From b65bbce9bbe654b4055fcba77e55a9d3342ddb60 Mon Sep 17 00:00:00 2001 From: Miko <110693261+mikomikotaishi@users.noreply.github.com> Date: Wed, 4 Jun 2025 09:02:20 -0400 Subject: [PATCH] Add modules support (#1015) Add experimental C++20 module suppport. Co-authored-by: ArthurSonzogni --- .github/workflows/build.yaml | 44 +++++++ .gitignore | 2 + CHANGELOG.md | 16 +++ CMakeLists.txt | 35 +++-- README.md | 7 +- cmake/ftxui_message.cmake | 11 +- cmake/ftxui_modules.cmake | 82 ++++++++++++ doc/Doxyfile.in | 38 +----- doc/cpp20-modules.md | 85 ++++++++++++ doc/header.html | 1 - doc/module.md | 2 +- examples/component/scrollbar.cpp | 1 + examples/component/window.cpp | 1 + src/ftxui/component.cppm | 18 +++ src/ftxui/component/animation.cppm | 66 ++++++++++ src/ftxui/component/captured_mouse.cppm | 18 +++ src/ftxui/component/component.cppm | 61 +++++++++ src/ftxui/component/component_base.cppm | 28 ++++ src/ftxui/component/component_options.cppm | 33 +++++ src/ftxui/component/event.cppm | 21 +++ src/ftxui/component/loop.cppm | 22 ++++ src/ftxui/component/mouse.cppm | 18 +++ src/ftxui/component/receiver.cppm | 22 ++++ src/ftxui/component/screen_interactive.cppm | 25 ++++ src/ftxui/component/task.cppm | 20 +++ src/ftxui/dom.cppm | 17 +++ src/ftxui/dom/canvas.cppm | 18 +++ src/ftxui/dom/deprecated.cppm | 20 +++ src/ftxui/dom/direction.cppm | 18 +++ src/ftxui/dom/elements.cppm | 137 ++++++++++++++++++++ src/ftxui/dom/flexbox_config.cppm | 18 +++ src/ftxui/dom/linear_gradient.cppm | 18 +++ src/ftxui/dom/node.cppm | 25 ++++ src/ftxui/dom/requirement.cppm | 18 +++ src/ftxui/dom/selection.cppm | 18 +++ src/ftxui/dom/table.cppm | 19 +++ src/ftxui/ftxui.cppm | 11 ++ src/ftxui/screen.cppm | 16 +++ src/ftxui/screen/box.cppm | 18 +++ src/ftxui/screen/color.cppm | 22 ++++ src/ftxui/screen/color_info.cppm | 20 +++ src/ftxui/screen/deprecated.cppm | 19 +++ src/ftxui/screen/image.cppm | 18 +++ src/ftxui/screen/pixel.cppm | 18 +++ src/ftxui/screen/screen.cppm | 24 ++++ src/ftxui/screen/string.cppm | 22 ++++ src/ftxui/screen/terminal.cppm | 26 ++++ src/ftxui/util.cppm | 9 ++ src/ftxui/util/autoreset.cppm | 18 +++ src/ftxui/util/ref.cppm | 22 ++++ tools/generate_examples_modules.sh | 29 +++++ 51 files changed, 1239 insertions(+), 56 deletions(-) create mode 100644 cmake/ftxui_modules.cmake create mode 100644 doc/cpp20-modules.md create mode 100644 src/ftxui/component.cppm create mode 100644 src/ftxui/component/animation.cppm create mode 100644 src/ftxui/component/captured_mouse.cppm create mode 100644 src/ftxui/component/component.cppm create mode 100644 src/ftxui/component/component_base.cppm create mode 100644 src/ftxui/component/component_options.cppm create mode 100644 src/ftxui/component/event.cppm create mode 100644 src/ftxui/component/loop.cppm create mode 100644 src/ftxui/component/mouse.cppm create mode 100644 src/ftxui/component/receiver.cppm create mode 100644 src/ftxui/component/screen_interactive.cppm create mode 100644 src/ftxui/component/task.cppm create mode 100644 src/ftxui/dom.cppm create mode 100644 src/ftxui/dom/canvas.cppm create mode 100644 src/ftxui/dom/deprecated.cppm create mode 100644 src/ftxui/dom/direction.cppm create mode 100644 src/ftxui/dom/elements.cppm create mode 100644 src/ftxui/dom/flexbox_config.cppm create mode 100644 src/ftxui/dom/linear_gradient.cppm create mode 100644 src/ftxui/dom/node.cppm create mode 100644 src/ftxui/dom/requirement.cppm create mode 100644 src/ftxui/dom/selection.cppm create mode 100644 src/ftxui/dom/table.cppm create mode 100644 src/ftxui/ftxui.cppm create mode 100644 src/ftxui/screen.cppm create mode 100644 src/ftxui/screen/box.cppm create mode 100644 src/ftxui/screen/color.cppm create mode 100644 src/ftxui/screen/color_info.cppm create mode 100644 src/ftxui/screen/deprecated.cppm create mode 100644 src/ftxui/screen/image.cppm create mode 100644 src/ftxui/screen/pixel.cppm create mode 100644 src/ftxui/screen/screen.cppm create mode 100644 src/ftxui/screen/string.cppm create mode 100644 src/ftxui/screen/terminal.cppm create mode 100644 src/ftxui/util.cppm create mode 100644 src/ftxui/util/autoreset.cppm create mode 100644 src/ftxui/util/ref.cppm create mode 100755 tools/generate_examples_modules.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index accc4091..e13402da 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -165,3 +165,47 @@ jobs: flags: ${{ runner.os }} name: ${{ runner.os }}-coverage 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 . diff --git a/.gitignore b/.gitignore index a3820005..40a2b7c4 100644 --- a/.gitignore +++ b/.gitignore @@ -62,8 +62,10 @@ out/ !include/ftxui/**/*.cpp # src directory: +!src/ftxui/*.cppm !src/ftxui/**/*.hpp !src/ftxui/**/*.cpp +!src/ftxui/**/*.cppm # tools directory: !tools/**/*.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 17313a60..2e559d50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,22 @@ Next - Use Doxygen awesome. Add our own theme. - 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) ------------ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ff6c8eb..d871e9a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 LANGUAGES CXX @@ -6,15 +21,6 @@ project(ftxui 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 \ 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_install.cmake) include(cmake/ftxui_package.cmake) +include(cmake/ftxui_modules.cmake) -add_subdirectory(examples) 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() diff --git a/README.md b/README.md index e4631159..e44db96e 100644 --- a/README.md +++ b/README.md @@ -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 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) - * 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!). * Learn by [examples](#documentation), and [tutorials](#documentation) * Multiple packages: @@ -50,6 +51,7 @@ A simple cross-platform C++ library for terminal based user interfaces! - [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui) - [Arch Linux](https://aur.archlinux.org/packages/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) * Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc... ## Documentation @@ -357,6 +359,7 @@ Feel free to add your projects here: - [terminal-rain](https://github.com/Oakamoore/terminal-rain) - [keywords](https://github.com/Oakamoore/keywords) ([Play web version :heart:](https://oakamoore.itch.io/keywords)) - [FTB - tertminal file browser](https://github.com/Cyxuan0311/FTB) +- [openJuice](https://github.com/mikomikotaishi/openJuice) - [SHOOT!](https://github.com/ShingZhanho/ENGG1340-Project-25Spring) ### [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam) @@ -435,6 +438,8 @@ If you choose to build and link FTXUI yourself, `ftxui-component` must be first g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . . ``` +To build FTXUI with modules, check [documentation](https://arthursonzogni.github.io/FTXUI/cpp20-modules.html) + ## Contributors diff --git a/cmake/ftxui_message.cmake b/cmake/ftxui_message.cmake index 49cc4e82..5f25f1ac 100644 --- a/cmake/ftxui_message.cmake +++ b/cmake/ftxui_message.cmake @@ -5,13 +5,14 @@ function(ftxui_message msg) endfunction() 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_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_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_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("└─────────────────────────────────────") diff --git a/cmake/ftxui_modules.cmake b/cmake/ftxui_modules.cmake new file mode 100644 index 00000000..6c784a97 --- /dev/null +++ b/cmake/ftxui_modules.cmake @@ -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() diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index d51bbbbf..44a30a6c 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -1001,48 +1001,12 @@ INPUT_FILE_ENCODING = FILE_PATTERNS = *.c \ *.cc \ - *.cxx \ *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ *.h \ - *.hh \ - *.hxx \ *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ *.md \ - *.mm \ - *.dox \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf + *.cppm \ # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. diff --git a/doc/cpp20-modules.md b/doc/cpp20-modules.md new file mode 100644 index 00000000..3fed5b5b --- /dev/null +++ b/doc/cpp20-modules.md @@ -0,0 +1,85 @@ +@page cpp20-modules C++20 Modules + +coucou + +> [!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 provides an experimental support for [C++20 +modules](https://en.cppreference.com/w/cpp/language/modules) to improve +compilation times and code organization. The existing API has a module +corresponding to each header. + +**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` diff --git a/doc/header.html b/doc/header.html index 23e998e6..649783b3 100644 --- a/doc/header.html +++ b/doc/header.html @@ -108,7 +108,6 @@ console.log("navtree.textContent", navtree.textContent); if (!navtree.textContent.includes("Getting Started") && !navtree.textContent.includes("Installation") && - !navtree.textContent.includes("Modules") && !navtree.textContent.includes("ftxui / screen") && !navtree.textContent.includes("ftxui / dom") && !navtree.textContent.includes("ftxui / component") && diff --git a/doc/module.md b/doc/module.md index 91be215f..3ef928bf 100644 --- a/doc/module.md +++ b/doc/module.md @@ -1,4 +1,4 @@ -# Modules {#modules} +# ftxui {#ftxui} ![title-img](https://nsm09.casimages.com/img/2025/05/30//2505300816063242518595251.jpg) diff --git a/examples/component/scrollbar.cpp b/examples/component/scrollbar.cpp index 6bdc4289..33b02241 100644 --- a/examples/component/scrollbar.cpp +++ b/examples/component/scrollbar.cpp @@ -3,6 +3,7 @@ // the LICENSE file. #include #include +#include using namespace ftxui; diff --git a/examples/component/window.cpp b/examples/component/window.cpp index 121b48a6..16966d62 100644 --- a/examples/component/window.cpp +++ b/examples/component/window.cpp @@ -3,6 +3,7 @@ // the LICENSE file. #include #include +#include using namespace ftxui; diff --git a/src/ftxui/component.cppm b/src/ftxui/component.cppm new file mode 100644 index 00000000..fcf9b38e --- /dev/null +++ b/src/ftxui/component.cppm @@ -0,0 +1,18 @@ +/** + * @file component.cppm + * @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; diff --git a/src/ftxui/component/animation.cppm b/src/ftxui/component/animation.cppm new file mode 100644 index 00000000..0ddf8dea --- /dev/null +++ b/src/ftxui/component/animation.cppm @@ -0,0 +1,66 @@ +/// @module ftxui.component.animation +/// @brief Module file for the Animation namespace of the Component module. +/// +/// @file animation.cppm + +module; + +#include + +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; +} diff --git a/src/ftxui/component/captured_mouse.cppm b/src/ftxui/component/captured_mouse.cppm new file mode 100644 index 00000000..eca2b6ec --- /dev/null +++ b/src/ftxui/component/captured_mouse.cppm @@ -0,0 +1,18 @@ +/** + * @file captured_mouse.cppm + * @brief Module file for the CapturedMouseInterface class of the Component module + */ + +module; + +#include + +export module ftxui.component.captured_mouse; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::CapturedMouseInterface; +} diff --git a/src/ftxui/component/component.cppm b/src/ftxui/component/component.cppm new file mode 100644 index 00000000..a55eec58 --- /dev/null +++ b/src/ftxui/component/component.cppm @@ -0,0 +1,61 @@ +/** + * @file component.cppm + * @brief Module file for the Component classes of the Component module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/component/component_base.cppm b/src/ftxui/component/component_base.cppm new file mode 100644 index 00000000..d470d329 --- /dev/null +++ b/src/ftxui/component/component_base.cppm @@ -0,0 +1,28 @@ +/** + * @file component_base.cppm + * @brief Module file for the ComponentBase class of the Component module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/component/component_options.cppm b/src/ftxui/component/component_options.cppm new file mode 100644 index 00000000..11fce76f --- /dev/null +++ b/src/ftxui/component/component_options.cppm @@ -0,0 +1,33 @@ +/** + * @file component_options.cppm + * @brief Module file for options for the Component class of the Component module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/component/event.cppm b/src/ftxui/component/event.cppm new file mode 100644 index 00000000..d67f7cc6 --- /dev/null +++ b/src/ftxui/component/event.cppm @@ -0,0 +1,21 @@ +/** + * @file event.cppm + * @brief Module file for the Event struct of the Component module + */ + +module; + +#include + +export module ftxui.component.event; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::ScreenInteractive; + using ftxui::ComponentBase; + + using ftxui::Event; +} diff --git a/src/ftxui/component/loop.cppm b/src/ftxui/component/loop.cppm new file mode 100644 index 00000000..34cbaef0 --- /dev/null +++ b/src/ftxui/component/loop.cppm @@ -0,0 +1,22 @@ +/** + * @file loop.cppm + * @brief Module file for the Loop class of the Component module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/component/mouse.cppm b/src/ftxui/component/mouse.cppm new file mode 100644 index 00000000..3124c84f --- /dev/null +++ b/src/ftxui/component/mouse.cppm @@ -0,0 +1,18 @@ +/** + * @file mouse.cppm + * @brief Module file for the Mouse struct of the Component module + */ + +module; + +#include + +export module ftxui.component.mouse; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Mouse; +} diff --git a/src/ftxui/component/receiver.cppm b/src/ftxui/component/receiver.cppm new file mode 100644 index 00000000..fb572e06 --- /dev/null +++ b/src/ftxui/component/receiver.cppm @@ -0,0 +1,22 @@ +/** + * @file receiver.cppm + * @brief Module file for the Receiver class of the Component module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/component/screen_interactive.cppm b/src/ftxui/component/screen_interactive.cppm new file mode 100644 index 00000000..dc15d8ab --- /dev/null +++ b/src/ftxui/component/screen_interactive.cppm @@ -0,0 +1,25 @@ +/** + * @file screen_interactive.cppm + * @brief Module file for the ScreenInteractive class of the Component module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/component/task.cppm b/src/ftxui/component/task.cppm new file mode 100644 index 00000000..0ca03188 --- /dev/null +++ b/src/ftxui/component/task.cppm @@ -0,0 +1,20 @@ +/** + * @file task.cppm + * @brief Module file for the Task class of the Component module + */ + +module; + +#include + +export module ftxui.component.task; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::AnimationTask; + using ftxui::Closure; + using ftxui::Task; +} diff --git a/src/ftxui/dom.cppm b/src/ftxui/dom.cppm new file mode 100644 index 00000000..8d89dfb6 --- /dev/null +++ b/src/ftxui/dom.cppm @@ -0,0 +1,17 @@ +/** + * @file dom.cppm + * @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; diff --git a/src/ftxui/dom/canvas.cppm b/src/ftxui/dom/canvas.cppm new file mode 100644 index 00000000..d1da96bf --- /dev/null +++ b/src/ftxui/dom/canvas.cppm @@ -0,0 +1,18 @@ +/** + * @file canvas.cppm + * @brief Module file for the Canvas struct of the Dom module + */ + +module; + +#include + +export module ftxui.dom.canvas; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Canvas; +} diff --git a/src/ftxui/dom/deprecated.cppm b/src/ftxui/dom/deprecated.cppm new file mode 100644 index 00000000..cda092f2 --- /dev/null +++ b/src/ftxui/dom/deprecated.cppm @@ -0,0 +1,20 @@ +/** + * @file deprecated.cppm + * @brief Module file for deprecated parts of the Dom module + */ + +module; + +#include + +export module ftxui.dom.deprecated; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::text; + using ftxui::vtext; + using ftxui::paragraph; +} diff --git a/src/ftxui/dom/direction.cppm b/src/ftxui/dom/direction.cppm new file mode 100644 index 00000000..294b781d --- /dev/null +++ b/src/ftxui/dom/direction.cppm @@ -0,0 +1,18 @@ +/** + * @file direction.cppm + * @brief Module file for the Direction enum of the Dom module + */ + +module; + +#include + +export module ftxui.dom.direction; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Direction; +} diff --git a/src/ftxui/dom/elements.cppm b/src/ftxui/dom/elements.cppm new file mode 100644 index 00000000..2b65f0ef --- /dev/null +++ b/src/ftxui/dom/elements.cppm @@ -0,0 +1,137 @@ +/** + * @file canvas.cppm + * @brief Module file for the Element classes and functions of the Dom module + */ + +module; + +#include + +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; + } +} diff --git a/src/ftxui/dom/flexbox_config.cppm b/src/ftxui/dom/flexbox_config.cppm new file mode 100644 index 00000000..1f7357e9 --- /dev/null +++ b/src/ftxui/dom/flexbox_config.cppm @@ -0,0 +1,18 @@ +/** + * @file flexbox_config.cppm + * @brief Module file for the FlexboxConfig struct of the Dom module + */ + +module; + +#include + +export module ftxui.dom.flexbox_config; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::FlexboxConfig; +} diff --git a/src/ftxui/dom/linear_gradient.cppm b/src/ftxui/dom/linear_gradient.cppm new file mode 100644 index 00000000..fc359a86 --- /dev/null +++ b/src/ftxui/dom/linear_gradient.cppm @@ -0,0 +1,18 @@ +/** + * @file linear_gradient.cppm + * @brief Module file for the LinearGradient struct of the Dom module + */ + +module; + +#include + +export module ftxui.dom.linear_gradient; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::LinearGradient; +} diff --git a/src/ftxui/dom/node.cppm b/src/ftxui/dom/node.cppm new file mode 100644 index 00000000..a7c58ed7 --- /dev/null +++ b/src/ftxui/dom/node.cppm @@ -0,0 +1,25 @@ +/** + * @file node.cppm + * @brief Module file for the Node class of the Dom module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/dom/requirement.cppm b/src/ftxui/dom/requirement.cppm new file mode 100644 index 00000000..c187547d --- /dev/null +++ b/src/ftxui/dom/requirement.cppm @@ -0,0 +1,18 @@ +/** + * @file requirement.cppm + * @brief Module file for the Requirement struct of the Dom module + */ + +module; + +#include + +export module ftxui.dom.requirement; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Requirement; +} diff --git a/src/ftxui/dom/selection.cppm b/src/ftxui/dom/selection.cppm new file mode 100644 index 00000000..79d9b816 --- /dev/null +++ b/src/ftxui/dom/selection.cppm @@ -0,0 +1,18 @@ +/** + * @file selection.cppm + * @brief Module file for the Selection class of the Dom module + */ + +module; + +#include + +export module ftxui.dom.selection; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Selection; +} diff --git a/src/ftxui/dom/table.cppm b/src/ftxui/dom/table.cppm new file mode 100644 index 00000000..d9d0010c --- /dev/null +++ b/src/ftxui/dom/table.cppm @@ -0,0 +1,19 @@ +/** + * @file table.cppm + * @brief Module file for the Table class of the Dom module + */ + +module; + +#include + +export module ftxui.dom.table; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Table; + using ftxui::TableSelection; +} diff --git a/src/ftxui/ftxui.cppm b/src/ftxui/ftxui.cppm new file mode 100644 index 00000000..effab708 --- /dev/null +++ b/src/ftxui/ftxui.cppm @@ -0,0 +1,11 @@ +/** + * @file ftxui.cppm + * @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; diff --git a/src/ftxui/screen.cppm b/src/ftxui/screen.cppm new file mode 100644 index 00000000..88e201e9 --- /dev/null +++ b/src/ftxui/screen.cppm @@ -0,0 +1,16 @@ +/** + * @file screen.cppm + * @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; diff --git a/src/ftxui/screen/box.cppm b/src/ftxui/screen/box.cppm new file mode 100644 index 00000000..41f711fe --- /dev/null +++ b/src/ftxui/screen/box.cppm @@ -0,0 +1,18 @@ +/** + * @file box.cppm + * @brief Module file for the Box struct of the Screen module + */ + +module; + +#include + +export module ftxui.screen.box; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Box; +} diff --git a/src/ftxui/screen/color.cppm b/src/ftxui/screen/color.cppm new file mode 100644 index 00000000..fffb4dfc --- /dev/null +++ b/src/ftxui/screen/color.cppm @@ -0,0 +1,22 @@ +/** + * @file color.cppm + * @brief Module file for the Color class of the Screen module + */ + +module; + +#include + +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; + } +} diff --git a/src/ftxui/screen/color_info.cppm b/src/ftxui/screen/color_info.cppm new file mode 100644 index 00000000..bc8ee15b --- /dev/null +++ b/src/ftxui/screen/color_info.cppm @@ -0,0 +1,20 @@ +/** + * @file color_info.cppm + * @brief Module file for the ColorInfo struct of the Screen module + */ + +module; + +#include + +export module ftxui.screen.color_info; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::ColorInfo; + + using ftxui::GetColorInfo; +} diff --git a/src/ftxui/screen/deprecated.cppm b/src/ftxui/screen/deprecated.cppm new file mode 100644 index 00000000..99f8654c --- /dev/null +++ b/src/ftxui/screen/deprecated.cppm @@ -0,0 +1,19 @@ +/** + * @file box.cppm + * @brief Module file for the deprecated parts of the Screen module + */ + +module; + +#include + +export module ftxui.screen.deprecated; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::wchar_width; + using ftxui::wstring_width; +} diff --git a/src/ftxui/screen/image.cppm b/src/ftxui/screen/image.cppm new file mode 100644 index 00000000..d7867659 --- /dev/null +++ b/src/ftxui/screen/image.cppm @@ -0,0 +1,18 @@ +/** + * @file image.cppm + * @brief Module file for the Image class of the Screen module + */ + +module; + +#include + +export module ftxui.screen.image; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Image; +} diff --git a/src/ftxui/screen/pixel.cppm b/src/ftxui/screen/pixel.cppm new file mode 100644 index 00000000..7cfe415f --- /dev/null +++ b/src/ftxui/screen/pixel.cppm @@ -0,0 +1,18 @@ +/** + * @file pixel.cppm + * @brief Module file for the Pixel struct of the Screen module + */ + +module; + +#include + +export module ftxui.screen.pixel; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::Pixel; +} diff --git a/src/ftxui/screen/screen.cppm b/src/ftxui/screen/screen.cppm new file mode 100644 index 00000000..659b300f --- /dev/null +++ b/src/ftxui/screen/screen.cppm @@ -0,0 +1,24 @@ +/** + * @file screen.cppm + * @brief Module file for the Screen class of the Screen module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/screen/string.cppm b/src/ftxui/screen/string.cppm new file mode 100644 index 00000000..108cee75 --- /dev/null +++ b/src/ftxui/screen/string.cppm @@ -0,0 +1,22 @@ +/** + * @file string.cppm + * @brief Module file for string functions of the Screen module + */ + +module; + +#include + +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; +} diff --git a/src/ftxui/screen/terminal.cppm b/src/ftxui/screen/terminal.cppm new file mode 100644 index 00000000..48ab7dcf --- /dev/null +++ b/src/ftxui/screen/terminal.cppm @@ -0,0 +1,26 @@ +/** + * @file terminal.cppm + * @brief Module file for the Terminal namespace of the Screen module + */ + +module; + +#include + +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; + } +} diff --git a/src/ftxui/util.cppm b/src/ftxui/util.cppm new file mode 100644 index 00000000..a7b82af4 --- /dev/null +++ b/src/ftxui/util.cppm @@ -0,0 +1,9 @@ +/** + * @file util.cppm + * @brief Module file for FTXUI utility operations. + */ + +export module ftxui.util; + +export import ftxui.util.autoreset; +export import ftxui.util.ref; diff --git a/src/ftxui/util/autoreset.cppm b/src/ftxui/util/autoreset.cppm new file mode 100644 index 00000000..dc67c200 --- /dev/null +++ b/src/ftxui/util/autoreset.cppm @@ -0,0 +1,18 @@ +/** + * @file autoreset.cppm + * @brief Module file for the AutoReset class of the Util module + */ + +module; + +#include + +export module ftxui.util.autoreset; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::AutoReset; +} diff --git a/src/ftxui/util/ref.cppm b/src/ftxui/util/ref.cppm new file mode 100644 index 00000000..88fce079 --- /dev/null +++ b/src/ftxui/util/ref.cppm @@ -0,0 +1,22 @@ +/** + * @file ref.cppm + * @brief Module file for the Ref classes of the Util module + */ + +module; + +#include + +export module ftxui.util.ref; + +/** + * @namespace ftxui + * @brief The FTXUI ftxui:: namespace + */ +export namespace ftxui { + using ftxui::ConstRef; + using ftxui::Ref; + using ftxui::StringRef; + using ftxui::ConstStringRef; + using ftxui::ConstStringListRef; +} diff --git a/tools/generate_examples_modules.sh b/tools/generate_examples_modules.sh new file mode 100755 index 00000000..aa6a5165 --- /dev/null +++ b/tools/generate_examples_modules.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Generate ./examples_modules from ./examples to using C++20 modules instead of +# #includes for ftxui. +# This is useful for testing ftxui with modules. This ensures we don't forget +# to update the FTXUI modules when adding new features to FTXUI. + +echo "Generating ./examples_modules" +rm -rf ./examples_modules +cp -r ./examples ./examples_modules + +for file in ./examples_modules/**/*.cpp; do + echo "Generating $file" + + sed -i '/#include "ftxui/d' "$file" + sed -i '/#include