Skip to content

Commit 229cae7

Browse files
Use module partitions instead of full modules (#1146)
Follow-up to #1015. This pull request replaces the full modules that represent headers, with partitions, to emphasise the belonging of the header to the module. This should hopefully provide a speedup to compilation, and confuse users less by aggregating the usable modules into a smaller set.
1 parent e87d5ff commit 229cae7

37 files changed

+140
-149
lines changed

doc/cpp20-modules.md

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
> [!WARNING]
55
> This feature is still in development, and the API may change in future releases.
66
> Your contribution is needed to help us improve the compatibility and usability
7-
> of C++20 modules in FTXUI. If you encounter any issues or have suggestions,
7+
> of C++ modules in FTXUI. If you encounter any issues or have suggestions,
88
> please open an issue.
99
1010
FTXUI experimentally supports
1111
[C++20 modules](https://en.cppreference.com/w/cpp/language/modules) to reduce
12-
compilation times and improve code organization. Each header has a
13-
corresponding module.
12+
compilation times and improve code organization. Each part of the library has a
13+
corresponding module, split into partitions per each header.
1414

15-
Use the FTXUI_BUILD_MODULES option to build the FTXUI project itself to provide C++ 20 modules,
15+
Use the FTXUI_BUILD_MODULES option to build the FTXUI project itself to provide C++20 modules,
1616
for example with CMake and Ninja:
1717

1818
```sh
@@ -25,7 +25,7 @@ ninja
2525
```
2626

2727
> [!NOTE]
28-
> To use modules, you need a C++20 compatible compiler, CMake version 3.20 or
28+
> To use modules, you need a C++20 compatible compiler, CMake version 3.20 or
2929
> higher, and use a compatible generator like Ninja. Note that Makefile
3030
> generators **do not support modules**.
3131
@@ -34,9 +34,12 @@ Then, in your own code you can consume the modules and code as normal:
3434
```cpp
3535
import ftxui;
3636

37+
using ftxui::Button;
38+
using ftxui::ScreenInteractive;
39+
3740
int main() {
38-
auto screen = ftxui::ScreenInteractive::TerminalOutput();
39-
auto button = ftxui::Button("Click me", screen.QuitClosure());
41+
auto screen = ScreenInteractive::TerminalOutput();
42+
auto button = Button("Click me", screen.QuitClosure());
4043
screen.Loop(button);
4144
return 0;
4245
}
@@ -70,38 +73,6 @@ are available:
7073

7174
- `ftxui`
7275
- `ftxui.component`
73-
- `ftxui.component.Animation`
74-
- `ftxui.component.CapturedMouse`
75-
- `ftxui.component.Component`
76-
- `ftxui.component.ComponentBase`
77-
- `ftxui.component.ComponentOptions`
78-
- `ftxui.component.Event`
79-
- `ftxui.component.Loop`
80-
- `ftxui.component.Mouse`
81-
- `ftxui.component.Receiver`
82-
- `ftxui.component.ScreenInteractive`
83-
- `ftxui.component.Task`
84-
- `ftxui.dom`
85-
- `ftxui.dom.Canvas`
86-
- `ftxui.dom.Deprecated`
87-
- `ftxui.dom.Direction`
88-
- `ftxui.dom.Elements`
89-
- `ftxui.dom.FlexboxConfig`
90-
- `ftxui.dom.LinearGradient`
91-
- `ftxui.dom.Node`
92-
- `ftxui.dom.Requirement`
93-
- `ftxui.dom.Selection`
94-
- `ftxui.dom.Table`
95-
- `ftxui.screen`
96-
- `ftxui.screen.Box`
97-
- `ftxui.screen.Color`
98-
- `ftxui.screen.ColorInfo`
99-
- `ftxui.screen.Deprecated`
100-
- `ftxui.screen.Image`
101-
- `ftxui.screen.Pixel`
102-
- `ftxui.screen.Screen`
103-
- `ftxui.screen.String`
104-
- `ftxui.screen.Terminal`
105-
- `ftxui.util`
106-
- `ftxui.util.AutoReset`
107-
- `ftxui.util.Ref`
76+
- `ftxui.dom`
77+
- `ftxui.screen`
78+
- `ftxui.util`

src/ftxui/component.cppm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
export module ftxui.component;
55

6-
export import ftxui.component.animation;
7-
export import ftxui.component.captured_mouse;
8-
export import ftxui.component.component;
9-
export import ftxui.component.component_base;
10-
export import ftxui.component.component_options;
11-
export import ftxui.component.event;
12-
export import ftxui.component.loop;
13-
export import ftxui.component.mouse;
14-
export import ftxui.component.receiver;
15-
export import ftxui.component.screen_interactive;
16-
export import ftxui.component.task;
6+
export import :Animation;
7+
export import :CapturedMouse;
8+
export import :Component;
9+
export import :ComponentBase;
10+
export import :ComponentOptions;
11+
export import :Event;
12+
export import :Loop;
13+
export import :Mouse;
14+
export import :Receiver;
15+
export import :ScreenInteractive;
16+
export import :Task;

src/ftxui/component/animation.cppm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/// @module ftxui.component.animation
1+
/// @module ftxui.component:Animation
22
/// @brief C++20 module interface for the Animation namespace of the Component module.
33
///
44

55
module;
66

77
#include <ftxui/component/animation.hpp>
88

9-
export module ftxui.component.animation;
9+
export module ftxui.component:Animation;
1010

1111
/**
1212
* @namespace ftxui::animation
@@ -23,7 +23,7 @@ export namespace ftxui::animation {
2323

2424
/**
2525
* @namespace easing
26-
* @brief The FTXUI sf::animation::easing:: namespace
26+
* @brief The FTXUI ftxui::animation::easing:: namespace
2727
*/
2828
namespace easing {
2929
using ftxui::animation::easing::Function;

src/ftxui/component/captured_mouse.cppm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// @module ftxui.component.captured_mouse
1+
/// @module ftxui.component.CapturedMouse
22
/// @brief Module file for the CapturedMouseInterface class of the Component module
33

44
module;
55

66
#include <ftxui/component/captured_mouse.hpp>
77

8-
export module ftxui.component.captured_mouse;
8+
export module ftxui.component:CapturedMouse;
99

1010
/**
1111
* @namespace ftxui

src/ftxui/component/component.cppm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// @module ftxui.component.component
1+
/// @module ftxui.component:Component
22
/// @brief Module file for the Component classes of the Component module
33

44
module;
55

66
#include <ftxui/component/component.hpp>
77

8-
export module ftxui.component.component;
8+
export module ftxui.component:Component;
99

1010
/**
1111
* @namespace ftxui
@@ -28,6 +28,10 @@ export namespace ftxui {
2828
using ftxui::operator|;
2929
using ftxui::operator|=;
3030

31+
/**
32+
* @namespace Container
33+
* @brief The FTXUI ftxui::Container:: namespace
34+
*/
3135
namespace Container {
3236
using ftxui::Container::Vertical;
3337
using ftxui::Container::Horizontal;

src/ftxui/component/component_base.cppm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// @module ftxui.component.component_base
1+
/// @module ftxui.component:ComponentBase
22
/// @brief Module file for the ComponentBase class of the Component module
33

44
module;
55

66
#include <ftxui/component/component_base.hpp>
77

8-
export module ftxui.component.component_base;
8+
export module ftxui.component:ComponentBase;
99

1010
/**
1111
* @namespace ftxui
@@ -16,6 +16,10 @@ export namespace ftxui {
1616
using ftxui::Focus;
1717
using ftxui::Event;
1818

19+
/**
20+
* @namespace animation
21+
* @brief The FTXUI ftxui::animation:: namespace
22+
*/
1923
namespace animation {
2024
using ftxui::animation::Params;
2125
}

src/ftxui/component/component_options.cppm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// @module ftxui.component.component_options
1+
/// @module ftxui.component:ComponentOptions
22
/// @brief Module file for options for the Component class of the Component module
33

44
module;
55

66
#include <ftxui/component/component_options.hpp>
77

8-
export module ftxui.component.component_options;
8+
export module ftxui.component:ComponentOptions;
99

1010
/**
1111
* @namespace ftxui

src/ftxui/component/event.cppm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// @module ftxui.component.event
1+
/// @module ftxui.component:Event
22
/// @brief Module file for the Event struct of the Component module
33

44
module;
55

66
#include <ftxui/component/event.hpp>
77

8-
export module ftxui.component.event;
8+
export module ftxui.component:Event;
99

1010
/**
1111
* @namespace ftxui

src/ftxui/component/loop.cppm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// @module ftxui.component.loop
1+
/// @module ftxui.component:Loop
22
/// @brief Module file for the Loop class of the Component module
33

44
module;
55

66
#include <ftxui/component/loop.hpp>
77

8-
export module ftxui.component.loop;
8+
export module ftxui.component:Loop;
99

1010
/**
1111
* @namespace ftxui

src/ftxui/component/mouse.cppm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// @module ftxui.component.mouse
1+
/// @module ftxui.component:Mouse
22
/// @brief Module file for the Mouse struct of the Component module
33

44
module;
55

66
#include <ftxui/component/mouse.hpp>
77

8-
export module ftxui.component.mouse;
8+
export module ftxui.component:Mouse;
99

1010
/**
1111
* @namespace ftxui

0 commit comments

Comments
 (0)