2.6 KiB
@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 provides an experimental support for C++20 modules to improve compilation times and code organization. The existing API has a module corresponding to each header.
Example with CMake and Ninja
import ftxui;
int main() {
auto screen = ftxui::ScreenInteractive::TerminalOutput();
auto button = ftxui::Button("Click me", screen.QuitClosure());
screen.Loop(button);
return 0;
}
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:
ftxuiftxui.componentftxui.component.Animationftxui.component.CapturedMouseftxui.component.Componentftxui.component.ComponentBaseftxui.component.ComponentOptionsftxui.component.Eventftxui.component.Loopftxui.component.Mouseftxui.component.Receiverftxui.component.ScreenInteractiveftxui.component.Task
ftxui.domftxui.dom.Canvasftxui.dom.Deprecatedftxui.dom.Directionftxui.dom.Elementsftxui.dom.FlexboxConfigftxui.dom.LinearGradientftxui.dom.Nodeftxui.dom.Requirementftxui.dom.Selectionftxui.dom.Table
ftxui.screenftxui.screen.Boxftxui.screen.Colorftxui.screen.ColorInfoftxui.screen.Deprecatedftxui.screen.Imageftxui.screen.Pixelftxui.screen.Screenftxui.screen.Stringftxui.screen.Terminal
ftxui.utilftxui.util.AutoResetftxui.util.Ref
![NOTE] The module
ftxuitransitively imports allftxui.*modules and thus has a dependency on those modules.
![NOTE] The list can be generated with the following command:
git grep "export module" | cut -d: -f2 | cut -d\ -f3