10 Commits

Author SHA1 Message Date
Alex
eb7b7c9da5 Merge baa5973128 into 6440a88dc6 2025-06-06 10:52:01 +03:00
Arthur Sonzogni
6440a88dc6 Add docs for additional install methods (#1059)
Some checks failed
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (cl, cl, windows-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, ubuntu-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
Build / Test modules (llvm, ubuntu-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
2025-06-05 12:13:41 +02:00
Arthur Sonzogni
14da21b0ee Improve documentation (#1058)
* Remove @ingroup from class member definitions
* Add the documentation for every public classes.
2025-06-05 11:35:14 +02:00
Arthur Sonzogni
a86d8f32d7 docs: fix module documentation (#1056)
Some checks are pending
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (cl, cl, windows-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, ubuntu-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Waiting to run
Build / Test modules (llvm, ubuntu-latest) (push) Waiting to run
Documentation / documentation (push) Waiting to run
2025-06-05 07:16:53 +02:00
Arthur Sonzogni
3367c3a005 docs: fix typos and grammar (#1055)
Some checks are pending
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (cl, cl, windows-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, ubuntu-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Waiting to run
Build / Test modules (llvm, ubuntu-latest) (push) Waiting to run
Documentation / documentation (push) Waiting to run
2025-06-04 19:40:43 +02:00
Arthur Sonzogni
44dcd41b5e Fix typo in Microsoft terminal comment (#1054)
Some checks are pending
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (cl, cl, windows-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, ubuntu-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Waiting to run
Build / Test modules (llvm, ubuntu-latest) (push) Waiting to run
Documentation / documentation (push) Waiting to run
2025-06-04 15:23:29 +02:00
Arthur Sonzogni
96d817217c Fix reversed comments for string conversion functions (#1053) 2025-06-04 15:19:03 +02:00
Arthur Sonzogni
bbe6d1e0a3 fix typos in Maybe comments (#1052) 2025-06-04 15:16:44 +02:00
Miko
b65bbce9bb Add modules support (#1015)
Add experimental C++20 module suppport.
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2025-06-04 15:02:20 +02:00
alexv-ds
baa5973128 msvc getenv deprecation warn fix 2024-07-18 18:34:34 +03:00
103 changed files with 1708 additions and 261 deletions

View File

@@ -165,3 +165,47 @@ jobs:
flags: ${{ runner.os }} flags: ${{ runner.os }}
name: ${{ runner.os }}-coverage name: ${{ runner.os }}-coverage
files: ./build/coverage.xml files: ./build/coverage.xml
test_modules:
name: "Test modules"
strategy:
matrix:
include:
- os: ubuntu-latest
compiler: llvm
# TODO add gcc / msvc
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Setup Cpp"
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
cmake: true
ninja: true
clangtidy: false
cppcheck: false
opencppcoverage: false
- name: "Generate ./examples_modules"
run: >
./tools/generate_examples_modules.sh
- name: "Build modules"
run: >
mkdir build;
cd build;
cmake ..
-DCMAKE_GENERATOR=Ninja
-DFTXUI_BUILD_MODULES=ON
-DFTXUI_BUILD_EXAMPLES=ON
-DCMAKE_BUILD_TYPE=Debug
-DFTXUI_BUILD_DOCS=OFF
-DFTXUI_BUILD_TESTS=OFF
-DFTXUI_BUILD_TESTS_FUZZER=OFF
-DFTXUI_ENABLE_INSTALL=ON
-DFTXUI_DEV_WARNINGS=ON ;
cmake --build .

2
.gitignore vendored
View File

@@ -62,8 +62,10 @@ out/
!include/ftxui/**/*.cpp !include/ftxui/**/*.cpp
# src directory: # src directory:
!src/ftxui/*.cppm
!src/ftxui/**/*.hpp !src/ftxui/**/*.hpp
!src/ftxui/**/*.cpp !src/ftxui/**/*.cpp
!src/ftxui/**/*.cppm
# tools directory: # tools directory:
!tools/**/*.sh !tools/**/*.sh

View File

@@ -9,6 +9,22 @@ Next
- Use Doxygen awesome. Add our own theme. - Use Doxygen awesome. Add our own theme.
- Break the documentation into several pages. - Break the documentation into several pages.
### Build
- Feature: Support C++20 modules.
This requires:
- Using the Ninja or MSVC generator
- A recent Clang/GCC/MSVC compiler.
- Cmake 3.28 or higher.
Usage:
```cpp
import ftxui;
import ftxui.component;
import ftxui.dom;
import ftxui.screen;
import ftxui.util;
```
Thanks @mikomikotaishi for PR #1015.
6.1.9 (2025-05-07) 6.1.9 (2025-05-07)
------------ ------------

View File

@@ -1,4 +1,19 @@
cmake_minimum_required(VERSION 3.12) option(FTXUI_BUILD_DOCS "Set to ON to build docs" OFF)
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" OFF)
option(FTXUI_BUILD_MODULES "Build the C++20 modules" OFF)
option(FTXUI_BUILD_TESTS "Set to ON to build tests" OFF)
option(FTXUI_BUILD_TESTS_FUZZER "Set to ON to enable fuzzing" OFF)
option(FTXUI_CLANG_TIDY "Execute clang-tidy" OFF)
option(FTXUI_DEV_WARNINGS "Enable more compiler warnings and warnings as errors" OFF)
option(FTXUI_ENABLE_COVERAGE "Execute code coverage" OFF)
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
option(FTXUI_QUIET "Set to ON for FTXUI to be quiet" OFF)
if (FTXUI_BUILD_MODULES)
cmake_minimum_required(VERSION 3.28.2)
else()
cmake_minimum_required(VERSION 3.12)
endif()
project(ftxui project(ftxui
LANGUAGES CXX LANGUAGES CXX
@@ -6,15 +21,6 @@ project(ftxui
DESCRIPTION "C++ Functional Terminal User Interface." DESCRIPTION "C++ Functional Terminal User Interface."
) )
option(FTXUI_QUIET "Set to ON for FTXUI to be quiet" OFF)
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" OFF)
option(FTXUI_BUILD_DOCS "Set to ON to build docs" OFF)
option(FTXUI_BUILD_TESTS "Set to ON to build tests" OFF)
option(FTXUI_BUILD_TESTS_FUZZER "Set to ON to enable fuzzing" OFF)
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
option(FTXUI_CLANG_TIDY "Execute clang-tidy" OFF)
option(FTXUI_ENABLE_COVERAGE "Execute code coverage" OFF)
option(FTXUI_DEV_WARNINGS "Enable more compiler warnings and warnings as errors" OFF)
set(FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT "On windows, assume the \ set(FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT "On windows, assume the \
terminal used will be one of Microsoft and use a set of reasonnable fallback \ terminal used will be one of Microsoft and use a set of reasonnable fallback \
@@ -176,6 +182,13 @@ include(cmake/iwyu.cmake)
include(cmake/ftxui_export.cmake) include(cmake/ftxui_export.cmake)
include(cmake/ftxui_install.cmake) include(cmake/ftxui_install.cmake)
include(cmake/ftxui_package.cmake) include(cmake/ftxui_package.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
# ./tools/generate_examples_modules.sh
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples_modules/CMakeLists.txt")
add_subdirectory(examples_modules)
endif()

View File

@@ -39,7 +39,8 @@ A simple cross-platform C++ library for terminal based user interfaces!
* Support for [UTF8](https://en.wikipedia.org/wiki/UTF-8) and [fullwidth chars](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) (→ 测试) * Support for [UTF8](https://en.wikipedia.org/wiki/UTF-8) and [fullwidth chars](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) (→ 测试)
* Support for animations. [Demo 1](https://arthursonzogni.github.io/FTXUI/examples/?file=component/menu_underline_animated_gallery), [Demo 2](https://arthursonzogni.github.io/FTXUI/examples/?file=component/button_style) * Support for animations. [Demo 1](https://arthursonzogni.github.io/FTXUI/examples/?file=component/menu_underline_animated_gallery), [Demo 2](https://arthursonzogni.github.io/FTXUI/examples/?file=component/button_style)
* Support for drawing. [Demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/canvas_animated) * Support for drawing. [Demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/canvas_animated)
* No dependencies * No dependencies.
* [C++20 Module support](https://arthursonzogni.github.io/FTXUI/cpp20-modules.html)
* **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!). * **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!).
* Learn by [examples](#documentation), and [tutorials](#documentation) * Learn by [examples](#documentation), and [tutorials](#documentation)
* Multiple packages: * Multiple packages:
@@ -49,7 +50,9 @@ A simple cross-platform C++ library for terminal based user interfaces!
- [Conan](https://conan.io/center/recipes/ftxui) [Debian package](https://tracker.debian.org/pkg/ftxui) - [Conan](https://conan.io/center/recipes/ftxui) [Debian package](https://tracker.debian.org/pkg/ftxui)
- [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui) - [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui)
- [Arch Linux](https://aur.archlinux.org/packages/ftxui/) - [Arch Linux](https://aur.archlinux.org/packages/ftxui/)
- [OpenSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui) - [OpenSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui)
- [XMake](https://xmake.io) repository [package](https://github.com/xmake-io/xmake-repo/blob/dev/packages/f/ftxui/xmake.lua)
- [Nix](https://github.com/ArthurSonzogni/FTXUI/blob/main/flake.nix)
* Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc... * Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc...
## Documentation ## Documentation
@@ -95,7 +98,7 @@ Element can be arranged together:
- inside a grid with `gridbox` - inside a grid with `gridbox`
- wrap along one direction using the `flexbox`. - wrap along one direction using the `flexbox`.
Element can become flexible using the the `flex` decorator. Element can become flexible using the `flex` decorator.
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2vbox_hbox_8cpp-example.html) using `hbox`, `vbox` and `filler`. [Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2vbox_hbox_8cpp-example.html) using `hbox`, `vbox` and `filler`.
@@ -357,6 +360,7 @@ Feel free to add your projects here:
- [terminal-rain](https://github.com/Oakamoore/terminal-rain) - [terminal-rain](https://github.com/Oakamoore/terminal-rain)
- [keywords](https://github.com/Oakamoore/keywords) ([Play web version :heart:](https://oakamoore.itch.io/keywords)) - [keywords](https://github.com/Oakamoore/keywords) ([Play web version :heart:](https://oakamoore.itch.io/keywords))
- [FTB - tertminal file browser](https://github.com/Cyxuan0311/FTB) - [FTB - tertminal file browser](https://github.com/Cyxuan0311/FTB)
- [openJuice](https://github.com/mikomikotaishi/openJuice)
- [SHOOT!](https://github.com/ShingZhanho/ENGG1340-Project-25Spring) - [SHOOT!](https://github.com/ShingZhanho/ENGG1340-Project-25Spring)
### [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)
@@ -427,6 +431,7 @@ If you don't, FTXUI may be used from the following packages:
- [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui), - [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui),
- [Arch Linux](https://aur.archlinux.org/packages/ftxui/), - [Arch Linux](https://aur.archlinux.org/packages/ftxui/),
- [OpenSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui), - [OpenSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui),
[Nix](https://github.com/ArthurSonzogni/FTXUI/blob/main/flake.nix),
[![Packaging status](https://repology.org/badge/vertical-allrepos/libftxui.svg)](https://repology.org/project/libftxui/versions) [![Packaging status](https://repology.org/badge/vertical-allrepos/libftxui.svg)](https://repology.org/project/libftxui/versions)
@@ -435,6 +440,8 @@ If you choose to build and link FTXUI yourself, `ftxui-component` must be first
g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . . g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . .
``` ```
To build FTXUI with modules, check [documentation](https://arthursonzogni.github.io/FTXUI/cpp20-modules.html)
## Contributors ## Contributors
<a href="https://github.com/ArthurSonzogni/FTXUI/graphs/contributors"> <a href="https://github.com/ArthurSonzogni/FTXUI/graphs/contributors">

View File

@@ -5,13 +5,14 @@ function(ftxui_message msg)
endfunction() endfunction()
ftxui_message("┌─ FTXUI options ─────────────────────") ftxui_message("┌─ FTXUI options ─────────────────────")
ftxui_message("│ FTXUI_ENABLE_INSTALL : ${FTXUI_ENABLE_INSTALL}")
ftxui_message("│ FTXUI_BUILD_EXAMPLES : ${FTXUI_BUILD_EXAMPLES}")
ftxui_message("│ FTXUI_QUIET : ${FTXUI_QUIET}")
ftxui_message("│ FTXUI_BUILD_DOCS : ${FTXUI_BUILD_DOCS}") ftxui_message("│ FTXUI_BUILD_DOCS : ${FTXUI_BUILD_DOCS}")
ftxui_message("│ FTXUI_BUILD_EXAMPLES : ${FTXUI_BUILD_EXAMPLES}")
ftxui_message("│ FTXUI_BUILD_MODULES : ${FTXUI_BUILD_MODULES}")
ftxui_message("│ FTXUI_BUILD_TESTS : ${FTXUI_BUILD_TESTS}") ftxui_message("│ FTXUI_BUILD_TESTS : ${FTXUI_BUILD_TESTS}")
ftxui_message("│ FTXUI_BUILD_TESTS_FUZZER : ${FTXUI_BUILD_TESTS_FUZZER}") ftxui_message("│ FTXUI_BUILD_TESTS_FUZZER : ${FTXUI_BUILD_TESTS_FUZZER}")
ftxui_message("│ FTXUI_ENABLE_COVERAGE : ${FTXUI_ENABLE_COVERAGE}")
ftxui_message("│ FTXUI_DEV_WARNINGS : ${FTXUI_DEV_WARNINGS}")
ftxui_message("│ FTXUI_CLANG_TIDY : ${FTXUI_CLANG_TIDY}") ftxui_message("│ FTXUI_CLANG_TIDY : ${FTXUI_CLANG_TIDY}")
ftxui_message("│ FTXUI_DEV_WARNINGS : ${FTXUI_DEV_WARNINGS}")
ftxui_message("│ FTXUI_ENABLE_COVERAGE : ${FTXUI_ENABLE_COVERAGE}")
ftxui_message("│ FTXUI_ENABLE_INSTALL : ${FTXUI_ENABLE_INSTALL}")
ftxui_message("│ FTXUI_QUIET : ${FTXUI_QUIET}")
ftxui_message("└─────────────────────────────────────") ftxui_message("└─────────────────────────────────────")

82
cmake/ftxui_modules.cmake Normal file
View File

@@ -0,0 +1,82 @@
if (NOT FTXUI_BUILD_MODULES)
return()
endif()
add_library(ftxui-modules)
target_sources(ftxui-modules
PUBLIC FILE_SET CXX_MODULES FILES
src/ftxui/component.cppm
src/ftxui/component/animation.cppm
src/ftxui/component/captured_mouse.cppm
src/ftxui/component/component.cppm
src/ftxui/component/component_base.cppm
src/ftxui/component/component_options.cppm
src/ftxui/component/event.cppm
src/ftxui/component/loop.cppm
src/ftxui/component/mouse.cppm
src/ftxui/component/receiver.cppm
src/ftxui/component/screen_interactive.cppm
src/ftxui/component/task.cppm
src/ftxui/dom.cppm
src/ftxui/dom/canvas.cppm
src/ftxui/dom/deprecated.cppm
src/ftxui/dom/direction.cppm
src/ftxui/dom/elements.cppm
src/ftxui/dom/flexbox_config.cppm
src/ftxui/dom/linear_gradient.cppm
src/ftxui/dom/node.cppm
src/ftxui/dom/requirement.cppm
src/ftxui/dom/selection.cppm
src/ftxui/dom/table.cppm
src/ftxui/screen.cppm
src/ftxui/screen/box.cppm
src/ftxui/screen/color.cppm
src/ftxui/screen/color_info.cppm
src/ftxui/screen/deprecated.cppm
src/ftxui/screen/image.cppm
src/ftxui/screen/pixel.cppm
src/ftxui/screen/screen.cppm
src/ftxui/screen/string.cppm
src/ftxui/screen/terminal.cppm
src/ftxui/util.cppm
src/ftxui/util/autoreset.cppm
src/ftxui/util/ref.cppm
)
target_link_libraries(ftxui-modules
PUBLIC
ftxui::screen
ftxui::dom
ftxui::component
)
target_compile_features(ftxui-modules PUBLIC cxx_std_20)
# TODO: Explain why this is needed.
if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(ftxui-modules PUBLIC -fmodules-ts)
endif ()
add_library(ftxui::modules ALIAS ftxui-modules)
if(FTXUI_ENABLE_INSTALL)
include(GNUInstallDirs)
install(TARGETS ftxui-modules
EXPORT ftxui-targets
FILE_SET CXX_MODULES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ftxui
FILE_SET HEADERS
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ftxui
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ftxui
)
install(EXPORT ftxui-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
CXX_MODULES_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
)
install(FILES my_package-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
)
endif()

View File

@@ -1001,48 +1001,12 @@ INPUT_FILE_ENCODING =
FILE_PATTERNS = *.c \ FILE_PATTERNS = *.c \
*.cc \ *.cc \
*.cxx \
*.cpp \ *.cpp \
*.c++ \
*.java \
*.ii \
*.ixx \
*.ipp \ *.ipp \
*.i++ \
*.inl \
*.idl \
*.ddl \
*.odl \
*.h \ *.h \
*.hh \
*.hxx \
*.hpp \ *.hpp \
*.h++ \
*.cs \
*.d \
*.php \
*.php4 \
*.php5 \
*.phtml \
*.inc \
*.m \
*.markdown \
*.md \ *.md \
*.mm \ *.cppm \
*.dox \
*.py \
*.pyw \
*.f90 \
*.f95 \
*.f03 \
*.f08 \
*.f \
*.for \
*.tcl \
*.vhd \
*.vhdl \
*.ucf \
*.qsf
# The RECURSIVE tag can be used to specify whether or not subdirectories should # The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well. # be searched for input files as well.

84
doc/cpp20-modules.md Normal file
View File

@@ -0,0 +1,84 @@
@page cpp20-modules C++20 Modules
> [!WARNING]
> 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
> of C++20 modules in FTXUI. If you encounter any issues or have suggestions,
> please open an issue.
FTXUI experimentally supports
[C++20 modules](https://en.cppreference.com/w/cpp/language/modules) to reduce
compilation times and improve code organization. Each header has a
corresponding module.
**Example with CMake and Ninja**
```cpp
import ftxui;
int main() {
auto screen = ftxui::ScreenInteractive::TerminalOutput();
auto button = ftxui::Button("Click me", screen.QuitClosure());
screen.Loop(button);
return 0;
}
```
```sh
cmake \
-DCMAKE_GENERATOR=Ninja \
-DFTXUI_BUILD_MODULES=ON \
..
ninja
```
> [!NOTE]
> 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
> generators **do not support modules**.
### Module list
The modules directly reference the corresponding header, or a group of related
headers to provide a more convenient interface. The following modules
are available:
- `ftxui`
- `ftxui.component`
- `ftxui.component.Animation`
- `ftxui.component.CapturedMouse`
- `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`

View File

@@ -108,7 +108,6 @@
console.log("navtree.textContent", navtree.textContent); console.log("navtree.textContent", navtree.textContent);
if (!navtree.textContent.includes("Getting Started") && if (!navtree.textContent.includes("Getting Started") &&
!navtree.textContent.includes("Installation") && !navtree.textContent.includes("Installation") &&
!navtree.textContent.includes("Modules") &&
!navtree.textContent.includes("ftxui / screen") && !navtree.textContent.includes("ftxui / screen") &&
!navtree.textContent.includes("ftxui / dom") && !navtree.textContent.includes("ftxui / dom") &&
!navtree.textContent.includes("ftxui / component") && !navtree.textContent.includes("ftxui / component") &&

View File

@@ -16,6 +16,11 @@ This page serves as an entry point for the available integration methods.
- @subpage installation_vcpkg - @subpage installation_vcpkg
- @subpage installation_conan - @subpage installation_conan
- @subpage installation_manual - @subpage installation_manual
- @subpage installation_nix
- @subpage installation_debian
- @subpage installation_arch
- @subpage installation_opensuse
- @subpage installation_xmake
## Next Steps ## Next Steps

34
doc/installation_arch.md Normal file
View File

@@ -0,0 +1,34 @@
@page installation_arch Arch Linux
FTXUI is packaged on the AUR. Install using an AUR helper:
```bash
yay -S ftxui
```
You can also manually download the PKGBUILD from <https://aur.archlinux.org/packages/ftxui>.
Once installed, you can use it in your CMake projects by adding the following to your `CMakeLists.txt`:
```cmake
find_package(ftxui REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)
```
> [!note]
> This is an unofficial package. That means it is not maintained by the FTXUI
> team, but by the community. The package maintainers seems to actively update
> the package to the latest version. Thanks to the maintainers for their work!
<div class="section_buttons">
| Previous |
|:------------------|
| [Getting Started](getting-started.html) |
</div>

View File

@@ -10,7 +10,7 @@ This page explains how to depend on FTXUI using [CMake](https://cmake.org).
This approach downloads FTXUI at configure time and doesn't require a system-wide install. This approach downloads FTXUI at configure time and doesn't require a system-wide install.
```fortran ```cmake
include(FetchContent) include(FetchContent)
FetchContent_Declare(ftxui FetchContent_Declare(ftxui
@@ -34,8 +34,8 @@ This ensures reproducible builds and easy dependency management.
If FTXUI is installed system-wide or via a package manager (e.g. vcpkg or Conan), you can use: If FTXUI is installed system-wide or via a package manager (e.g. vcpkg or Conan), you can use:
```fortran ```cmake
fortranind_package(ftxui REQUIRED) find_package(ftxui REQUIRED)
add_executable(main main.cpp) add_executable(main main.cpp)
target_link_libraries(main target_link_libraries(main
@@ -51,7 +51,7 @@ Make sure the package is visible in your `CMAKE_PREFIX_PATH`.
You can also add FTXUI as a [Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules), keeping it as part of your repository: You can also add FTXUI as a [Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules), keeping it as part of your repository:
```fortran ```cmake
git submodule add https://github.com/ArthurSonzogni/FTXUI external/ftxui git submodule add https://github.com/ArthurSonzogni/FTXUI external/ftxui
git submodule update --init --recursive git submodule update --init --recursive
``` ```
@@ -66,7 +66,7 @@ git submodule update --init --recursive
Then in your `CMakeLists.txt`: Then in your `CMakeLists.txt`:
```fortran ```cmake
add_subdirectory(external/ftxui) add_subdirectory(external/ftxui)
add_executable(main main.cpp) add_executable(main main.cpp)

View File

@@ -1,15 +1,19 @@
@page installation_conan Conan @page installation_conan Conan
@tableofcontents
## Conan Package Unofficial recipe for FTXUI exists on Conan Center:
<https://conan.io/center/recipes/ftxui>
Unofficial support for FTXUI exists on Conan Center: > [!note]
> This is an unofficial recipe. That means it is not maintained by the FTXUI
> team, but by the community. The package maintainers seems to actively update
> the package to the latest version. Thanks to the maintainers for their work!
- https://conan.io/center/recipes/ftxui
## TODO @todo Add instructions on how to use the conan recipe.
This page is incomplete. If you use FTXUI with Conan and can provide a minimal working setup, feel free to contribute. @todo Please consider adding an "official" recipe to Conan Center if know how.
It could be a github action that will automatically update the conan center
when a new release is made.
<div class="section_buttons"> <div class="section_buttons">

View File

@@ -0,0 +1,42 @@
@page installation_debian Debian/Ubuntu
## Debian and Ubuntu Packages (Unofficial)
Pre-built packages are provided by the distributions. Install with:
```bash
sudo apt install libftxui-dev
```
The following packages are available:
- `ftxui-doc`
- `ftxui-examples`
- `libftxui-component<version>`
- `libftxui-dev`
- `libftxui-dom<version>`
- `libftxui-screen<version>`
Once installed, you can use it in your CMake projects by adding the following to
your `CMakeLists.txt`:
```cmake
find_package(ftxui REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)
```
> [!note]
> This is an **unofficial** package. That means it is not maintained by the FTXUI
> team, but by the community.
<div class="section_buttons">
| Previous |
|:------------------|
| [Getting Started](getting-started.html) |
</div>

View File

@@ -0,0 +1,35 @@
@page installation_manual Manual
@tableofcontents
## Building from Source (Official)
Clone and build the project using CMake:
```bash
git clone https://github.com/ArthurSonzogni/FTXUI.git
cd FTXUI
cmake -S . -B build -DFTXUI_ENABLE_INSTALL=ON -D
cmake --build build -j
sudo cmake --install build
```
Once installed you can use it in your CMake projects by adding the following to your `CMakeLists.txt`:
```cmake
find_package(ftxui REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)
```
<div class="section_buttons">
| Previous |
|:------------------|
| [Getting Started](getting-started.html) |
</div>

38
doc/installation_nix.md Normal file
View File

@@ -0,0 +1,38 @@
@page installation_nix Nix
> [!note]
> FTXUI author is not very knowledgeable about Nix. This page has been mostly
> generated by AI. If you have any suggestions to improve it, please open a
> PR.
## Nix Flake
FTXUI ships with a `flake.nix` providing both packages and a development shell.
### Build the Library
```bash
nix build github:ArthurSonzogni/FTXUI
```
The resulting package is accessible via the `result` link.
### Use as a Dependency
Add FTXUI to your flake inputs:
```nix
{
inputs.ftxui.url = "github:ArthurSonzogni/FTXUI";
}
```
Then reference `ftxui.packages.<system>.ftxui` in your outputs.
<div class="section_buttons">
| Previous |
|:------------------|
| [Getting Started](getting-started.html) |
</div>

View File

@@ -0,0 +1,32 @@
@page installation_opensuse openSUSE
## openSUSE Package (Unofficial)
FTXUI seems to be available from the `devel:libraries:c_c++` repository.
```bash
sudo zypper addrepo https://download.opensuse.org/repositories/devel:libraries:c_c++/openSUSE_Leap_$releasever/devel:libraries:c_c++.repo
sudo zypper install ftxui
```
See <https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui> for details.
> [!note]
> This is an **unofficial** package. That means it is not maintained by the FTXUI
> team, but by the community.
--
> [!note]
> The FTXUI author is not very knowledgeable about openSUSE. This page has been
> mostly generated by AI. If you have any suggestions to improve it, please open
> a PR.
<div class="section_buttons">
| Previous |
|:------------------|
| [Getting Started](getting-started.html) |
</div>

View File

@@ -1,15 +1,74 @@
@page installation_vcpkg Vcpkg @page installation_vcpkg Vcpkg
@tableofcontents @tableofcontents
## Vcpkg Package # Vcpkg Package
FTXUI is available in the Vcpkg registry: FTXUI is available in the [Vcpkg registry](https://vcpkg.link/ports/ftxui)
To use it, you can add the following to your `vcpkg.json`:
```json
{
"name": "your-project",
"version-string": "0.1.0",
"dependencies": [
{
"name": "ftxui",
"version>=": "6.1.9"
}
]
}
```
# Install FTXUI using Vcpkg
```bash
vcpkg install --triplet x64-linux # or x64-windows / arm64-osx etc.
```
# Configure your build system.
If you are using CMake, you can use the following in your `CMakeLists.txt`:
**CMakeLists.txt**
```cmake
cmake_minimum_required(VERSION 3.15)
project(my_project)
# Make sure vcpkg toolchain file is passed at configure time
find_package(ftxui CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)
```
**main.cpp**
```cpp
#include <ftxui/component/screen_interactive.hpp>
#include <ftxui/component/component.hpp>
#include <ftxui/component/component_options.hpp>
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();
auto button = Button("Click me", [] { std::cout << "Clicked!\n"; });
screen.Loop(button);
}
```
**Configure and build the project**
```bash
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build
./build/main
```
- https://vcpkg.link/ports/ftxui
## TODO
This page is incomplete. If you use FTXUI with Vcpkg, please help improve this page by contributing working configuration examples.
<div class="section_buttons"> <div class="section_buttons">

40
doc/installation_xmake.md Normal file
View File

@@ -0,0 +1,40 @@
@page installation_xmake XMake
@tableofcontents
## XMake Package (Unofficial)
FTXUI is available in the [xmake-repo](https://github.com/xmake-io/xmake-repo/blob/dev/packages/f/ftxui/xmake.lua)
Example `xmake.lua` snippet:
```lua
add_requires("ftxui", {system = false})
target("demo")
set_kind("binary")
add_files("src/*.cpp")
add_packages("ftxui")
```
Refer to the [XMake documentation](https://xmake.io) for further options.
> [!note]
> This is an **unofficial** package. That means it is not maintained by the FTXUI
> team, but by the community.
---
> [!note]
> The FTXUI author is not very knowledgeable about openSUSE. This page has been
> mostly generated by AI. If you have any suggestions to improve it, please open
> a PR.
---
<div class="section_buttons">
| Previous |
|:------------------|
| [Getting Started](getting-started.html) |
</div>

View File

@@ -14,7 +14,7 @@ A `ftxui::Component` is a shared pointer to a `ftxui::ComponentBase`. The latter
- `ftxui::ComponentBase::Render()`: How to render the interface. - `ftxui::ComponentBase::Render()`: How to render the interface.
- `ftxui::ComponentBase::OnEvent()`: How to react to events. - `ftxui::ComponentBase::OnEvent()`: How to react to events.
- `ftxui::ComponentBase::Add()`: Construct a parent/child relationship - `ftxui::ComponentBase::Add()`: Construct a parent/child relationship
between two components. The tree of component is used to define how to between two components. The tree of components is used to define how to
navigate using the keyboard. navigate using the keyboard.
`ftxui::Element` are used to render a single frame. `ftxui::Element` are used to render a single frame.
@@ -45,7 +45,7 @@ Produced by: `ftxui::Input()` from "ftxui/component/component.hpp"
## Filtered input ## Filtered input
On can filter out the characters received by the input component, using One can filter out the characters received by the input component, using
`ftxui::CatchEvent`. `ftxui::CatchEvent`.
```cpp ```cpp
@@ -123,8 +123,8 @@ Produced by: `ftxui::Radiobox()` from "ftxui/component/component.hpp"
# Dropdown {#component-dropdown} # Dropdown {#component-dropdown}
A drop down menu is a component that when checked display a list of element for A drop-down menu is a component that, when opened, displays a list of elements
the user to select one. for the user to select from.
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2dropdown_8cpp-example.html): [Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2dropdown_8cpp-example.html):
@@ -204,12 +204,12 @@ component = component
# Collapsible {#component-collapsible} # Collapsible {#component-collapsible}
Useful for visual elements whose visibility can be toggle on/off by the user. Useful for visual elements whose visibility can be toggled on or off by the
Essentially, this the combination of the `ftxui::Checkbox()` and user. Essentially, this is the combination of the `ftxui::Checkbox()` and
`ftxui::Maybe()` components. `ftxui::Maybe()` components.
```cpp ```cpp
auto collabsible = Collapsible("Show more", inner_element); auto collapsible = Collapsible("Show more", inner_element);
``` ```
# Maybe {#component-maybe} # Maybe {#component-maybe}
@@ -245,7 +245,7 @@ component = component
Produced by: `ftxui::Container::Horizontal()` from Produced by: `ftxui::Container::Horizontal()` from
"ftxui/component/component.hpp". It displays a list of components horizontally "ftxui/component/component.hpp". It displays a list of components horizontally
and handle keyboard/mouse navigation. and handles keyboard/mouse navigation.
## Vertical {#component-vertical} ## Vertical {#component-vertical}
@@ -256,8 +256,8 @@ and handles keyboard/mouse navigation.
## Tab {#component-tab} ## Tab {#component-tab}
Produced by: `ftxui::Container::Tab()` from Produced by: `ftxui::Container::Tab()` from
"ftxui/component/component.hpp". It take a list of component and display only "ftxui/component/component.hpp". It takes a list of components and displays
one of them. This is useful for implementing a tab bar. only one of them. This is useful for implementing a tab bar.
[Vertical](https://arthursonzogni.github.io/FTXUI/examples_2component_2tab_vertical_8cpp-example.html): [Vertical](https://arthursonzogni.github.io/FTXUI/examples_2component_2tab_vertical_8cpp-example.html):

View File

@@ -207,7 +207,7 @@ Code:
border(gauge(0.5)) border(gauge(0.5))
``` ```
Teminal output: Terminal output:
```bash ```bash
┌────────────────────────────────────────────────────────────────────────────┐ ┌────────────────────────────────────────────────────────────────────────────┐
│██████████████████████████████████████ │ │██████████████████████████████████████ │
@@ -407,7 +407,7 @@ Checkout this
and the associated and the associated
[demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/flexbox). [demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/flexbox).
Element can also become flexible using the the `ftxui::flex` decorator. Element can also become flexible using the `ftxui::flex` decorator.
Code: Code:
```cpp ```cpp

View File

@@ -1,4 +1,4 @@
# Modules {#modules} # ftxui {#ftxui}
![title-img](https://nsm09.casimages.com/img/2025/05/30//2505300816063242518595251.jpg) ![title-img](https://nsm09.casimages.com/img/2025/05/30//2505300816063242518595251.jpg)

View File

@@ -3,6 +3,7 @@
// the LICENSE file. // the LICENSE file.
#include <ftxui/component/component.hpp> #include <ftxui/component/component.hpp>
#include <ftxui/component/screen_interactive.hpp> #include <ftxui/component/screen_interactive.hpp>
#include <string>
using namespace ftxui; using namespace ftxui;

View File

@@ -3,6 +3,7 @@
// the LICENSE file. // the LICENSE file.
#include <ftxui/component/component.hpp> #include <ftxui/component/component.hpp>
#include <ftxui/component/screen_interactive.hpp> #include <ftxui/component/screen_interactive.hpp>
#include <string>
using namespace ftxui; using namespace ftxui;

View File

@@ -8,11 +8,21 @@
#include <functional> // for function #include <functional> // for function
namespace ftxui::animation { namespace ftxui::animation {
// Components who haven't completed their animation can call this function to /// @brief RequestAnimationFrame is a function that requests a new frame to be
// request a new frame to be drawn later. /// drawn in the next animation cycle.
// ///
// When there is no new events and no animations to complete, no new frame is /// @note This function is typically called by components that need to
// drawn. /// update their state or appearance over time, such as animations or
/// transitions. This is useful when the change doesn't depend depend on the
/// events seen by the terminal, but rather on the passage of time.
///
/// Components who haven't completed their animation can call this function to
/// request a new frame to be drawn later.
///
/// When there is no new events and no animations to complete, no new frame is
/// drawn.
///
/// @ingroup component
void RequestAnimationFrame(); void RequestAnimationFrame();
using Clock = std::chrono::steady_clock; using Clock = std::chrono::steady_clock;

View File

@@ -7,6 +7,7 @@
#include <memory> #include <memory>
namespace ftxui { namespace ftxui {
class CapturedMouseInterface { class CapturedMouseInterface {
public: public:
CapturedMouseInterface() = default; CapturedMouseInterface() = default;

View File

@@ -27,6 +27,8 @@ struct EntryState {
int index; ///< Index of the entry when applicable or -1. int index; ///< Index of the entry when applicable or -1.
}; };
/// @brief Option for the underline effect.
/// @ingroup component
struct UnderlineOption { struct UnderlineOption {
bool enabled = false; bool enabled = false;
@@ -230,7 +232,8 @@ struct SliderOption {
std::function<void()> on_change; ///> Called when `value` is updated. std::function<void()> on_change; ///> Called when `value` is updated.
}; };
// Parameter pack used by `WindowOptions::render`. /// @brief State passed to the `Window` component's render function.
/// @ingroup component
struct WindowRenderState { struct WindowRenderState {
Element inner; ///< The element wrapped inside this window. Element inner; ///< The element wrapped inside this window.
const std::string& title; ///< The title of the window. const std::string& title; ///< The title of the window.

View File

@@ -24,6 +24,8 @@ class ComponentBase;
/// ///
/// Useful documentation about xterm specification: /// Useful documentation about xterm specification:
/// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html /// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
///
/// @ingroup component
struct Event { struct Event {
// --- Constructor section --------------------------------------------------- // --- Constructor section ---------------------------------------------------
static Event Character(std::string); static Event Character(std::string);

View File

@@ -14,6 +14,45 @@ class ComponentBase;
using Component = std::shared_ptr<ComponentBase>; using Component = std::shared_ptr<ComponentBase>;
class ScreenInteractive; class ScreenInteractive;
/// @brief Loop is a class that manages the event loop for a component.
///
/// It is responsible for running the component, handling events, and
/// updating the screen.
///
/// The Loop class is designed to be used with a ScreenInteractive object,
/// which represents the terminal screen.
///
/// **Example**
/// ```cpp
/// #include <ftxui/component/component.hpp>
/// #include <ftxui/component/screen_interactive.hpp>
/// #include <ftxui/component/loop.hpp>
///
/// int main() {
/// auto screen = ftxui::ScreenInteractive::TerminalOutput();
/// auto component = ftxui::Button("Click me", [] { ... });
///
/// ftxui::Loop loop(screen.get(), component);
///
/// // Either
/// loop.Run(); // Blocking until the component quits.
///
/// // Or
/// loop.RunOnce(); // Non-blocking, returns immediately.
///
/// // Or
/// loop.RunOnceBlocking(); // Blocking until handling one event.
///
/// // Or in a loop:
/// while (!loop.HasQuitted()) {
/// loop.RunOnce();
///
/// // Do something else like running a different library loop function.
/// }
/// }
/// ```
///
/// @ingroup component
class Loop { class Loop {
public: public:
Loop(ScreenInteractive* screen, Component component); Loop(ScreenInteractive* screen, Component component);

View File

@@ -27,6 +27,10 @@ struct Event;
using Component = std::shared_ptr<ComponentBase>; using Component = std::shared_ptr<ComponentBase>;
class ScreenInteractivePrivate; class ScreenInteractivePrivate;
/// @brief ScreenInteractive is a `Screen` that can handle events, run a main
/// loop, and manage components.
///
/// @ingroup component
class ScreenInteractive : public Screen { class ScreenInteractive : public Screen {
public: public:
// Constructors: // Constructors:

View File

@@ -20,6 +20,21 @@
namespace ftxui { namespace ftxui {
/// @brief Canvas is a drawable buffer associated with drawing operations.
///
/// Canvas is a drawable area that can be used to create complex graphics. It
/// supports drawing points, lines, circles, ellipses, text, and images using
/// braille, block, or normal characters.
///
/// Note: A terminal contains cells. A cells is a unit of:
/// - 2x4 braille characters (1x1 pixel)
/// - 2x2 block characters (2x2 pixels)
/// - 2x4 normal characters (2x4 pixels)
///
/// You need to multiply the x coordinate by 2 and the y coordinate by 4 to
/// get the correct position in the terminal.
///
/// @ingroup dom
struct Canvas { struct Canvas {
public: public:
Canvas() = default; Canvas() = default;

View File

@@ -5,6 +5,11 @@
#define FTXUI_DOM_DIRECTION_HPP #define FTXUI_DOM_DIRECTION_HPP
namespace ftxui { namespace ftxui {
/// @brief Direction is an enumeration that represents the four cardinal
/// directions.
///
/// @ingroup dom
enum class Direction { enum class Direction {
Up = 0, Up = 0,
Down = 1, Down = 1,

View File

@@ -24,6 +24,14 @@ using Elements = std::vector<Element>;
using Decorator = std::function<Element(Element)>; using Decorator = std::function<Element(Element)>;
using GraphFunction = std::function<std::vector<int>(int, int)>; using GraphFunction = std::function<std::vector<int>(int, int)>;
/// @brief BorderStyle is an enumeration that represents the different styles
/// of borders that can be applied to elements in the terminal UI.
///
/// BorderStyle is an enumeration that represents the different styles of
/// borders that can be applied to elements in the terminal UI.
/// It is used to define the visual appearance of borders around elements,
/// such as windows, frames, or separators.
/// @ingroup dom
enum BorderStyle { enum BorderStyle {
LIGHT, LIGHT,
DASHED, DASHED,

View File

@@ -12,6 +12,19 @@
namespace ftxui { namespace ftxui {
/// @brief FlexboxConfig is a configuration structure that defines the layout
/// properties for a flexbox container.
//
/// It allows you to specify the direction of the flex items, whether they
/// should wrap, how they should be justified along the main axis, and how
/// they should be aligned along the cross axis.
/// It also includes properties for gaps between flex items in both the
/// main and cross axes.
/// This structure is used to configure the layout behavior of flexbox
/// containers in a terminal user interface.
///
/// @ingroup dom
struct FlexboxConfig { struct FlexboxConfig {
/// This establishes the main-axis, thus defining the direction flex items are /// This establishes the main-axis, thus defining the direction flex items are
/// placed in the flex container. Flexbox is (aside wrapping) single-direction /// placed in the flex container. Flexbox is (aside wrapping) single-direction

View File

@@ -27,8 +27,15 @@ namespace ftxui {
/// LinearGradient(Color::Red, Color::Blue); /// LinearGradient(Color::Red, Color::Blue);
/// LinearGradient(45, Color::Red, Color::Blue); /// LinearGradient(45, Color::Red, Color::Blue);
/// ``` /// ```
///
/// @ingroup dom
struct LinearGradient { struct LinearGradient {
float angle = 0.f; float angle = 0.f;
/// A stop is a color at a specific position in the gradient.
/// The position is a value between 0.0 and 1.0,
/// where 0.0 is the start of the gradient
/// and 1.0 is the end of the gradient.
struct Stop { struct Stop {
Color color = Color::Default; Color color = Color::Default;
std::optional<float> position; std::optional<float> position;

View File

@@ -20,6 +20,20 @@ class Screen;
using Element = std::shared_ptr<Node>; using Element = std::shared_ptr<Node>;
using Elements = std::vector<Element>; using Elements = std::vector<Element>;
/// @brief Node is the base class for all elements in the DOM tree.
///
/// It represents a single node in the document object model (DOM) and provides
/// the basic structure for layout and rendering.
/// It contains methods for computing layout requirements, setting the box
/// dimensions, selecting content, rendering to the screen, and checking the
/// layout status.
/// It typically contains child elements, which are also instances of Node.
///
/// Users are expected to derive from this class to create custom elements.
///
/// A list of builtin elements can be found in the `elements.hpp` file.
///
/// @ingroup dom
class Node { class Node {
public: public:
Node(); Node();

View File

@@ -10,6 +10,11 @@
namespace ftxui { namespace ftxui {
class Node; class Node;
/// @brief Requirement is a structure that defines the layout requirements for a
/// Node in the terminal user interface.
///
/// It specifies the minimum size required to fully draw the element,
/// @ingroup dom
struct Requirement { struct Requirement {
// The required size to fully draw the element. // The required size to fully draw the element.
int min_x = 0; int min_x = 0;

View File

@@ -13,7 +13,12 @@
namespace ftxui { namespace ftxui {
/// @brief Represent a selection in the terminal. /// @brief Represents a selection in a terminal user interface.
///
/// Selection is a class that represents the two endpoints of a selection in a
/// terminal user interface.
///
/// @ingroup dom
class Selection { class Selection {
public: public:
Selection(); // Empty selection. Selection(); // Empty selection.

View File

@@ -11,28 +11,28 @@
namespace ftxui { namespace ftxui {
// Usage:
//
// Initialization:
// ---------------
//
// auto table = Table({
// {"X", "Y"},
// {"-1", "1"},
// {"+0", "0"},
// {"+1", "1"},
// });
//
// table.SelectAll().Border(LIGHT);
//
// table.SelectRow(1).Border(DOUBLE);
// table.SelectRow(1).SeparatorInternal(Light);
//
// std::move(table).Element();
class Table; class Table;
class TableSelection; class TableSelection;
/// @brief Table is a utility to draw tables.
///
/// **example**
/// ```cpp
/// auto table = Table({
/// {"X", "Y"},
/// {"-1", "1"},
/// {"+0", "0"},
/// {"+1", "1"},
/// });
///
/// table.SelectAll().Border(LIGHT);
/// table.SelectRow(1).Border(DOUBLE);
/// table.SelectRow(1).SeparatorInternal(LIGHT);
///
/// std::move(table).Render();
/// ```
///
/// @ingroup dom
class Table { class Table {
public: public:
Table(); Table();

View File

@@ -6,6 +6,13 @@
namespace ftxui { namespace ftxui {
/// @brief Box is a structure that represents a rectangular area in a 2D space.
///
/// It is defined by its minimum and maximum coordinates along the x and y axes.
/// Note that the coordinates are inclusive, meaning that the box includes both
/// the minimum and maximum values.
///
/// @ingroup screen
struct Box { struct Box {
int x_min = 0; int x_min = 0;
int x_max = 0; int x_max = 0;

View File

@@ -15,7 +15,9 @@
namespace ftxui { namespace ftxui {
/// @brief A class representing terminal colors. /// @brief Color is a class that represents a color in the terminal user
/// interface.
///
/// @ingroup screen /// @ingroup screen
class Color { class Color {
public: public:

View File

@@ -9,6 +9,10 @@
namespace ftxui { namespace ftxui {
/// @brief ColorInfo is a structure that contains information about the terminal
/// color palette.
///
/// @ingroup screen
struct ColorInfo { struct ColorInfo {
const char* name; const char* name;
uint8_t index_256; uint8_t index_256;

View File

@@ -5,6 +5,9 @@
#define FTXUI_SCREEN_TERMINAL_HPP #define FTXUI_SCREEN_TERMINAL_HPP
namespace ftxui { namespace ftxui {
/// @brief Dimensions is a structure that represents the size of the terminal
/// @ingroup screen
struct Dimensions { struct Dimensions {
int dimx; int dimx;
int dimy; int dimy;
@@ -14,6 +17,9 @@ namespace Terminal {
Dimensions Size(); Dimensions Size();
void SetFallbackSize(const Dimensions& fallbackSize); void SetFallbackSize(const Dimensions& fallbackSize);
/// @brief Color is an enumeration that represents the color support of the
/// terminal.
/// @ingroup screen
enum Color { enum Color {
Palette1, Palette1,
Palette16, Palette16,

16
src/ftxui/component.cppm Normal file
View File

@@ -0,0 +1,16 @@
/// @module ftxui.component
/// @brief Module file for FTXUI component operations.
export module ftxui.component;
export import ftxui.component.animation;
export import ftxui.component.captured_mouse;
export import ftxui.component.component;
export import ftxui.component.component_base;
export import ftxui.component.component_options;
export import ftxui.component.event;
export import ftxui.component.loop;
export import ftxui.component.mouse;
export import ftxui.component.receiver;
export import ftxui.component.screen_interactive;
export import ftxui.component.task;

View File

@@ -0,0 +1,65 @@
/// @module ftxui.component.animation
/// @brief C++20 module interface for the Animation namespace of the Component module.
///
module;
#include <ftxui/component/animation.hpp>
export module ftxui.component.animation;
/**
* @namespace ftxui::animation
* @brief The FTXUI ftxui::animation:: namespace
*/
export namespace ftxui::animation {
using ftxui::animation::RequestAnimationFrame;
using ftxui::animation::Clock;
using ftxui::animation::TimePoint;
using ftxui::animation::Duration;
using ftxui::animation::Params;
/**
* @namespace easing
* @brief The FTXUI sf::animation::easing:: namespace
*/
namespace easing {
using ftxui::animation::easing::Function;
using ftxui::animation::easing::Linear;
using ftxui::animation::easing::QuadraticIn;
using ftxui::animation::easing::QuadraticOut;
using ftxui::animation::easing::QuadraticInOut;
using ftxui::animation::easing::CubicIn;
using ftxui::animation::easing::CubicOut;
using ftxui::animation::easing::CubicInOut;
using ftxui::animation::easing::QuarticIn;
using ftxui::animation::easing::QuarticOut;
using ftxui::animation::easing::QuarticInOut;
using ftxui::animation::easing::QuinticIn;
using ftxui::animation::easing::QuinticOut;
using ftxui::animation::easing::QuinticInOut;
using ftxui::animation::easing::SineIn;
using ftxui::animation::easing::SineOut;
using ftxui::animation::easing::SineInOut;
using ftxui::animation::easing::CircularIn;
using ftxui::animation::easing::CircularOut;
using ftxui::animation::easing::CircularInOut;
using ftxui::animation::easing::ExponentialIn;
using ftxui::animation::easing::ExponentialOut;
using ftxui::animation::easing::ExponentialInOut;
using ftxui::animation::easing::ElasticIn;
using ftxui::animation::easing::ElasticOut;
using ftxui::animation::easing::ElasticInOut;
using ftxui::animation::easing::BackIn;
using ftxui::animation::easing::BackOut;
using ftxui::animation::easing::BackInOut;
using ftxui::animation::easing::BounceIn;
using ftxui::animation::easing::BounceOut;
using ftxui::animation::easing::BounceInOut;
}
using ftxui::animation::Animator;
}

View File

@@ -0,0 +1,16 @@
/// @module ftxui.component.captured_mouse
/// @brief Module file for the CapturedMouseInterface class of the Component module
module;
#include <ftxui/component/captured_mouse.hpp>
export module ftxui.component.captured_mouse;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::CapturedMouseInterface;
}

View File

@@ -12,11 +12,11 @@
namespace ftxui { namespace ftxui {
/// @brief A collapsible component. It display a checkbox with an arrow. Once /// @brief A collapsible component. It displays a checkbox with an arrow. Once
/// activated, the children is displayed. /// activated, the child is displayed.
/// @param label The label of the checkbox. /// @param label The label of the checkbox.
/// @param child The children to display. /// @param child The child to display.
/// @param show Hold the state about whether the children is displayed or not. /// @param show Hold the state about whether the child is displayed or not.
/// ///
/// ### Example /// ### Example
/// ```cpp /// ```cpp

View File

@@ -35,26 +35,22 @@ ComponentBase::~ComponentBase() {
/// @brief Return the parent ComponentBase, or nul if any. /// @brief Return the parent ComponentBase, or nul if any.
/// @see Detach /// @see Detach
/// @see Parent /// @see Parent
/// @ingroup component
ComponentBase* ComponentBase::Parent() const { ComponentBase* ComponentBase::Parent() const {
return parent_; return parent_;
} }
/// @brief Access the child at index `i`. /// @brief Access the child at index `i`.
/// @ingroup component
Component& ComponentBase::ChildAt(size_t i) { Component& ComponentBase::ChildAt(size_t i) {
assert(i < ChildCount()); // NOLINT assert(i < ChildCount()); // NOLINT
return children_[i]; return children_[i];
} }
/// @brief Returns the number of children. /// @brief Returns the number of children.
/// @ingroup component
size_t ComponentBase::ChildCount() const { size_t ComponentBase::ChildCount() const {
return children_.size(); return children_.size();
} }
/// @brief Return index of the component in its parent. -1 if no parent. /// @brief Return index of the component in its parent. -1 if no parent.
/// @ingroup component
int ComponentBase::Index() const { int ComponentBase::Index() const {
if (parent_ == nullptr) { if (parent_ == nullptr) {
return -1; return -1;
@@ -71,7 +67,6 @@ int ComponentBase::Index() const {
/// @brief Add a child. /// @brief Add a child.
/// @@param child The child to be attached. /// @@param child The child to be attached.
/// @ingroup component
void ComponentBase::Add(Component child) { void ComponentBase::Add(Component child) {
child->Detach(); child->Detach();
child->parent_ = this; child->parent_ = this;
@@ -81,7 +76,6 @@ void ComponentBase::Add(Component child) {
/// @brief Detach this child from its parent. /// @brief Detach this child from its parent.
/// @see Detach /// @see Detach
/// @see Parent /// @see Parent
/// @ingroup component
void ComponentBase::Detach() { void ComponentBase::Detach() {
if (parent_ == nullptr) { if (parent_ == nullptr) {
return; return;
@@ -97,7 +91,6 @@ void ComponentBase::Detach() {
} }
/// @brief Remove all children. /// @brief Remove all children.
/// @ingroup component
void ComponentBase::DetachAllChildren() { void ComponentBase::DetachAllChildren() {
while (!children_.empty()) { while (!children_.empty()) {
children_[0]->Detach(); children_[0]->Detach();
@@ -107,7 +100,6 @@ void ComponentBase::DetachAllChildren() {
/// @brief Draw the component. /// @brief Draw the component.
/// Build a ftxui::Element to be drawn on the ftxui::Screen representing this /// Build a ftxui::Element to be drawn on the ftxui::Screen representing this
/// ftxui::ComponentBase. Please override OnRender() to modify the rendering. /// ftxui::ComponentBase. Please override OnRender() to modify the rendering.
/// @ingroup component
Element ComponentBase::Render() { Element ComponentBase::Render() {
// Some users might call `ComponentBase::Render()` from // Some users might call `ComponentBase::Render()` from
// `T::OnRender()`. To avoid infinite recursion, we use a flag. // `T::OnRender()`. To avoid infinite recursion, we use a flag.
@@ -143,7 +135,6 @@ Element ComponentBase::Render() {
/// @brief Draw the component. /// @brief Draw the component.
/// Build a ftxui::Element to be drawn on the ftxi::Screen representing this /// Build a ftxui::Element to be drawn on the ftxi::Screen representing this
/// ftxui::ComponentBase. This function is means to be overridden. /// ftxui::ComponentBase. This function is means to be overridden.
/// @ingroup component
Element ComponentBase::OnRender() { Element ComponentBase::OnRender() {
if (children_.size() == 1) { if (children_.size() == 1) {
return children_.front()->Render(); return children_.front()->Render();
@@ -157,7 +148,6 @@ Element ComponentBase::OnRender() {
/// @return True when the event has been handled. /// @return True when the event has been handled.
/// The default implementation called OnEvent on every child until one return /// The default implementation called OnEvent on every child until one return
/// true. If none returns true, return false. /// true. If none returns true, return false.
/// @ingroup component
bool ComponentBase::OnEvent(Event event) { // NOLINT bool ComponentBase::OnEvent(Event event) { // NOLINT
for (Component& child : children_) { // NOLINT for (Component& child : children_) { // NOLINT
if (child->OnEvent(event)) { if (child->OnEvent(event)) {
@@ -170,7 +160,6 @@ bool ComponentBase::OnEvent(Event event) { // NOLINT
/// @brief Called in response to an animation event. /// @brief Called in response to an animation event.
/// @param params the parameters of the animation /// @param params the parameters of the animation
/// The default implementation dispatch the event to every child. /// The default implementation dispatch the event to every child.
/// @ingroup component
void ComponentBase::OnAnimation(animation::Params& params) { void ComponentBase::OnAnimation(animation::Params& params) {
for (const Component& child : children_) { for (const Component& child : children_) {
child->OnAnimation(params); child->OnAnimation(params);
@@ -179,7 +168,6 @@ void ComponentBase::OnAnimation(animation::Params& params) {
/// @brief Return the currently Active child. /// @brief Return the currently Active child.
/// @return the currently Active child. /// @return the currently Active child.
/// @ingroup component
Component ComponentBase::ActiveChild() { Component ComponentBase::ActiveChild() {
for (auto& child : children_) { for (auto& child : children_) {
if (child->Focusable()) { if (child->Focusable()) {
@@ -192,7 +180,6 @@ Component ComponentBase::ActiveChild() {
/// @brief Return true when the component contains focusable elements. /// @brief Return true when the component contains focusable elements.
/// The non focusable Components will be skipped when navigating using the /// The non focusable Components will be skipped when navigating using the
/// keyboard. /// keyboard.
/// @ingroup component
bool ComponentBase::Focusable() const { bool ComponentBase::Focusable() const {
for (const Component& child : children_) { // NOLINT for (const Component& child : children_) { // NOLINT
if (child->Focusable()) { if (child->Focusable()) {
@@ -203,7 +190,6 @@ bool ComponentBase::Focusable() const {
} }
/// @brief Returns if the element if the currently active child of its parent. /// @brief Returns if the element if the currently active child of its parent.
/// @ingroup component
bool ComponentBase::Active() const { bool ComponentBase::Active() const {
return parent_ == nullptr || parent_->ActiveChild().get() == this; return parent_ == nullptr || parent_->ActiveChild().get() == this;
} }
@@ -212,7 +198,6 @@ bool ComponentBase::Active() const {
/// True when the ComponentBase is focused by the user. An element is Focused /// True when the ComponentBase is focused by the user. An element is Focused
/// when it is with all its ancestors the ActiveChild() of their parents, and it /// when it is with all its ancestors the ActiveChild() of their parents, and it
/// Focusable(). /// Focusable().
/// @ingroup component
bool ComponentBase::Focused() const { bool ComponentBase::Focused() const {
const auto* current = this; const auto* current = this;
while (current && current->Active()) { while (current && current->Active()) {
@@ -223,18 +208,15 @@ bool ComponentBase::Focused() const {
/// @brief Make the |child| to be the "active" one. /// @brief Make the |child| to be the "active" one.
/// @param child the child to become active. /// @param child the child to become active.
/// @ingroup component
void ComponentBase::SetActiveChild([[maybe_unused]] ComponentBase* child) {} void ComponentBase::SetActiveChild([[maybe_unused]] ComponentBase* child) {}
/// @brief Make the |child| to be the "active" one. /// @brief Make the |child| to be the "active" one.
/// @param child the child to become active. /// @param child the child to become active.
/// @ingroup component
void ComponentBase::SetActiveChild(Component child) { // NOLINT void ComponentBase::SetActiveChild(Component child) { // NOLINT
SetActiveChild(child.get()); SetActiveChild(child.get());
} }
/// @brief Configure all the ancestors to give focus to this component. /// @brief Configure all the ancestors to give focus to this component.
/// @ingroup component
void ComponentBase::TakeFocus() { void ComponentBase::TakeFocus() {
ComponentBase* child = this; ComponentBase* child = this;
while (ComponentBase* parent = child->parent_) { while (ComponentBase* parent = child->parent_) {
@@ -246,7 +228,6 @@ void ComponentBase::TakeFocus() {
/// @brief Take the CapturedMouse if available. There is only one component of /// @brief Take the CapturedMouse if available. There is only one component of
/// them. It represents a component taking priority over others. /// them. It represents a component taking priority over others.
/// @param event The event /// @param event The event
/// @ingroup component
CapturedMouse ComponentBase::CaptureMouse(const Event& event) { // NOLINT CapturedMouse ComponentBase::CaptureMouse(const Event& event) { // NOLINT
if (event.screen_) { if (event.screen_) {
return event.screen_->CaptureMouse(); return event.screen_->CaptureMouse();

View File

@@ -0,0 +1,59 @@
/// @module ftxui.component.component
/// @brief Module file for the Component classes of the Component module
module;
#include <ftxui/component/component.hpp>
export module ftxui.component.component;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::ButtonOption;
using ftxui::CheckboxOption;
using ftxui::Event;
using ftxui::InputOption;
using ftxui::MenuOption;
using ftxui::RadioboxOption;
using ftxui::MenuEntryOption;
using ftxui::Make;
using ftxui::ComponentDecorator;
using ftxui::ElementDecorator;
using ftxui::operator|;
using ftxui::operator|=;
namespace Container {
using ftxui::Container::Vertical;
using ftxui::Container::Horizontal;
using ftxui::Container::Tab;
using ftxui::Container::Stacked;
}
using ftxui::Button;
using ftxui::Checkbox;
using ftxui::Input;
using ftxui::Menu;
using ftxui::MenuEntry;
using ftxui::Radiobox;
using ftxui::Dropdown;
using ftxui::Toggle;
using ftxui::Slider;
using ftxui::ResizableSplit;
using ftxui::ResizableSplitLeft;
using ftxui::ResizableSplitRight;
using ftxui::ResizableSplitTop;
using ftxui::ResizableSplitBottom;
using ftxui::Renderer;
using ftxui::CatchEvent;
using ftxui::Maybe;
using ftxui::Modal;
using ftxui::Collapsible;
using ftxui::Hoverable;
using ftxui::Window;
}

View File

@@ -0,0 +1,26 @@
/// @module ftxui.component.component_base
/// @brief Module file for the ComponentBase class of the Component module
module;
#include <ftxui/component/component_base.hpp>
export module ftxui.component.component_base;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Delegate;
using ftxui::Focus;
using ftxui::Event;
namespace animation {
using ftxui::animation::Params;
}
using ftxui::ComponentBase;
using ftxui::Component;
using ftxui::Components;
}

View File

@@ -17,7 +17,6 @@ namespace ftxui {
/// @params _active The color when the component is active. /// @params _active The color when the component is active.
/// @params _duration The duration of the animation. /// @params _duration The duration of the animation.
/// @params _function The easing function of the animation. /// @params _function The easing function of the animation.
/// @ingroup component
void AnimatedColorOption::Set(Color _inactive, void AnimatedColorOption::Set(Color _inactive,
Color _active, Color _active,
animation::Duration _duration, animation::Duration _duration,
@@ -32,7 +31,6 @@ void AnimatedColorOption::Set(Color _inactive,
/// @brief Set how the underline should animate. /// @brief Set how the underline should animate.
/// @param d The duration of the animation. /// @param d The duration of the animation.
/// @param f The easing function of the animation. /// @param f The easing function of the animation.
/// @ingroup component
void UnderlineOption::SetAnimation(animation::Duration d, void UnderlineOption::SetAnimation(animation::Duration d,
animation::easing::Function f) { animation::easing::Function f) {
SetAnimationDuration(d); SetAnimationDuration(d);
@@ -41,7 +39,6 @@ void UnderlineOption::SetAnimation(animation::Duration d,
/// @brief Set how the underline should animate. /// @brief Set how the underline should animate.
/// @param d The duration of the animation. /// @param d The duration of the animation.
/// @ingroup component
void UnderlineOption::SetAnimationDuration(animation::Duration d) { void UnderlineOption::SetAnimationDuration(animation::Duration d) {
leader_duration = d; leader_duration = d;
follower_duration = d; follower_duration = d;
@@ -49,7 +46,6 @@ void UnderlineOption::SetAnimationDuration(animation::Duration d) {
/// @brief Set how the underline should animate. /// @brief Set how the underline should animate.
/// @param f The easing function of the animation. /// @param f The easing function of the animation.
/// @ingroup component
void UnderlineOption::SetAnimationFunction(animation::easing::Function f) { void UnderlineOption::SetAnimationFunction(animation::easing::Function f) {
leader_function = f; leader_function = f;
follower_function = std::move(f); follower_function = std::move(f);
@@ -60,7 +56,6 @@ void UnderlineOption::SetAnimationFunction(animation::easing::Function f) {
/// follower. /// follower.
/// @param f_leader The duration of the animation for the leader. /// @param f_leader The duration of the animation for the leader.
/// @param f_follower The duration of the animation for the follower. /// @param f_follower The duration of the animation for the follower.
/// @ingroup component
void UnderlineOption::SetAnimationFunction( void UnderlineOption::SetAnimationFunction(
animation::easing::Function f_leader, animation::easing::Function f_leader,
animation::easing::Function f_follower) { animation::easing::Function f_follower) {
@@ -68,9 +63,8 @@ void UnderlineOption::SetAnimationFunction(
follower_function = std::move(f_follower); follower_function = std::move(f_follower);
} }
/// @brief Standard options for an horizontal menu. /// @brief Standard options for a horizontal menu.
/// This can be useful to implement a tab bar. /// This can be useful to implement a tab bar.
/// @ingroup component
// static // static
MenuOption MenuOption::Horizontal() { MenuOption MenuOption::Horizontal() {
MenuOption option; MenuOption option;
@@ -95,7 +89,6 @@ MenuOption MenuOption::Horizontal() {
/// @brief Standard options for an animated horizontal menu. /// @brief Standard options for an animated horizontal menu.
/// This can be useful to implement a tab bar. /// This can be useful to implement a tab bar.
/// @ingroup component
// static // static
MenuOption MenuOption::HorizontalAnimated() { MenuOption MenuOption::HorizontalAnimated() {
auto option = Horizontal(); auto option = Horizontal();
@@ -105,7 +98,6 @@ MenuOption MenuOption::HorizontalAnimated() {
/// @brief Standard options for a vertical menu. /// @brief Standard options for a vertical menu.
/// This can be useful to implement a list of selectable items. /// This can be useful to implement a list of selectable items.
/// @ingroup component
// static // static
MenuOption MenuOption::Vertical() { MenuOption MenuOption::Vertical() {
MenuOption option; MenuOption option;
@@ -127,7 +119,6 @@ MenuOption MenuOption::Vertical() {
/// @brief Standard options for an animated vertical menu. /// @brief Standard options for an animated vertical menu.
/// This can be useful to implement a list of selectable items. /// This can be useful to implement a list of selectable items.
/// @ingroup component
// static // static
MenuOption MenuOption::VerticalAnimated() { MenuOption MenuOption::VerticalAnimated() {
auto option = MenuOption::Vertical(); auto option = MenuOption::Vertical();
@@ -148,9 +139,8 @@ MenuOption MenuOption::VerticalAnimated() {
return option; return option;
} }
/// @brief Standard options for a horitontal menu with some separator. /// @brief Standard options for a horizontal menu with some separator.
/// This can be useful to implement a tab bar. /// This can be useful to implement a tab bar.
/// @ingroup component
// static // static
MenuOption MenuOption::Toggle() { MenuOption MenuOption::Toggle() {
auto option = MenuOption::Horizontal(); auto option = MenuOption::Horizontal();
@@ -159,7 +149,6 @@ MenuOption MenuOption::Toggle() {
} }
/// @brief Create a ButtonOption, highlighted using [] characters. /// @brief Create a ButtonOption, highlighted using [] characters.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Ascii() { ButtonOption ButtonOption::Ascii() {
ButtonOption option; ButtonOption option;
@@ -172,7 +161,6 @@ ButtonOption ButtonOption::Ascii() {
} }
/// @brief Create a ButtonOption, inverted when focused. /// @brief Create a ButtonOption, inverted when focused.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Simple() { ButtonOption ButtonOption::Simple() {
ButtonOption option; ButtonOption option;
@@ -188,7 +176,6 @@ ButtonOption ButtonOption::Simple() {
/// @brief Create a ButtonOption. The button is shown using a border, inverted /// @brief Create a ButtonOption. The button is shown using a border, inverted
/// when focused. This is the current default. /// when focused. This is the current default.
/// @ingroup component
ButtonOption ButtonOption::Border() { ButtonOption ButtonOption::Border() {
ButtonOption option; ButtonOption option;
option.transform = [](const EntryState& s) { option.transform = [](const EntryState& s) {
@@ -205,7 +192,6 @@ ButtonOption ButtonOption::Border() {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated() { ButtonOption ButtonOption::Animated() {
return Animated(Color::Black, Color::GrayLight, // return Animated(Color::Black, Color::GrayLight, //
@@ -213,7 +199,6 @@ ButtonOption ButtonOption::Animated() {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated(Color color) { ButtonOption ButtonOption::Animated(Color color) {
return ButtonOption::Animated( return ButtonOption::Animated(
@@ -224,7 +209,6 @@ ButtonOption ButtonOption::Animated(Color color) {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated(Color background, Color foreground) { ButtonOption ButtonOption::Animated(Color background, Color foreground) {
// NOLINTBEGIN // NOLINTBEGIN
@@ -237,7 +221,6 @@ ButtonOption ButtonOption::Animated(Color background, Color foreground) {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated(Color background, ButtonOption ButtonOption::Animated(Color background,
Color foreground, Color foreground,
@@ -257,7 +240,6 @@ ButtonOption ButtonOption::Animated(Color background,
} }
/// @brief Option for standard Checkbox. /// @brief Option for standard Checkbox.
/// @ingroup component
// static // static
CheckboxOption CheckboxOption::Simple() { CheckboxOption CheckboxOption::Simple() {
auto option = CheckboxOption(); auto option = CheckboxOption();
@@ -282,7 +264,6 @@ CheckboxOption CheckboxOption::Simple() {
} }
/// @brief Option for standard Radiobox /// @brief Option for standard Radiobox
/// @ingroup component
// static // static
RadioboxOption RadioboxOption::Simple() { RadioboxOption RadioboxOption::Simple() {
auto option = RadioboxOption(); auto option = RadioboxOption();
@@ -307,7 +288,6 @@ RadioboxOption RadioboxOption::Simple() {
} }
/// @brief Standard options for the input component. /// @brief Standard options for the input component.
/// @ingroup component
// static // static
InputOption InputOption::Default() { InputOption InputOption::Default() {
InputOption option; InputOption option;
@@ -330,7 +310,6 @@ InputOption InputOption::Default() {
} }
/// @brief Standard options for a more beautiful input component. /// @brief Standard options for a more beautiful input component.
/// @ingroup component
// static // static
InputOption InputOption::Spacious() { InputOption InputOption::Spacious() {
InputOption option; InputOption option;

View File

@@ -0,0 +1,31 @@
/// @module ftxui.component.component_options
/// @brief Module file for options for the Component class of the Component module
module;
#include <ftxui/component/component_options.hpp>
export module ftxui.component.component_options;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::EntryState;
using ftxui::UnderlineOption;
using ftxui::AnimatedColorOption;
using ftxui::AnimatedColorsOption;
using ftxui::MenuEntryOption;
using ftxui::MenuOption;
using ftxui::ButtonOption;
using ftxui::CheckboxOption;
using ftxui::InputState;
using ftxui::InputOption;
using ftxui::RadioboxOption;
using ftxui::ResizableSplitOption;
using ftxui::SliderOption;
using ftxui::WindowRenderState;
using ftxui::WindowOptions;
using ftxui::DropdownOption;
}

View File

@@ -24,7 +24,6 @@ namespace ftxui {
/// @brief An event corresponding to a given typed character. /// @brief An event corresponding to a given typed character.
/// @param input The character typed by the user. /// @param input The character typed by the user.
/// @ingroup component
// static // static
Event Event::Character(std::string input) { Event Event::Character(std::string input) {
Event event; Event event;
@@ -35,7 +34,6 @@ Event Event::Character(std::string input) {
/// @brief An event corresponding to a given typed character. /// @brief An event corresponding to a given typed character.
/// @param c The character typed by the user. /// @param c The character typed by the user.
/// @ingroup component
// static // static
Event Event::Character(char c) { Event Event::Character(char c) {
return Event::Character(std::string{c}); return Event::Character(std::string{c});
@@ -43,7 +41,6 @@ Event Event::Character(char c) {
/// @brief An event corresponding to a given typed character. /// @brief An event corresponding to a given typed character.
/// @param c The character typed by the user. /// @param c The character typed by the user.
/// @ingroup component
// static // static
Event Event::Character(wchar_t c) { Event Event::Character(wchar_t c) {
return Event::Character(to_string(std::wstring{c})); return Event::Character(to_string(std::wstring{c}));
@@ -52,7 +49,6 @@ Event Event::Character(wchar_t c) {
/// @brief An event corresponding to a given typed character. /// @brief An event corresponding to a given typed character.
/// @param input The sequence of character send by the terminal. /// @param input The sequence of character send by the terminal.
/// @param mouse The mouse state. /// @param mouse The mouse state.
/// @ingroup component
// static // static
Event Event::Mouse(std::string input, struct Mouse mouse) { Event Event::Mouse(std::string input, struct Mouse mouse) {
Event event; Event event;
@@ -74,7 +70,6 @@ Event Event::CursorShape(std::string input, int shape) {
/// @brief An custom event whose meaning is defined by the user of the library. /// @brief An custom event whose meaning is defined by the user of the library.
/// @param input An arbitrary sequence of character defined by the developer. /// @param input An arbitrary sequence of character defined by the developer.
/// @ingroup component
// static // static
Event Event::Special(std::string input) { Event Event::Special(std::string input) {
Event event; Event event;

View File

@@ -0,0 +1,19 @@
/// @module ftxui.component.event
/// @brief Module file for the Event struct of the Component module
module;
#include <ftxui/component/event.hpp>
export module ftxui.component.event;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::ScreenInteractive;
using ftxui::ComponentBase;
using ftxui::Event;
}

View File

@@ -11,7 +11,6 @@ namespace ftxui {
/// @brief A Loop is a wrapper around a Component and a ScreenInteractive. /// @brief A Loop is a wrapper around a Component and a ScreenInteractive.
/// It is used to run a Component in a terminal. /// It is used to run a Component in a terminal.
/// @ingroup component
/// @see Component, ScreenInteractive. /// @see Component, ScreenInteractive.
/// @see ScreenInteractive::Loop(). /// @see ScreenInteractive::Loop().
/// @see ScreenInteractive::ExitLoop(). /// @see ScreenInteractive::ExitLoop().
@@ -28,7 +27,6 @@ Loop::~Loop() {
} }
/// @brief Whether the loop has quitted. /// @brief Whether the loop has quitted.
/// @ingroup component
bool Loop::HasQuitted() { bool Loop::HasQuitted() {
return screen_->HasQuitted(); return screen_->HasQuitted();
} }

View File

@@ -0,0 +1,20 @@
/// @module ftxui.component.loop
/// @brief Module file for the Loop class of the Component module
module;
#include <ftxui/component/loop.hpp>
export module ftxui.component.loop;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::ComponentBase;
using ftxui::Component;
using ftxui::ScreenInteractive;
using ftxui::Loop;
}

View File

@@ -15,7 +15,7 @@ namespace ftxui {
/// @brief Decorate a component |child|. It is shown only when |show| returns /// @brief Decorate a component |child|. It is shown only when |show| returns
/// true. /// true.
/// @param child the compoenent to decorate. /// @param child the component to decorate.
/// @param show a function returning whether |child| should shown. /// @param show a function returning whether |child| should shown.
/// @ingroup component /// @ingroup component
Component Maybe(Component child, std::function<bool()> show) { Component Maybe(Component child, std::function<bool()> show) {
@@ -61,7 +61,7 @@ ComponentDecorator Maybe(std::function<bool()> show) {
} }
/// @brief Decorate a component |child|. It is shown only when |show| is true. /// @brief Decorate a component |child|. It is shown only when |show| is true.
/// @param child the compoennt to decorate. /// @param child the component to decorate.
/// @param show a boolean. |child| is shown when |show| is true. /// @param show a boolean. |child| is shown when |show| is true.
/// @ingroup component /// @ingroup component
/// ///

View File

@@ -0,0 +1,16 @@
/// @module ftxui.component.mouse
/// @brief Module file for the Mouse struct of the Component module
module;
#include <ftxui/component/mouse.hpp>
export module ftxui.component.mouse;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Mouse;
}

View File

@@ -0,0 +1,20 @@
/// @module ftxui.component.receiver
/// @brief Module file for the Receiver class of the Component module
module;
#include <ftxui/component/receiver.hpp>
export module ftxui.component.receiver;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::SenderImpl;
using ftxui::ReceiverImpl;
using ftxui::Sender;
using ftxui::Receiver;
using ftxui::MakeReceiver;
}

View File

@@ -366,7 +366,6 @@ ScreenInteractive ScreenInteractive::FixedSize(int dimx, int dimy) {
}; };
} }
/// @ingroup component
/// Create a ScreenInteractive taking the full terminal size. This is using the /// Create a ScreenInteractive taking the full terminal size. This is using the
/// alternate screen buffer to avoid messing with the terminal content. /// alternate screen buffer to avoid messing with the terminal content.
/// @note This is the same as `ScreenInteractive::FullscreenAlternateScreen()` /// @note This is the same as `ScreenInteractive::FullscreenAlternateScreen()`
@@ -375,7 +374,6 @@ ScreenInteractive ScreenInteractive::Fullscreen() {
return FullscreenAlternateScreen(); return FullscreenAlternateScreen();
} }
/// @ingroup component
/// Create a ScreenInteractive taking the full terminal size. The primary screen /// Create a ScreenInteractive taking the full terminal size. The primary screen
/// buffer is being used. It means if the terminal is resized, the previous /// buffer is being used. It means if the terminal is resized, the previous
/// content might mess up with the terminal content. /// content might mess up with the terminal content.
@@ -389,7 +387,6 @@ ScreenInteractive ScreenInteractive::FullscreenPrimaryScreen() {
}; };
} }
/// @ingroup component
/// Create a ScreenInteractive taking the full terminal size. This is using the /// Create a ScreenInteractive taking the full terminal size. This is using the
/// alternate screen buffer to avoid messing with the terminal content. /// alternate screen buffer to avoid messing with the terminal content.
// static // static
@@ -422,7 +419,6 @@ ScreenInteractive ScreenInteractive::FitComponent() {
}; };
} }
/// @ingroup component
/// @brief Set whether mouse is tracked and events reported. /// @brief Set whether mouse is tracked and events reported.
/// called outside of the main loop. E.g `ScreenInteractive::Loop(...)`. /// called outside of the main loop. E.g `ScreenInteractive::Loop(...)`.
/// @param enable Whether to enable mouse event tracking. /// @param enable Whether to enable mouse event tracking.
@@ -444,7 +440,6 @@ void ScreenInteractive::TrackMouse(bool enable) {
/// @brief Add a task to the main loop. /// @brief Add a task to the main loop.
/// It will be executed later, after every other scheduled tasks. /// It will be executed later, after every other scheduled tasks.
/// @ingroup component
void ScreenInteractive::Post(Task task) { void ScreenInteractive::Post(Task task) {
// Task/Events sent toward inactive screen or screen waiting to become // Task/Events sent toward inactive screen or screen waiting to become
// inactive are dropped. // inactive are dropped.
@@ -457,7 +452,6 @@ void ScreenInteractive::Post(Task task) {
/// @brief Add an event to the main loop. /// @brief Add an event to the main loop.
/// It will be executed later, after every other scheduled events. /// It will be executed later, after every other scheduled events.
/// @ingroup component
void ScreenInteractive::PostEvent(Event event) { void ScreenInteractive::PostEvent(Event event) {
Post(event); Post(event);
} }
@@ -479,7 +473,6 @@ void ScreenInteractive::RequestAnimationFrame() {
/// @brief Try to get the unique lock about behing able to capture the mouse. /// @brief Try to get the unique lock about behing able to capture the mouse.
/// @return A unique lock if the mouse is not already captured, otherwise a /// @return A unique lock if the mouse is not already captured, otherwise a
/// null. /// null.
/// @ingroup component
CapturedMouse ScreenInteractive::CaptureMouse() { CapturedMouse ScreenInteractive::CaptureMouse() {
if (mouse_captured) { if (mouse_captured) {
return nullptr; return nullptr;
@@ -491,14 +484,12 @@ CapturedMouse ScreenInteractive::CaptureMouse() {
/// @brief Execute the main loop. /// @brief Execute the main loop.
/// @param component The component to draw. /// @param component The component to draw.
/// @ingroup component
void ScreenInteractive::Loop(Component component) { // NOLINT void ScreenInteractive::Loop(Component component) { // NOLINT
class Loop loop(this, std::move(component)); class Loop loop(this, std::move(component));
loop.Run(); loop.Run();
} }
/// @brief Return whether the main loop has been quit. /// @brief Return whether the main loop has been quit.
/// @ingroup component
bool ScreenInteractive::HasQuitted() { bool ScreenInteractive::HasQuitted() {
return task_receiver_->HasQuitted(); return task_receiver_->HasQuitted();
} }
@@ -1022,13 +1013,11 @@ void ScreenInteractive::ResetCursorPosition() {
} }
/// @brief Return a function to exit the main loop. /// @brief Return a function to exit the main loop.
/// @ingroup component
Closure ScreenInteractive::ExitLoopClosure() { Closure ScreenInteractive::ExitLoopClosure() {
return [this] { Exit(); }; return [this] { Exit(); };
} }
/// @brief Exit the main loop. /// @brief Exit the main loop.
/// @ingroup component
void ScreenInteractive::Exit() { void ScreenInteractive::Exit() {
Post([this] { ExitNow(); }); Post([this] { ExitNow(); });
} }

View File

@@ -0,0 +1,23 @@
/// @module ftxui.component.screen_interactive
/// @brief Module file for the ScreenInteractive class of the Component module
module;
#include <ftxui/component/screen_interactive.hpp>
export module ftxui.component.screen_interactive;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::ComponentBase;
using ftxui::Loop;
using ftxui::Event;
using ftxui::Component;
using ftxui::Screen;
using ftxui::ScreenInteractivePrivate;
using ftxui::ScreenInteractive;
}

View File

@@ -0,0 +1,18 @@
/// @module ftxui.component.task
/// @brief Module file for the Task class of the Component module
module;
#include <ftxui/component/task.hpp>
export module ftxui.component.task;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::AnimationTask;
using ftxui::Closure;
using ftxui::Task;
}

15
src/ftxui/dom.cppm Normal file
View File

@@ -0,0 +1,15 @@
/// @module ftxui.dom
/// @brief Module file for FTXUI main operations.
export module ftxui.dom;
export import ftxui.dom.canvas;
export import ftxui.dom.deprecated;
export import ftxui.dom.direction;
export import ftxui.dom.elements;
export import ftxui.dom.flexbox_config;
export import ftxui.dom.linear_gradient;
export import ftxui.dom.node;
export import ftxui.dom.requirement;
export import ftxui.dom.selection;
export import ftxui.dom.table;

16
src/ftxui/dom/canvas.cppm Normal file
View File

@@ -0,0 +1,16 @@
/// @module ftxui.dom.canvas
/// @brief Module file for the Canvas struct of the Dom module
module;
#include <ftxui/dom/canvas.hpp>
export module ftxui.dom.canvas;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Canvas;
}

View File

@@ -32,7 +32,7 @@ class ClearUnder : public NodeDecorator {
} // namespace } // namespace
/// @brief Before drawing |child|, clear the pixels below. This is useful in /// @brief Before drawing |child|, clear the pixels below. This is useful in
// combinaison with dbox. /// combination with dbox.
/// @see ftxui::dbox /// @see ftxui::dbox
/// @ingroup dom /// @ingroup dom
Element clear_under(Element element) { Element clear_under(Element element) {

View File

@@ -0,0 +1,18 @@
/// @module ftxui.dom.deprecated
/// @brief Module file for deprecated parts of the Dom module
module;
#include <ftxui/dom/deprecated.hpp>
export module ftxui.dom.deprecated;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::text;
using ftxui::vtext;
using ftxui::paragraph;
}

View File

@@ -0,0 +1,16 @@
/// @module ftxui.dom.direction
/// @brief Module file for the Direction enum of the Dom module
module;
#include <ftxui/dom/direction.hpp>
export module ftxui.dom.direction;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Direction;
}

135
src/ftxui/dom/elements.cppm Normal file
View File

@@ -0,0 +1,135 @@
/// @module ftxui.dom.elements
/// @brief Module file for the Element classes and functions of the Dom module
module;
#include <ftxui/dom/elements.hpp>
export module ftxui.dom.elements;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Node;
using ftxui::Element;
using ftxui::Elements;
using ftxui::Decorator;
using ftxui::GraphFunction;
using ftxui::BorderStyle;
using ftxui::operator|;
using ftxui::operator|=;
using ftxui::text;
using ftxui::vtext;
using ftxui::separator;
using ftxui::separatorLight;
using ftxui::separatorDashed;
using ftxui::separatorHeavy;
using ftxui::separatorDouble;
using ftxui::separatorEmpty;
using ftxui::separatorStyled;
using ftxui::separatorCharacter;
using ftxui::separatorHSelector;
using ftxui::separatorVSelector;
using ftxui::gauge;
using ftxui::gaugeLeft;
using ftxui::gaugeRight;
using ftxui::gaugeUp;
using ftxui::gaugeDown;
using ftxui::gaugeDirection;
using ftxui::border;
using ftxui::borderLight;
using ftxui::borderDashed;
using ftxui::borderHeavy;
using ftxui::borderDouble;
using ftxui::borderRounded;
using ftxui::borderEmpty;
using ftxui::borderStyled;
using ftxui::borderWith;
using ftxui::window;
using ftxui::spinner;
using ftxui::paragraph;
using ftxui::paragraphAlignLeft;
using ftxui::paragraphAlignRight;
using ftxui::paragraphAlignCenter;
using ftxui::paragraphAlignJustify;
using ftxui::graph;
using ftxui::emptyElement;
using ftxui::canvas;
using ftxui::bold;
using ftxui::dim;
using ftxui::italic;
using ftxui::inverted;
using ftxui::underlined;
using ftxui::underlinedDouble;
using ftxui::blink;
using ftxui::strikethrough;
using ftxui::color;
using ftxui::bgcolor;
using ftxui::focusPosition;
using ftxui::focusPositionRelative;
using ftxui::automerge;
using ftxui::hyperlink;
using ftxui::selectionStyleReset;
using ftxui::selectionColor;
using ftxui::selectionBackgroundColor;
using ftxui::selectionForegroundColor;
using ftxui::selectionStyle;
using ftxui::hbox;
using ftxui::vbox;
using ftxui::dbox;
using ftxui::flexbox;
using ftxui::gridbox;
using ftxui::hflow;
using ftxui::vflow;
using ftxui::flex;
using ftxui::flex_grow;
using ftxui::flex_shrink;
using ftxui::xflex;
using ftxui::xflex_grow;
using ftxui::xflex_shrink;
using ftxui::yflex;
using ftxui::yflex_grow;
using ftxui::yflex_shrink;
using ftxui::notflex;
using ftxui::filler;
using ftxui::WidthOrHeight;
using ftxui::Constraint;
using ftxui::size;
using ftxui::frame;
using ftxui::xframe;
using ftxui::yframe;
using ftxui::focus;
using ftxui::select;
using ftxui::focusCursorBlock;
using ftxui::focusCursorBlockBlinking;
using ftxui::focusCursorBar;
using ftxui::focusCursorBarBlinking;
using ftxui::focusCursorUnderline;
using ftxui::focusCursorUnderlineBlinking;
using ftxui::vscroll_indicator;
using ftxui::hscroll_indicator;
using ftxui::reflect;
using ftxui::clear_under;
using ftxui::hcenter;
using ftxui::vcenter;
using ftxui::center;
using ftxui::align_right;
using ftxui::nothing;
namespace Dimension {
using ftxui::Dimension::Fit;
}
}

View File

@@ -6,42 +6,36 @@
namespace ftxui { namespace ftxui {
/// @brief Set the flexbox direction. /// @brief Set the flexbox direction.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Direction d) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Direction d) {
this->direction = d; this->direction = d;
return *this; return *this;
} }
/// @brief Set the flexbox wrap. /// @brief Set the flexbox wrap.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Wrap w) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Wrap w) {
this->wrap = w; this->wrap = w;
return *this; return *this;
} }
/// @brief Set the flexbox justify content. /// @brief Set the flexbox justify content.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::JustifyContent j) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::JustifyContent j) {
this->justify_content = j; this->justify_content = j;
return *this; return *this;
} }
/// @brief Set the flexbox align items. /// @brief Set the flexbox align items.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignItems a) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignItems a) {
this->align_items = a; this->align_items = a;
return *this; return *this;
} }
/// @brief Set the flexbox align content. /// @brief Set the flexbox align content.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignContent a) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignContent a) {
this->align_content = a; this->align_content = a;
return *this; return *this;
} }
/// @brief Set the flexbox flex direction. /// @brief Set the flexbox flex direction.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::SetGap(int x, int y) { FlexboxConfig& FlexboxConfig::SetGap(int x, int y) {
this->gap_x = x; this->gap_x = x;
this->gap_y = y; this->gap_y = y;

View File

@@ -0,0 +1,16 @@
/// @module ftxui.dom.flexbox_config
/// @brief Module file for the FlexboxConfig struct of the Dom module
module;
#include <ftxui/dom/flexbox_config.hpp>
export module ftxui.dom.flexbox_config;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::FlexboxConfig;
}

View File

@@ -34,8 +34,8 @@ class Hyperlink : public NodeDecorator {
} // namespace } // namespace
/// @brief Make the rendered area clickable using a web browser. /// @brief Make the rendered area clickable using a web browser.
/// The link will be opened when the user click on it. /// The link will be opened when the user clicks on it.
/// This is supported only on a limited set of terminal emulator. /// This is supported only on a limited set of terminal emulators.
/// List: https://github.com/Alhadis/OSC8-Adoption/ /// List: https://github.com/Alhadis/OSC8-Adoption/
/// @param link The link /// @param link The link
/// @param child The input element. /// @param child The input element.
@@ -52,9 +52,9 @@ Element hyperlink(std::string link, Element child) {
return std::make_shared<Hyperlink>(std::move(child), std::move(link)); return std::make_shared<Hyperlink>(std::move(child), std::move(link));
} }
/// @brief Decorate using an hyperlink. /// @brief Decorate using a hyperlink.
/// The link will be opened when the user click on it. /// The link will be opened when the user clicks on it.
/// This is supported only on a limited set of terminal emulator. /// This is supported only on a limited set of terminal emulators.
/// List: https://github.com/Alhadis/OSC8-Adoption/ /// List: https://github.com/Alhadis/OSC8-Adoption/
/// @param link The link to redirect the users to. /// @param link The link to redirect the users to.
/// @return The Decorator applying the hyperlink. /// @return The Decorator applying the hyperlink.

View File

@@ -189,13 +189,11 @@ class LinearGradientColor : public NodeDecorator {
/// .Stop(Color::Green, 0.5) /// .Stop(Color::Green, 0.5)
/// .Stop(Color::Blue, 1.0);; /// .Stop(Color::Blue, 1.0);;
/// ``` /// ```
/// @ingroup dom
LinearGradient::LinearGradient() = default; LinearGradient::LinearGradient() = default;
/// @brief Build a gradient with two colors. /// @brief Build a gradient with two colors.
/// @param begin The color at the beginning of the gradient. /// @param begin The color at the beginning of the gradient.
/// @param end The color at the end of the gradient. /// @param end The color at the end of the gradient.
/// @ingroup dom
LinearGradient::LinearGradient(Color begin, Color end) LinearGradient::LinearGradient(Color begin, Color end)
: LinearGradient(0, begin, end) {} : LinearGradient(0, begin, end) {}
@@ -203,7 +201,6 @@ LinearGradient::LinearGradient(Color begin, Color end)
/// @param a The angle of the gradient. /// @param a The angle of the gradient.
/// @param begin The color at the beginning of the gradient. /// @param begin The color at the beginning of the gradient.
/// @param end The color at the end of the gradient. /// @param end The color at the end of the gradient.
/// @ingroup dom
LinearGradient::LinearGradient(float a, Color begin, Color end) : angle(a) { LinearGradient::LinearGradient(float a, Color begin, Color end) : angle(a) {
stops.push_back({begin, {}}); stops.push_back({begin, {}});
stops.push_back({end, {}}); stops.push_back({end, {}});
@@ -212,7 +209,6 @@ LinearGradient::LinearGradient(float a, Color begin, Color end) : angle(a) {
/// @brief Set the angle of the gradient. /// @brief Set the angle of the gradient.
/// @param a The angle of the gradient. /// @param a The angle of the gradient.
/// @return The gradient. /// @return The gradient.
/// @ingroup dom
LinearGradient& LinearGradient::Angle(float a) { LinearGradient& LinearGradient::Angle(float a) {
angle = a; angle = a;
return *this; return *this;
@@ -221,7 +217,6 @@ LinearGradient& LinearGradient::Angle(float a) {
/// @brief Add a color stop to the gradient. /// @brief Add a color stop to the gradient.
/// @param c The color of the stop. /// @param c The color of the stop.
/// @param p The position of the stop. /// @param p The position of the stop.
/// @return The gradient.
LinearGradient& LinearGradient::Stop(Color c, float p) { LinearGradient& LinearGradient::Stop(Color c, float p) {
stops.push_back({c, p}); stops.push_back({c, p});
return *this; return *this;
@@ -230,7 +225,6 @@ LinearGradient& LinearGradient::Stop(Color c, float p) {
/// @brief Add a color stop to the gradient. /// @brief Add a color stop to the gradient.
/// @param c The color of the stop. /// @param c The color of the stop.
/// @return The gradient. /// @return The gradient.
/// @ingroup dom
/// @note The position of the stop is interpolated from nearby stops. /// @note The position of the stop is interpolated from nearby stops.
LinearGradient& LinearGradient::Stop(Color c) { LinearGradient& LinearGradient::Stop(Color c) {
stops.push_back({c, {}}); stops.push_back({c, {}});

View File

@@ -0,0 +1,16 @@
/// @module ftxui.dom.linear_gradient
/// @brief Module file for the LinearGradient struct of the Dom module
module;
#include <ftxui/dom/linear_gradient.hpp>
export module ftxui.dom.linear_gradient;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::LinearGradient;
}

View File

@@ -16,8 +16,7 @@ Node::Node() = default;
Node::Node(Elements children) : children_(std::move(children)) {} Node::Node(Elements children) : children_(std::move(children)) {}
Node::~Node() = default; Node::~Node() = default;
/// @brief Compute how much space an elements needs. /// @brief Compute how much space an element needs.
/// @ingroup dom
void Node::ComputeRequirement() { void Node::ComputeRequirement() {
if (children_.empty()) { if (children_.empty()) {
return; return;
@@ -39,13 +38,11 @@ void Node::ComputeRequirement() {
} }
/// @brief Assign a position and a dimension to an element for drawing. /// @brief Assign a position and a dimension to an element for drawing.
/// @ingroup dom
void Node::SetBox(Box box) { void Node::SetBox(Box box) {
box_ = box; box_ = box;
} }
/// @brief Compute the selection of an element. /// @brief Compute the selection of an element.
/// @ingroup dom
void Node::Select(Selection& selection) { void Node::Select(Selection& selection) {
// If this Node box_ doesn't intersect with the selection, then no selection. // If this Node box_ doesn't intersect with the selection, then no selection.
if (Box::Intersection(selection.GetBox(), box_).IsEmpty()) { if (Box::Intersection(selection.GetBox(), box_).IsEmpty()) {
@@ -59,7 +56,6 @@ void Node::Select(Selection& selection) {
} }
/// @brief Display an element on a ftxui::Screen. /// @brief Display an element on a ftxui::Screen.
/// @ingroup dom
void Node::Render(Screen& screen) { void Node::Render(Screen& screen) {
for (auto& child : children_) { for (auto& child : children_) {
child->Render(screen); child->Render(screen);

23
src/ftxui/dom/node.cppm Normal file
View File

@@ -0,0 +1,23 @@
/// @module ftxui.dom.node
/// @brief Module file for the Node class of the Dom module
module;
#include <ftxui/dom/node.hpp>
export module ftxui.dom.node;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Node;
using ftxui::Screen;
using ftxui::Element;
using ftxui::Elements;
using ftxui::Render;
using ftxui::GetNodeSelectedContent;
}

View File

@@ -0,0 +1,16 @@
/// @module ftxui.dom.requirement
/// @brief Module file for the Requirement struct of the Dom module
module;
#include <ftxui/dom/requirement.hpp>
export module ftxui.dom.requirement;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Requirement;
}

View File

@@ -15,8 +15,8 @@
namespace ftxui { namespace ftxui {
/// @brief Display a vertical scrollbar to the right. /// @brief Display a vertical scrollbar on the right.
/// colors. /// Colors follow the content.
/// @ingroup dom /// @ingroup dom
Element vscroll_indicator(Element child) { Element vscroll_indicator(Element child) {
class Impl : public NodeDecorator { class Impl : public NodeDecorator {
@@ -70,8 +70,8 @@ Element vscroll_indicator(Element child) {
return std::make_shared<Impl>(std::move(child)); return std::make_shared<Impl>(std::move(child));
} }
/// @brief Display an horizontal scrollbar to the bottom. /// @brief Display a horizontal scrollbar at the bottom.
/// colors. /// Colors follow the content.
/// @ingroup dom /// @ingroup dom
Element hscroll_indicator(Element child) { Element hscroll_indicator(Element child) {
class Impl : public NodeDecorator { class Impl : public NodeDecorator {

View File

@@ -0,0 +1,16 @@
/// @module ftxui.dom.selection
/// @brief Module file for the Selection class of the Dom module
module;
#include <ftxui/dom/selection.hpp>
export module ftxui.dom.selection;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Selection;
}

View File

@@ -427,7 +427,7 @@ Element separator(Pixel pixel) {
return std::make_shared<SeparatorWithPixel>(std::move(pixel)); return std::make_shared<SeparatorWithPixel>(std::move(pixel));
} }
/// @brief Draw an horizontal bar, with the area in between left/right colored /// @brief Draw a horizontal bar, with the area in between left/right colored
/// differently. /// differently.
/// @param left the left limit of the active area. /// @param left the left limit of the active area.
/// @param right the right limit of the active area. /// @param right the right limit of the active area.

View File

@@ -273,8 +273,8 @@ const std::vector<std::vector<std::vector<std::string>>> elements = {
} // namespace } // namespace
/// @brief Useful to represent the effect of time and/or events. This display an /// @brief Useful to represent the effect of time and/or events. This displays
/// ASCII art "video". /// an ASCII art "video".
/// @param charset_index The type of "video". /// @param charset_index The type of "video".
/// @param image_index The "frame" of the video. You need to increase this for /// @param image_index The "frame" of the video. You need to increase this for
/// every "step". /// every "step".

View File

@@ -44,14 +44,12 @@ void Order(int& a, int& b) {
} // namespace } // namespace
/// @brief Create an empty table. /// @brief Create an empty table.
/// @ingroup dom
Table::Table() { Table::Table() {
Initialize({}); Initialize({});
} }
/// @brief Create a table from a vector of vector of string. /// @brief Create a table from a vector of vector of string.
/// @param input The input data. /// @param input The input data.
/// @ingroup dom
Table::Table(std::vector<std::vector<std::string>> input) { Table::Table(std::vector<std::vector<std::string>> input) {
std::vector<std::vector<Element>> output; std::vector<std::vector<Element>> output;
output.reserve(input.size()); output.reserve(input.size());
@@ -68,14 +66,12 @@ Table::Table(std::vector<std::vector<std::string>> input) {
/// @brief Create a table from a vector of vector of Element /// @brief Create a table from a vector of vector of Element
/// @param input The input elements. /// @param input The input elements.
/// @ingroup dom
Table::Table(std::vector<std::vector<Element>> input) { Table::Table(std::vector<std::vector<Element>> input) {
Initialize(std::move(input)); Initialize(std::move(input));
} }
// @brief Create a table from a list of list of string. // @brief Create a table from a list of list of string.
// @param init The input data. // @param init The input data.
// @ingroup dom
Table::Table(std::initializer_list<std::vector<std::string>> init) { Table::Table(std::initializer_list<std::vector<std::string>> init) {
std::vector<std::vector<Element>> input; std::vector<std::vector<Element>> input;
for (const auto& row : init) { for (const auto& row : init) {
@@ -139,7 +135,6 @@ void Table::Initialize(std::vector<std::vector<Element>> input) {
/// @brief Select a row of the table. /// @brief Select a row of the table.
/// @param index The index of the row to select. /// @param index The index of the row to select.
/// @note You can use negative index to select from the end. /// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectRow(int index) { TableSelection Table::SelectRow(int index) {
return SelectRectangle(0, -1, index, index); return SelectRectangle(0, -1, index, index);
} }
@@ -148,7 +143,6 @@ TableSelection Table::SelectRow(int index) {
/// @param row_min The first row to select. /// @param row_min The first row to select.
/// @param row_max The last row to select. /// @param row_max The last row to select.
/// @note You can use negative index to select from the end. /// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectRows(int row_min, int row_max) { TableSelection Table::SelectRows(int row_min, int row_max) {
return SelectRectangle(0, -1, row_min, row_max); return SelectRectangle(0, -1, row_min, row_max);
} }
@@ -156,7 +150,6 @@ TableSelection Table::SelectRows(int row_min, int row_max) {
/// @brief Select a column of the table. /// @brief Select a column of the table.
/// @param index The index of the column to select. /// @param index The index of the column to select.
/// @note You can use negative index to select from the end. /// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectColumn(int index) { TableSelection Table::SelectColumn(int index) {
return SelectRectangle(index, index, 0, -1); return SelectRectangle(index, index, 0, -1);
} }
@@ -165,7 +158,6 @@ TableSelection Table::SelectColumn(int index) {
/// @param column_min The first column to select. /// @param column_min The first column to select.
/// @param column_max The last column to select. /// @param column_max The last column to select.
/// @note You can use negative index to select from the end. /// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectColumns(int column_min, int column_max) { TableSelection Table::SelectColumns(int column_min, int column_max) {
return SelectRectangle(column_min, column_max, 0, -1); return SelectRectangle(column_min, column_max, 0, -1);
} }
@@ -174,7 +166,6 @@ TableSelection Table::SelectColumns(int column_min, int column_max) {
/// @param column The column of the cell to select. /// @param column The column of the cell to select.
/// @param row The row of the cell to select. /// @param row The row of the cell to select.
/// @note You can use negative index to select from the end. /// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectCell(int column, int row) { TableSelection Table::SelectCell(int column, int row) {
return SelectRectangle(column, column, row, row); return SelectRectangle(column, column, row, row);
} }
@@ -185,7 +176,6 @@ TableSelection Table::SelectCell(int column, int row) {
/// @param row_min The first row to select. /// @param row_min The first row to select.
/// @param row_max The last row to select. /// @param row_max The last row to select.
/// @note You can use negative index to select from the end. /// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectRectangle(int column_min, TableSelection Table::SelectRectangle(int column_min,
int column_max, int column_max,
int row_min, int row_min,
@@ -207,7 +197,6 @@ TableSelection Table::SelectRectangle(int column_min,
} }
/// @brief Select all the table. /// @brief Select all the table.
/// @ingroup dom
TableSelection Table::SelectAll() { TableSelection Table::SelectAll() {
TableSelection output; // NOLINT TableSelection output; // NOLINT
output.table_ = this; output.table_ = this;
@@ -220,7 +209,6 @@ TableSelection Table::SelectAll() {
/// @brief Render the table. /// @brief Render the table.
/// @return The rendered table. This is an element you can draw. /// @return The rendered table. This is an element you can draw.
/// @ingroup dom
Element Table::Render() { Element Table::Render() {
for (int y = 0; y < dim_y_; ++y) { for (int y = 0; y < dim_y_; ++y) {
for (int x = 0; x < dim_x_; ++x) { for (int x = 0; x < dim_x_; ++x) {
@@ -250,7 +238,6 @@ Element Table::Render() {
/// @brief Apply the `decorator` to the selection. /// @brief Apply the `decorator` to the selection.
/// This decorate both the cells, the lines and the corners. /// This decorate both the cells, the lines and the corners.
/// @param decorator The decorator to apply. /// @param decorator The decorator to apply.
/// @ingroup dom
// NOLINTNEXTLINE // NOLINTNEXTLINE
void TableSelection::Decorate(Decorator decorator) { void TableSelection::Decorate(Decorator decorator) {
for (int y = y_min_; y <= y_max_; ++y) { for (int y = y_min_; y <= y_max_; ++y) {
@@ -264,7 +251,6 @@ void TableSelection::Decorate(Decorator decorator) {
/// @brief Apply the `decorator` to the selection. /// @brief Apply the `decorator` to the selection.
/// @param decorator The decorator to apply. /// @param decorator The decorator to apply.
/// This decorate only the cells. /// This decorate only the cells.
/// @ingroup dom
// NOLINTNEXTLINE // NOLINTNEXTLINE
void TableSelection::DecorateCells(Decorator decorator) { void TableSelection::DecorateCells(Decorator decorator) {
for (int y = y_min_; y <= y_max_; ++y) { for (int y = y_min_; y <= y_max_; ++y) {
@@ -282,7 +268,6 @@ void TableSelection::DecorateCells(Decorator decorator) {
/// @param decorator The decorator to apply. /// @param decorator The decorator to apply.
/// @param modulo The modulo of the lines to decorate. /// @param modulo The modulo of the lines to decorate.
/// @param shift The shift of the lines to decorate. /// @param shift The shift of the lines to decorate.
/// @ingroup dom
// NOLINTNEXTLINE // NOLINTNEXTLINE
void TableSelection::DecorateAlternateColumn(Decorator decorator, void TableSelection::DecorateAlternateColumn(Decorator decorator,
int modulo, int modulo,
@@ -302,7 +287,6 @@ void TableSelection::DecorateAlternateColumn(Decorator decorator,
/// @param decorator The decorator to apply. /// @param decorator The decorator to apply.
/// @param modulo The modulo of the lines to decorate. /// @param modulo The modulo of the lines to decorate.
/// @param shift The shift of the lines to decorate. /// @param shift The shift of the lines to decorate.
/// @ingroup dom
// NOLINTNEXTLINE // NOLINTNEXTLINE
void TableSelection::DecorateAlternateRow(Decorator decorator, void TableSelection::DecorateAlternateRow(Decorator decorator,
int modulo, int modulo,
@@ -322,7 +306,6 @@ void TableSelection::DecorateAlternateRow(Decorator decorator,
/// @param decorator The decorator to apply. /// @param decorator The decorator to apply.
/// @param modulo The modulo of the corners to decorate. /// @param modulo The modulo of the corners to decorate.
/// @param shift The shift of the corners to decorate. /// @param shift The shift of the corners to decorate.
/// @ingroup dom
// NOLINTNEXTLINE // NOLINTNEXTLINE
void TableSelection::DecorateCellsAlternateColumn(Decorator decorator, void TableSelection::DecorateCellsAlternateColumn(Decorator decorator,
int modulo, int modulo,
@@ -342,7 +325,6 @@ void TableSelection::DecorateCellsAlternateColumn(Decorator decorator,
/// @param decorator The decorator to apply. /// @param decorator The decorator to apply.
/// @param modulo The modulo of the corners to decorate. /// @param modulo The modulo of the corners to decorate.
/// @param shift The shift of the corners to decorate. /// @param shift The shift of the corners to decorate.
/// @ingroup dom
// NOLINTNEXTLINE // NOLINTNEXTLINE
void TableSelection::DecorateCellsAlternateRow(Decorator decorator, void TableSelection::DecorateCellsAlternateRow(Decorator decorator,
int modulo, int modulo,
@@ -359,7 +341,6 @@ void TableSelection::DecorateCellsAlternateRow(Decorator decorator,
/// @brief Apply a `border` around the selection. /// @brief Apply a `border` around the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::Border(BorderStyle border) { void TableSelection::Border(BorderStyle border) {
BorderLeft(border); BorderLeft(border);
BorderRight(border); BorderRight(border);
@@ -378,7 +359,6 @@ void TableSelection::Border(BorderStyle border) {
/// @brief Draw some separator lines in the selection. /// @brief Draw some separator lines in the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::Separator(BorderStyle border) { void TableSelection::Separator(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) { for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) { for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
@@ -394,7 +374,6 @@ void TableSelection::Separator(BorderStyle border) {
/// @brief Draw some vertical separator lines in the selection. /// @brief Draw some vertical separator lines in the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::SeparatorVertical(BorderStyle border) { void TableSelection::SeparatorVertical(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) { for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) { for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
@@ -408,7 +387,6 @@ void TableSelection::SeparatorVertical(BorderStyle border) {
/// @brief Draw some horizontal separator lines in the selection. /// @brief Draw some horizontal separator lines in the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::SeparatorHorizontal(BorderStyle border) { void TableSelection::SeparatorHorizontal(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) { for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) { for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
@@ -422,7 +400,6 @@ void TableSelection::SeparatorHorizontal(BorderStyle border) {
/// @brief Draw some separator lines to the left side of the selection. /// @brief Draw some separator lines to the left side of the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderLeft(BorderStyle border) { void TableSelection::BorderLeft(BorderStyle border) {
for (int y = y_min_; y <= y_max_; y++) { for (int y = y_min_; y <= y_max_; y++) {
table_->elements_[y][x_min_] = table_->elements_[y][x_min_] =
@@ -432,7 +409,6 @@ void TableSelection::BorderLeft(BorderStyle border) {
/// @brief Draw some separator lines to the right side of the selection. /// @brief Draw some separator lines to the right side of the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderRight(BorderStyle border) { void TableSelection::BorderRight(BorderStyle border) {
for (int y = y_min_; y <= y_max_; y++) { for (int y = y_min_; y <= y_max_; y++) {
table_->elements_[y][x_max_] = table_->elements_[y][x_max_] =
@@ -442,7 +418,6 @@ void TableSelection::BorderRight(BorderStyle border) {
/// @brief Draw some separator lines to the top side of the selection. /// @brief Draw some separator lines to the top side of the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderTop(BorderStyle border) { void TableSelection::BorderTop(BorderStyle border) {
for (int x = x_min_; x <= x_max_; x++) { for (int x = x_min_; x <= x_max_; x++) {
table_->elements_[y_min_][x] = table_->elements_[y_min_][x] =
@@ -452,7 +427,6 @@ void TableSelection::BorderTop(BorderStyle border) {
/// @brief Draw some separator lines to the bottom side of the selection. /// @brief Draw some separator lines to the bottom side of the selection.
/// @param border The border style to apply. /// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderBottom(BorderStyle border) { void TableSelection::BorderBottom(BorderStyle border) {
for (int x = x_min_; x <= x_max_; x++) { for (int x = x_min_; x <= x_max_; x++) {
table_->elements_[y_max_][x] = table_->elements_[y_max_][x] =

17
src/ftxui/dom/table.cppm Normal file
View File

@@ -0,0 +1,17 @@
/// @module ftxui.dom.table
/// @brief Module file for the Table class of the Dom module
module;
#include <ftxui/dom/table.hpp>
export module ftxui.dom.table;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Table;
using ftxui::TableSelection;
}

View File

@@ -28,7 +28,7 @@ class Underlined : public NodeDecorator {
}; };
} // namespace } // namespace
/// @brief Make the underlined element to be underlined. /// @brief Underline the given element.
/// @ingroup dom /// @ingroup dom
Element underlined(Element child) { Element underlined(Element child) {
return std::make_shared<Underlined>(std::move(child)); return std::make_shared<Underlined>(std::move(child));

9
src/ftxui/ftxui.cppm Normal file
View File

@@ -0,0 +1,9 @@
/// @module ftxui
/// @brief Module file re-exporting all FTXUI submodules.
export module ftxui;
export import ftxui.component;
export import ftxui.dom;
export import ftxui.screen;
export import ftxui.util;

14
src/ftxui/screen.cppm Normal file
View File

@@ -0,0 +1,14 @@
/// @module ftxui.screen
/// @brief Module file for FTXUI screen operations.
export module ftxui.screen;
export import ftxui.screen.box;
export import ftxui.screen.color;
export import ftxui.screen.color_info;
export import ftxui.screen.deprecated;
export import ftxui.screen.image;
export import ftxui.screen.pixel;
export import ftxui.screen.screen;
export import ftxui.screen.string;
export import ftxui.screen.terminal;

View File

@@ -7,7 +7,6 @@
namespace ftxui { namespace ftxui {
/// @return the biggest Box contained in both |a| and |b|. /// @return the biggest Box contained in both |a| and |b|.
/// @ingroup screen
// static // static
Box Box::Intersection(Box a, Box b) { Box Box::Intersection(Box a, Box b) {
return Box{ return Box{
@@ -19,7 +18,6 @@ Box Box::Intersection(Box a, Box b) {
} }
/// @return the smallest Box containing both |a| and |b|. /// @return the smallest Box containing both |a| and |b|.
/// @ingroup screen
// static // static
Box Box::Union(Box a, Box b) { Box Box::Union(Box a, Box b) {
return Box{ return Box{
@@ -33,7 +31,6 @@ Box Box::Union(Box a, Box b) {
/// Shift the box by (x,y). /// Shift the box by (x,y).
/// @param x horizontal shift. /// @param x horizontal shift.
/// @param y vertical shift. /// @param y vertical shift.
/// @ingroup screen
void Box::Shift(int x, int y) { void Box::Shift(int x, int y) {
x_min += x; x_min += x;
x_max += x; x_max += x;
@@ -42,7 +39,6 @@ void Box::Shift(int x, int y) {
} }
/// @return whether (x,y) is contained inside the box. /// @return whether (x,y) is contained inside the box.
/// @ingroup screen
bool Box::Contain(int x, int y) const { bool Box::Contain(int x, int y) const {
return x_min <= x && // return x_min <= x && //
x_max >= x && // x_max >= x && //
@@ -51,20 +47,17 @@ bool Box::Contain(int x, int y) const {
} }
/// @return whether the box is empty. /// @return whether the box is empty.
/// @ingroup screen
bool Box::IsEmpty() const { bool Box::IsEmpty() const {
return x_min > x_max || y_min > y_max; return x_min > x_max || y_min > y_max;
} }
/// @return whether |other| is the same as |this| /// @return whether |other| is the same as |this|
/// @ingroup screen
bool Box::operator==(const Box& other) const { bool Box::operator==(const Box& other) const {
return (x_min == other.x_min) && (x_max == other.x_max) && return (x_min == other.x_min) && (x_max == other.x_max) &&
(y_min == other.y_min) && (y_max == other.y_max); (y_min == other.y_min) && (y_max == other.y_max);
} }
/// @return whether |other| and |this| are different. /// @return whether |other| and |this| are different.
/// @ingroup screen
bool Box::operator!=(const Box& other) const { bool Box::operator!=(const Box& other) const {
return !operator==(other); return !operator==(other);
} }

16
src/ftxui/screen/box.cppm Normal file
View File

@@ -0,0 +1,16 @@
/// @module ftxui.screen.box
/// @brief Module file for the Box struct of the Screen module
module;
#include <ftxui/screen/box.hpp>
export module ftxui.screen.box;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Box;
}

View File

@@ -74,20 +74,16 @@ std::string Color::Print(bool is_background_color) const {
} }
/// @brief Build a transparent color. /// @brief Build a transparent color.
/// @ingroup screen
Color::Color() = default; Color::Color() = default;
/// @brief Build a transparent color. /// @brief Build a transparent color.
/// @ingroup screen
Color::Color(Palette1 /*value*/) : Color() {} Color::Color(Palette1 /*value*/) : Color() {}
/// @brief Build a color using the Palette16 colors. /// @brief Build a color using the Palette16 colors.
/// @ingroup screen
Color::Color(Palette16 index) Color::Color(Palette16 index)
: type_(ColorType::Palette16), red_(index), alpha_(255) {} : type_(ColorType::Palette16), red_(index), alpha_(255) {}
/// @brief Build a color using Palette256 colors. /// @brief Build a color using Palette256 colors.
/// @ingroup screen
Color::Color(Palette256 index) Color::Color(Palette256 index)
: type_(ColorType::Palette256), red_(index), alpha_(255) { : type_(ColorType::Palette256), red_(index), alpha_(255) {
if (Terminal::ColorSupport() >= Terminal::Color::Palette256) { if (Terminal::ColorSupport() >= Terminal::Color::Palette256) {
@@ -104,7 +100,6 @@ Color::Color(Palette256 index)
/// @param green The quantity of green [0,255] /// @param green The quantity of green [0,255]
/// @param blue The quantity of blue [0,255] /// @param blue The quantity of blue [0,255]
/// @param alpha The quantity of alpha [0,255] /// @param alpha The quantity of alpha [0,255]
/// @ingroup screen
Color::Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) Color::Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
: type_(ColorType::TrueColor), : type_(ColorType::TrueColor),
red_(red), red_(red),
@@ -148,7 +143,6 @@ Color::Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
/// @param red The quantity of red [0,255] /// @param red The quantity of red [0,255]
/// @param green The quantity of green [0,255] /// @param green The quantity of green [0,255]
/// @param blue The quantity of blue [0,255] /// @param blue The quantity of blue [0,255]
/// @ingroup screen
// static // static
Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) { Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) {
return RGBA(red, green, blue, 255); return RGBA(red, green, blue, 255);
@@ -160,7 +154,6 @@ Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) {
/// @param green The quantity of green [0,255] /// @param green The quantity of green [0,255]
/// @param blue The quantity of blue [0,255] /// @param blue The quantity of blue [0,255]
/// @param alpha The quantity of alpha [0,255] /// @param alpha The quantity of alpha [0,255]
/// @ingroup screen
/// @see Color::RGB /// @see Color::RGB
// static // static
Color Color::RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) { Color Color::RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) {
@@ -174,7 +167,6 @@ Color Color::RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) {
/// @param s The "colorfulness" [0,255]. /// @param s The "colorfulness" [0,255].
/// @param v The "Lightness" [0,255] /// @param v The "Lightness" [0,255]
/// @param alpha The quantity of alpha [0,255] /// @param alpha The quantity of alpha [0,255]
/// @ingroup screen
// static // static
Color Color::HSVA(uint8_t h, uint8_t s, uint8_t v, uint8_t alpha) { Color Color::HSVA(uint8_t h, uint8_t s, uint8_t v, uint8_t alpha) {
uint8_t region = h / 43; // NOLINT uint8_t region = h / 43; // NOLINT
@@ -202,7 +194,6 @@ Color Color::HSVA(uint8_t h, uint8_t s, uint8_t v, uint8_t alpha) {
/// @param h The hue of the color [0,255] /// @param h The hue of the color [0,255]
/// @param s The "colorfulness" [0,255]. /// @param s The "colorfulness" [0,255].
/// @param v The "Lightness" [0,255] /// @param v The "Lightness" [0,255]
/// @ingroup screen
// static // static
Color Color::HSV(uint8_t h, uint8_t s, uint8_t v) { Color Color::HSV(uint8_t h, uint8_t s, uint8_t v) {
return HSVA(h, s, v, 255); return HSVA(h, s, v, 255);

View File

@@ -0,0 +1,20 @@
/// @module ftxui.screen.color
/// @brief Module file for the Color class of the Screen module
module;
#include <ftxui/screen/color.hpp>
export module ftxui.screen.color;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Color;
inline namespace literals {
using ftxui::literals::operator""_rgb;
}
}

View File

@@ -0,0 +1,18 @@
/// @module ftxui.screen.color_info
/// @brief Module file for the ColorInfo struct of the Screen module
module;
#include <ftxui/screen/color_info.hpp>
export module ftxui.screen.color_info;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::ColorInfo;
using ftxui::GetColorInfo;
}

View File

@@ -0,0 +1,17 @@
/// @module ftxui.screen.deprecated
/// @brief Module file for the deprecated parts of the Screen module
module;
#include <ftxui/screen/deprecated.hpp>
export module ftxui.screen.deprecated;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::wchar_width;
using ftxui::wstring_width;
}

View File

@@ -0,0 +1,16 @@
/// @module ftxui.screen.image
/// @brief Module file for the Image class of the Screen module
module;
#include <ftxui/screen/image.hpp>
export module ftxui.screen.image;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Image;
}

View File

@@ -0,0 +1,16 @@
/// @module ftxui.screen.pixel
/// @brief Module file for the Pixel struct of the Screen module
module;
#include <ftxui/screen/pixel.hpp>
export module ftxui.screen.pixel;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Pixel;
}

View File

@@ -0,0 +1,22 @@
/// @module ftxui.screen.screen
/// @brief Module file for the Screen class of the Screen module
module;
#include <ftxui/screen/screen.hpp>
export module ftxui.screen.screen;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
namespace Dimension {
using ftxui::Dimension::Fixed;
using ftxui::Dimension::Full;
}
using ftxui::Image;
using ftxui::Screen;
}

View File

@@ -1561,7 +1561,7 @@ std::vector<WordBreakProperty> Utf8ToWordBreakProperty(
return out; return out;
} }
/// Convert a UTF8 std::string into a std::wstring. /// Convert a std::wstring into a UTF8 std::string.
std::string to_string(const std::wstring& s) { std::string to_string(const std::wstring& s) {
std::string out; std::string out;
@@ -1633,7 +1633,7 @@ std::string to_string(const std::wstring& s) {
return out; return out;
} }
/// Convert a std::wstring into a UTF8 std::string. /// Convert a UTF8 std::string into a std::wstring.
std::wstring to_wstring(const std::string& s) { std::wstring to_wstring(const std::string& s) {
std::wstring out; std::wstring out;

View File

@@ -0,0 +1,20 @@
/// @module ftxui.screen.string
/// @brief Module file for string functions of the Screen module
module;
#include <ftxui/screen/string.hpp>
export module ftxui.screen.string;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::to_string;
using ftxui::to_wstring;
using ftxui::string_width;
using ftxui::Utf8ToGlyphs;
using ftxui::CellToGlyphIndex;
}

View File

@@ -48,31 +48,44 @@ Dimensions& FallbackSize() {
return g_fallback_size; return g_fallback_size;
} }
const char* Safe(const char* c) {
return (c != nullptr) ? c : "";
}
bool Contains(const std::string& s, const char* key) { bool Contains(const std::string& s, const char* key) {
return s.find(key) != std::string::npos; return s.find(key) != std::string::npos;
} }
// https://github.com/gabime/spdlog/blob/885b5473e291833b148eeac3b7ce227e582cd88b/include/spdlog/details/os-inl.h#L566
std::string getenv_safe(const char *field) {
#if defined(_MSC_VER)
#if defined(__cplusplus_winrt)
return std::string{}; // not supported under uwp
#else
size_t len = 0;
char buf[1024];
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
return ok ? buf : std::string{};
#endif
#else // revert to getenv
char *buf = ::getenv(field); // NOLINT(*-mt-unsafe)
return buf ? buf : std::string{};
#endif
}
Terminal::Color ComputeColorSupport() { Terminal::Color ComputeColorSupport() {
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
return Terminal::Color::TrueColor; return Terminal::Color::TrueColor;
#endif #endif
std::string COLORTERM = Safe(std::getenv("COLORTERM")); // NOLINT std::string COLORTERM = getenv_safe("COLORTERM");
if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor")) { if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor")) {
return Terminal::Color::TrueColor; return Terminal::Color::TrueColor;
} }
std::string TERM = Safe(std::getenv("TERM")); // NOLINT std::string TERM = getenv_safe("TERM");
if (Contains(COLORTERM, "256") || Contains(TERM, "256")) { if (Contains(COLORTERM, "256") || Contains(TERM, "256")) {
return Terminal::Color::Palette256; return Terminal::Color::Palette256;
} }
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK) #if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
// Microsoft terminals do not properly declare themselve supporting true // Microsoft terminals do not properly declare themselves supporting true
// colors: https://github.com/microsoft/terminal/issues/1040 // colors: https://github.com/microsoft/terminal/issues/1040
// As a fallback, assume microsoft terminal are the ones not setting those // As a fallback, assume microsoft terminal are the ones not setting those
// variables, and enable true colors. // variables, and enable true colors.

View File

@@ -0,0 +1,24 @@
/// @module ftxui.screen.terminal
/// @brief Module file for the Terminal namespace of the Screen module
module;
#include <ftxui/screen/terminal.hpp>
export module ftxui.screen.terminal;
/**
* @namespace ftxui
* @brief The FTXUI ftxui:: namespace
*/
export namespace ftxui {
using ftxui::Dimensions;
namespace Terminal {
using ftxui::Terminal::Size;
using ftxui::Terminal::SetFallbackSize;
using ftxui::Terminal::Color;
using ftxui::Terminal::ColorSupport;
using ftxui::Terminal::SetColorSupport;
}
}

7
src/ftxui/util.cppm Normal file
View File

@@ -0,0 +1,7 @@
/// @module ftxui.util
/// @brief Module file for FTXUI utility operations.
export module ftxui.util;
export import ftxui.util.autoreset;
export import ftxui.util.ref;

Some files were not shown because too many files have changed in this diff Show More