diff --git a/.github/workflows/linux-emscripten.yaml b/.github/workflows/linux-emscripten.yaml index 64b5f51..1c60d40 100644 --- a/.github/workflows/linux-emscripten.yaml +++ b/.github/workflows/linux-emscripten.yaml @@ -16,5 +16,5 @@ jobs: run: > mkdir build; cd build; - emcmake cmake .. + emcmake cmake ..; cmake --build . --config Release; diff --git a/CMakeLists.txt b/CMakeLists.txt index c6182a0..e6fc342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,14 @@ add_library(ftxui::component ALIAS component) target_link_libraries(dom PUBLIC screen) target_link_libraries(component PUBLIC dom Threads::Threads) + find_program(iwyu_path NAMES include-what-you-use iwyu) + if(iwyu_path) + set_property(TARGET ${lib} + PROPERTY ${iwyu_path} -Xiwyu + --mapping_file ${CMAKE_CURRENT_SOURCE_DIR}/iwyu.impl + ) + endif() + foreach(lib screen dom component) target_include_directories(${lib} diff --git a/doc/example_list.md b/doc/example_list.md index 3b089bc..efddeab 100644 --- a/doc/example_list.md +++ b/doc/example_list.md @@ -30,6 +30,7 @@ @example ./examples/component/checkbox_in_frame.cpp @example ./examples/component/menu2.cpp @example ./examples/component/tab_horizontal.cpp +@example ./examples/component/slider.cpp @example ./examples/component/input.cpp @example ./examples/component/homescreen.cpp @example ./examples/component/radiobox.cpp diff --git a/examples/component/button.cpp b/examples/component/button.cpp index d38f4c1..dc3ceaf 100644 --- a/examples/component/button.cpp +++ b/examples/component/button.cpp @@ -1,8 +1,14 @@ -#include "ftxui/component/button.hpp" +#include // for function +#include // for unique_ptr, make_u... +#include // for wstring +#include // for move +#include // for vector -#include "ftxui/component/component.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include "ftxui/component/button.hpp" // for Button +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/screen/box.hpp" // for ftxui using namespace ftxui; diff --git a/examples/component/checkbox.cpp b/examples/component/checkbox.cpp index a0cb0b8..47189b6 100644 --- a/examples/component/checkbox.cpp +++ b/examples/component/checkbox.cpp @@ -1,8 +1,7 @@ #include "ftxui/component/checkbox.hpp" - -#include "ftxui/component/component.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive using namespace ftxui; diff --git a/examples/component/checkbox_in_frame.cpp b/examples/component/checkbox_in_frame.cpp index 608f2d2..c1f0f96 100644 --- a/examples/component/checkbox_in_frame.cpp +++ b/examples/component/checkbox_in_frame.cpp @@ -1,10 +1,15 @@ -#include "ftxui/component/checkbox.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/input.hpp" -#include "ftxui/component/menu.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/component/toggle.hpp" -#include "ftxui/screen/string.hpp" +#include // for allocator_traits<>... +#include // for operator+, wstring +#include // for move +#include // for vector + +#include "ftxui/component/checkbox.hpp" // for CheckBox +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/dom/elements.hpp" // for Element, operator| +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/string.hpp" // for to_wstring using namespace ftxui; diff --git a/examples/component/gallery.cpp b/examples/component/gallery.cpp index 9bd5c86..d819c54 100644 --- a/examples/component/gallery.cpp +++ b/examples/component/gallery.cpp @@ -1,12 +1,20 @@ -#include "ftxui/component/button.hpp" -#include "ftxui/component/checkbox.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/input.hpp" -#include "ftxui/component/menu.hpp" -#include "ftxui/component/radiobox.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/component/slider.hpp" -#include "ftxui/component/toggle.hpp" +#include // for function +#include // for allocator, unique_ptr +#include // for wstring +#include // for vector + +#include "ftxui/component/button.hpp" // for Button +#include "ftxui/component/checkbox.hpp" // for CheckBox +#include "ftxui/component/component.hpp" // for Component, Compone... +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/input.hpp" // for Input +#include "ftxui/component/menu.hpp" // for Menu +#include "ftxui/component/radiobox.hpp" // for RadioBox +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/component/slider.hpp" // for Slider +#include "ftxui/component/toggle.hpp" // for Toggle +#include "ftxui/dom/elements.hpp" // for separator, operator| +#include "ftxui/screen/box.hpp" // for ftxui using namespace ftxui; @@ -73,10 +81,11 @@ class MyComponent : public Component { Element Render(std::wstring name, Element element) { return hbox({ - text(name) | size(WIDTH, EQUAL, 8), - separator(), - element | xflex, - }) | xflex; + text(name) | size(WIDTH, EQUAL, 8), + separator(), + element | xflex, + }) | + xflex; } Element Render(std::wstring name, Component& component) { diff --git a/examples/component/homescreen.cpp b/examples/component/homescreen.cpp index ac8fc83..b6c49c7 100644 --- a/examples/component/homescreen.cpp +++ b/examples/component/homescreen.cpp @@ -1,14 +1,23 @@ -#include -#include +#include // for operator""s, chron... +#include // for sin +#include // for ref, reference_wra... +#include // for allocator, wstring +#include // for sleep_for, thread +#include // for move +#include // for vector -#include "ftxui/component/checkbox.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/input.hpp" -#include "ftxui/component/menu.hpp" -#include "ftxui/component/radiobox.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/component/toggle.hpp" -#include "ftxui/screen/string.hpp" +#include "ftxui/component/checkbox.hpp" // for CheckBox +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/event.hpp" // for Event, Event::Custom +#include "ftxui/component/input.hpp" // for Input +#include "ftxui/component/menu.hpp" // for Menu +#include "ftxui/component/radiobox.hpp" // for RadioBox +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/component/toggle.hpp" // for Toggle +#include "ftxui/dom/elements.hpp" // for text, operator| +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/color.hpp" // for Color, Color::Blue... using namespace ftxui; diff --git a/examples/component/input.cpp b/examples/component/input.cpp index 2f2eb51..3fc69e1 100644 --- a/examples/component/input.cpp +++ b/examples/component/input.cpp @@ -1,10 +1,6 @@ #include "ftxui/component/input.hpp" - -#include - -#include "ftxui/component/container.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/screen/string.hpp" +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive using namespace ftxui; diff --git a/examples/component/menu.cpp b/examples/component/menu.cpp index 1fd33e3..41860fe 100644 --- a/examples/component/menu.cpp +++ b/examples/component/menu.cpp @@ -1,10 +1,11 @@ -#include "ftxui/component/menu.hpp" +#include // for function +#include // for basic_ostream::ope... +#include // for wstring, allocator +#include // for vector -#include -#include -#include - -#include "ftxui/component/screen_interactive.hpp" +#include "ftxui/component/menu.hpp" // for Menu +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/screen/box.hpp" // for ftxui int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/component/menu2.cpp b/examples/component/menu2.cpp index dd422f6..91aacf8 100644 --- a/examples/component/menu2.cpp +++ b/examples/component/menu2.cpp @@ -1,11 +1,14 @@ -#include -#include -#include +#include // for function +#include // for wstring, allocator +#include // for vector -#include "ftxui/component/container.hpp" -#include "ftxui/component/menu.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/screen/string.hpp" +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/menu.hpp" // for Menu +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/dom/elements.hpp" // for text, separator, bold +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/string.hpp" // for to_wstring using namespace ftxui; diff --git a/examples/component/menu_style.cpp b/examples/component/menu_style.cpp index da1fb68..3fc8879 100644 --- a/examples/component/menu_style.cpp +++ b/examples/component/menu_style.cpp @@ -1,10 +1,15 @@ -#include -#include +#include // for function +#include // for initializer_list +#include // for wstring, allocator +#include // for vector -#include "ftxui/component/container.hpp" -#include "ftxui/component/menu.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/screen/string.hpp" +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/menu.hpp" // for Menu +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/dom/elements.hpp" // for operator|, Element +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/color.hpp" // for Color, Color::Blue using namespace ftxui; @@ -13,7 +18,14 @@ class MyComponent : public Component { MyComponent() { Add(&container); - for (Menu* menu : {&menu_1, &menu_2, &menu_3, &menu_4, &menu_5, &menu_6,}) { + for (Menu* menu : { + &menu_1, + &menu_2, + &menu_3, + &menu_4, + &menu_5, + &menu_6, + }) { container.Add(menu); menu->entries = { L"Monkey", L"Dog", L"Cat", L"Bird", L"Elephant", diff --git a/examples/component/modal_dialog.cpp b/examples/component/modal_dialog.cpp index 520fd78..d325e49 100644 --- a/examples/component/modal_dialog.cpp +++ b/examples/component/modal_dialog.cpp @@ -1,7 +1,14 @@ -#include "ftxui/component/button.hpp" -#include "ftxui/component/component.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include // for function +#include // for allocator_traits<>... +#include // for operator+, wstring +#include // for vector + +#include "ftxui/component/button.hpp" // for Button +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/dom/elements.hpp" // for Element, operator| +#include "ftxui/screen/box.hpp" // for ftxui using namespace ftxui; diff --git a/examples/component/radiobox.cpp b/examples/component/radiobox.cpp index 62d0f1e..0a3a650 100644 --- a/examples/component/radiobox.cpp +++ b/examples/component/radiobox.cpp @@ -1,8 +1,5 @@ #include "ftxui/component/radiobox.hpp" - -#include "ftxui/component/component.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive using namespace ftxui; diff --git a/examples/component/radiobox_in_frame.cpp b/examples/component/radiobox_in_frame.cpp index 0137425..09c8644 100644 --- a/examples/component/radiobox_in_frame.cpp +++ b/examples/component/radiobox_in_frame.cpp @@ -1,11 +1,12 @@ -#include "ftxui/component/checkbox.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/input.hpp" -#include "ftxui/component/menu.hpp" -#include "ftxui/component/radiobox.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/component/toggle.hpp" -#include "ftxui/screen/string.hpp" +#include // for wstring, operator+ +#include // for vector + +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/radiobox.hpp" // for RadioBox +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/dom/elements.hpp" // for Element, operator| +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/string.hpp" // for to_wstring using namespace ftxui; diff --git a/examples/component/slider.cpp b/examples/component/slider.cpp index 65cb068..9e7b6f1 100644 --- a/examples/component/slider.cpp +++ b/examples/component/slider.cpp @@ -1,16 +1,21 @@ -#include "ftxui/component/slider.hpp" -#include "ftxui/component/container.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/component/toggle.hpp" -#include "ftxui/screen/string.hpp" +#include // for function +#include // for allocator, unique_ptr +#include // for operator+, to_wstring + +#include "ftxui/component/component.hpp" // for Component, Compone... +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/event.hpp" // for Event, Event::Escape +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/component/slider.hpp" // for Slider +#include "ftxui/dom/elements.hpp" // for separator, operator| +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/color.hpp" // for Color using namespace ftxui; Element ColorTile(int red, int green, int blue) { - return text(L"") - | size(WIDTH, GREATER_THAN, 14) - | size(HEIGHT, GREATER_THAN, 7) - | bgcolor(Color::RGB(red, green, blue)); + return text(L"") | size(WIDTH, GREATER_THAN, 14) | + size(HEIGHT, GREATER_THAN, 7) | bgcolor(Color::RGB(red, green, blue)); } Element ColorString(int red, int green, int blue) { diff --git a/examples/component/tab_horizontal.cpp b/examples/component/tab_horizontal.cpp index a475e4b..8d4b822 100644 --- a/examples/component/tab_horizontal.cpp +++ b/examples/component/tab_horizontal.cpp @@ -1,11 +1,14 @@ -#include -#include +#include // for function +#include // for wstring, allocator +#include // for vector -#include "ftxui/component/container.hpp" -#include "ftxui/component/radiobox.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/component/toggle.hpp" -#include "ftxui/screen/string.hpp" +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/radiobox.hpp" // for RadioBox +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/component/toggle.hpp" // for Toggle +#include "ftxui/dom/elements.hpp" // for Element, operator| +#include "ftxui/screen/box.hpp" // for ftxui using namespace ftxui; diff --git a/examples/component/tab_vertical.cpp b/examples/component/tab_vertical.cpp index b32a8d9..398be13 100644 --- a/examples/component/tab_vertical.cpp +++ b/examples/component/tab_vertical.cpp @@ -1,10 +1,12 @@ -#include +#include // for function +#include // for wstring, allocator +#include // for vector -#include "ftxui/component/container.hpp" -#include "ftxui/component/menu.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/component/toggle.hpp" -#include "ftxui/screen/string.hpp" +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/menu.hpp" // for Menu +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/screen/box.hpp" // for ftxui using namespace ftxui; diff --git a/examples/component/toggle.cpp b/examples/component/toggle.cpp index ef2cd3a..5ecf092 100644 --- a/examples/component/toggle.cpp +++ b/examples/component/toggle.cpp @@ -1,12 +1,7 @@ #include "ftxui/component/toggle.hpp" - -#include -#include -#include - -#include "ftxui/component/container.hpp" -#include "ftxui/component/screen_interactive.hpp" -#include "ftxui/screen/string.hpp" +#include "ftxui/component/container.hpp" // for Container +#include "ftxui/component/event.hpp" // for Event, Event::Return +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive using namespace ftxui; diff --git a/examples/dom/border.cpp b/examples/dom/border.cpp index 57fa7b3..bd12701 100644 --- a/examples/dom/border.cpp +++ b/examples/dom/border.cpp @@ -1,8 +1,9 @@ -#include #include #include -#include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/color_gallery.cpp b/examples/dom/color_gallery.cpp index 0775ad1..8bdd3e7 100644 --- a/examples/dom/color_gallery.cpp +++ b/examples/dom/color_gallery.cpp @@ -1,14 +1,16 @@ -#include #include #include #include #include -#include - -#include "ftxui/screen/string.hpp" +#include +#include +#include using namespace ftxui; #include "./color_info_sorted_2d.ipp" // ColorInfoSorted2D. +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" int main(int argc, const char* argv[]) { // clang-format off diff --git a/examples/dom/color_info_palette256.cpp b/examples/dom/color_info_palette256.cpp index 68a1d18..0e172f4 100644 --- a/examples/dom/color_info_palette256.cpp +++ b/examples/dom/color_info_palette256.cpp @@ -1,10 +1,13 @@ -#include -#include #include #include #include -#include -#include +#include +#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" #include "ftxui/screen/string.hpp" using namespace ftxui; diff --git a/examples/dom/color_truecolor_HSV.cpp b/examples/dom/color_truecolor_HSV.cpp index ad902bb..0aa6317 100644 --- a/examples/dom/color_truecolor_HSV.cpp +++ b/examples/dom/color_truecolor_HSV.cpp @@ -1,10 +1,11 @@ -#include #include #include -#include -#include +#include +#include -#include "ftxui/screen/string.hpp" +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/color_truecolor_RGB.cpp b/examples/dom/color_truecolor_RGB.cpp index d35788e..1fd632a 100644 --- a/examples/dom/color_truecolor_RGB.cpp +++ b/examples/dom/color_truecolor_RGB.cpp @@ -1,10 +1,11 @@ -#include #include #include -#include -#include +#include +#include -#include "ftxui/screen/string.hpp" +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/dbox.cpp b/examples/dom/dbox.cpp index 2fc712c..851e3ce 100644 --- a/examples/dom/dbox.cpp +++ b/examples/dom/dbox.cpp @@ -1,6 +1,9 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/gauge.cpp b/examples/dom/gauge.cpp index eb2a96d..ae882e8 100644 --- a/examples/dom/gauge.cpp +++ b/examples/dom/gauge.cpp @@ -2,8 +2,12 @@ #include #include #include +#include #include +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" + int main(int argc, const char* argv[]) { using namespace ftxui; using namespace std::chrono_literals; diff --git a/examples/dom/graph.cpp b/examples/dom/graph.cpp index 78c8f46..55d6257 100644 --- a/examples/dom/graph.cpp +++ b/examples/dom/graph.cpp @@ -2,9 +2,15 @@ #include #include #include -#include +#include #include +#include #include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" class Graph { public: diff --git a/examples/dom/hflow.cpp b/examples/dom/hflow.cpp index aa140a6..6d2cb9d 100644 --- a/examples/dom/hflow.cpp +++ b/examples/dom/hflow.cpp @@ -1,7 +1,11 @@ +#include #include #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/html_like.cpp b/examples/dom/html_like.cpp index be565e8..4f60287 100644 --- a/examples/dom/html_like.cpp +++ b/examples/dom/html_like.cpp @@ -1,10 +1,14 @@ #include #include #include -#include #include +#include #include +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" + int main(int argc, const char* argv[]) { using namespace ftxui; using namespace std::chrono_literals; diff --git a/examples/dom/package_manager.cpp b/examples/dom/package_manager.cpp index 11cbd5f..1ae23b3 100644 --- a/examples/dom/package_manager.cpp +++ b/examples/dom/package_manager.cpp @@ -4,9 +4,16 @@ #include #include #include +#include +#include #include +#include #include +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" + /// @example examples/dom/package_manage.cpp int main(int argc, const char* argv[]) { diff --git a/examples/dom/paragraph.cpp b/examples/dom/paragraph.cpp index adb1f38..9a1a614 100644 --- a/examples/dom/paragraph.cpp +++ b/examples/dom/paragraph.cpp @@ -1,7 +1,10 @@ +#include #include #include -#include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/separator.cpp b/examples/dom/separator.cpp index f3bf1a3..0f258a3 100644 --- a/examples/dom/separator.cpp +++ b/examples/dom/separator.cpp @@ -1,6 +1,9 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/size.cpp b/examples/dom/size.cpp index dfeea1d..bc736d4 100644 --- a/examples/dom/size.cpp +++ b/examples/dom/size.cpp @@ -1,7 +1,12 @@ #include #include #include -#include +#include +#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/spinner.cpp b/examples/dom/spinner.cpp index 7fff889..e5c3a26 100644 --- a/examples/dom/spinner.cpp +++ b/examples/dom/spinner.cpp @@ -3,7 +3,13 @@ #include #include #include +#include #include +#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/style_blink.cpp b/examples/dom/style_blink.cpp index 114a0d4..64645bf 100644 --- a/examples/dom/style_blink.cpp +++ b/examples/dom/style_blink.cpp @@ -1,6 +1,9 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/style_bold.cpp b/examples/dom/style_bold.cpp index e395d78..df0dd6e 100644 --- a/examples/dom/style_bold.cpp +++ b/examples/dom/style_bold.cpp @@ -1,6 +1,9 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/style_color.cpp b/examples/dom/style_color.cpp index f50fddb..f96e3cc 100644 --- a/examples/dom/style_color.cpp +++ b/examples/dom/style_color.cpp @@ -1,6 +1,10 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/style_dim.cpp b/examples/dom/style_dim.cpp index 1c4d446..61b73d7 100644 --- a/examples/dom/style_dim.cpp +++ b/examples/dom/style_dim.cpp @@ -1,6 +1,9 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/style_gallery.cpp b/examples/dom/style_gallery.cpp index 0ce864f..4439aa6 100644 --- a/examples/dom/style_gallery.cpp +++ b/examples/dom/style_gallery.cpp @@ -1,6 +1,10 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/style_inverted.cpp b/examples/dom/style_inverted.cpp index 9a19181..3712deb 100644 --- a/examples/dom/style_inverted.cpp +++ b/examples/dom/style_inverted.cpp @@ -1,6 +1,9 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/style_underlined.cpp b/examples/dom/style_underlined.cpp index dedf04a..52a8d7a 100644 --- a/examples/dom/style_underlined.cpp +++ b/examples/dom/style_underlined.cpp @@ -1,6 +1,9 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/vbox_hbox.cpp b/examples/dom/vbox_hbox.cpp index 92d23cd..65b55a8 100644 --- a/examples/dom/vbox_hbox.cpp +++ b/examples/dom/vbox_hbox.cpp @@ -1,6 +1,10 @@ +#include #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/dom/window.cpp b/examples/dom/window.cpp index df84561..ea2e917 100644 --- a/examples/dom/window.cpp +++ b/examples/dom/window.cpp @@ -1,6 +1,10 @@ #include #include -#include +#include + +#include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" int main(void) { using namespace ftxui; diff --git a/examples/util/print_key_press.cpp b/examples/util/print_key_press.cpp index 3ba9848..3f255b5 100644 --- a/examples/util/print_key_press.cpp +++ b/examples/util/print_key_press.cpp @@ -2,12 +2,18 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include -#include -#include -#include -#include -#include +#include // for size_t +#include // for max +#include // for Component +#include // for ScreenInteractive +#include // for allocator, operator+ +#include // for move +#include // for vector + +#include "ftxui/component/event.hpp" // for Event +#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::Left +#include "ftxui/dom/elements.hpp" // for text, vbox, window +#include "ftxui/screen/box.hpp" // for ftxui using namespace ftxui; @@ -57,8 +63,8 @@ std::wstring Stringify(Event event) { out += L"_meta"; out += L"(" + // - std::to_wstring(event.mouse().x) + L"," + - std::to_wstring(event.mouse().y) + L")"; + std::to_wstring(event.mouse().x) + L"," + + std::to_wstring(event.mouse().y) + L")"; } else { out += L"(special)"; } diff --git a/include/ftxui/component/button.hpp b/include/ftxui/component/button.hpp index 76e4186..e7b190c 100644 --- a/include/ftxui/component/button.hpp +++ b/include/ftxui/component/button.hpp @@ -2,10 +2,14 @@ #define FTXUI_COMPONENT_BUTTON_HPP #include +#include #include "ftxui/component/component.hpp" +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { +struct Event; /// @brief A button. An action is associated to the click event. /// @ingroup dom @@ -25,6 +29,7 @@ class Button : public Component { // Component implementation. Element Render() override; bool OnEvent(Event) override; + private: Box box_; }; diff --git a/include/ftxui/component/captured_mouse.hpp b/include/ftxui/component/captured_mouse.hpp index b76ac10..9c69a3a 100644 --- a/include/ftxui/component/captured_mouse.hpp +++ b/include/ftxui/component/captured_mouse.hpp @@ -12,3 +12,7 @@ using CapturedMouse = std::unique_ptr; } // namespace ftxui #endif /* end of include guard: FTXUI_CAPTURED_MOUSE_HPP */ + +// Copyright 2020 Arthur Sonzogni. All rights reserved. +// Use of this source code is governed by the MIT license that can be found in +// the LICENSE file. diff --git a/include/ftxui/component/checkbox.hpp b/include/ftxui/component/checkbox.hpp index f21121b..214ce52 100644 --- a/include/ftxui/component/checkbox.hpp +++ b/include/ftxui/component/checkbox.hpp @@ -1,11 +1,13 @@ #ifndef FTXUI_COMPONENT_CHECKBOX_HPP #define FTXUI_COMPONENT_CHECKBOX_HPP -#include +#include #include "ftxui/component/component.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { +struct Event; /// @brief A Checkbox. It can be checked or unchecked.Display an element on a /// ftxui::Screen. @@ -42,7 +44,6 @@ class CheckBox : public Component { int cursor_position = 0; Box box_; - }; } // namespace ftxui diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index 5a42216..9003f1c 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -1,14 +1,17 @@ #ifndef FTXUI_COMPONENT_COMPONENT_HPP #define FTXUI_COMPONENT_COMPONENT_HPP -#include -#include "ftxui/component/event.hpp" -#include "ftxui/dom/elements.hpp" +#include // for unique_ptr +#include // for vector + +#include "ftxui/component/captured_mouse.hpp" // for CaptureMouse +#include "ftxui/dom/elements.hpp" // for Element namespace ftxui { class Delegate; class Focus; +struct Event; /// @brief It implement rendering itself as ftxui::Element. It implement /// keyboard navigation by responding to ftxui::Event. @@ -53,6 +56,8 @@ class Component { void TakeFocus(); protected: + CapturedMouse CaptureMouse(const Event& event); + std::vector children_; private: diff --git a/include/ftxui/component/container.hpp b/include/ftxui/component/container.hpp index 03cee39..3f78798 100644 --- a/include/ftxui/component/container.hpp +++ b/include/ftxui/component/container.hpp @@ -2,6 +2,8 @@ #define FTXUI_COMPONENT_CONTAINER_HPP #include "ftxui/component/component.hpp" +#include "ftxui/component/event.hpp" +#include "ftxui/dom/elements.hpp" namespace ftxui { diff --git a/include/ftxui/component/event.hpp b/include/ftxui/component/event.hpp index 6295c91..7da613e 100644 --- a/include/ftxui/component/event.hpp +++ b/include/ftxui/component/event.hpp @@ -1,16 +1,14 @@ #ifndef FTXUI_COMPONENT_EVENT_HPP #define FTXUI_COMPONENT_EVENT_HPP -#include -#include -#include -#include -#include +#include // for Mouse +#include // for string, operator== #include namespace ftxui { class ScreenInteractive; +class Component; /// @brief Represent an event. It can be key press event, a terminal resize, or /// more ... @@ -53,7 +51,7 @@ struct Event { static Event Custom; //--- Method section --------------------------------------------------------- - bool is_character() const { return type_ == Type::Character;} + bool is_character() const { return type_ == Type::Character; } wchar_t character() const { return character_; } bool is_mouse() const { return type_ == Type::Mouse; } @@ -67,13 +65,12 @@ struct Event { const std::string& input() const { return input_; } - ScreenInteractive* screen() { return screen_; } - void SetScreen(ScreenInteractive* screen) { screen_ = screen; } - bool operator==(const Event& other) const { return input_ == other.input_; } //--- State section ---------------------------------------------------------- private: + friend Component; + friend ScreenInteractive; enum class Type { Unknown, Character, @@ -94,10 +91,9 @@ struct Event { }; std::string input_; - ScreenInteractive* screen_; + ScreenInteractive* screen_ = nullptr; }; - } // namespace ftxui #endif /* end of include guard: FTXUI_COMPONENT_EVENT_HPP */ diff --git a/include/ftxui/component/input.hpp b/include/ftxui/component/input.hpp index a55bd30..fedeacb 100644 --- a/include/ftxui/component/input.hpp +++ b/include/ftxui/component/input.hpp @@ -2,10 +2,14 @@ #define FTXUI_COMPONENT_INPUT_H_ #include +#include #include "ftxui/component/component.hpp" +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { +struct Event; /// @brief An input box. The user can type text into it. /// @ingroup component. diff --git a/include/ftxui/component/menu.hpp b/include/ftxui/component/menu.hpp index d621363..8e3f2b1 100644 --- a/include/ftxui/component/menu.hpp +++ b/include/ftxui/component/menu.hpp @@ -2,11 +2,15 @@ #define FTXUI_COMPONENT_MENU #include +#include +#include #include "ftxui/component/component.hpp" #include "ftxui/dom/elements.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { +struct Event; /// @brief A list of items. The user can navigate through them. /// @ingroup component diff --git a/include/ftxui/component/mouse.hpp b/include/ftxui/component/mouse.hpp index 54e80d4..aeeb490 100644 --- a/include/ftxui/component/mouse.hpp +++ b/include/ftxui/component/mouse.hpp @@ -1,3 +1,5 @@ +#ifndef FTXUI_COMPONENT_MOUSE_HPP +#define FTXUI_COMPONENT_MOUSE_HPP namespace ftxui { /// @brief A mouse event. It contains the coordinate of the mouse, the button @@ -39,3 +41,4 @@ struct Mouse { // Copyright 2020 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. +#endif /* end of include guard: FTXUI_COMPONENT_MOUSE_HPP */ diff --git a/include/ftxui/component/radiobox.hpp b/include/ftxui/component/radiobox.hpp index bbfc6f7..7493245 100644 --- a/include/ftxui/component/radiobox.hpp +++ b/include/ftxui/component/radiobox.hpp @@ -1,11 +1,15 @@ #ifndef FTXUI_COMPONENT_RADIOBOX_HPP #define FTXUI_COMPONENT_RADIOBOX_HPP -#include +#include +#include #include "ftxui/component/component.hpp" +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { +struct Event; /// @brief A list of selectable element. One and only one can be selected at /// the same time. diff --git a/include/ftxui/component/receiver.hpp b/include/ftxui/component/receiver.hpp index 7b85922..8b236c3 100644 --- a/include/ftxui/component/receiver.hpp +++ b/include/ftxui/component/receiver.hpp @@ -1,13 +1,13 @@ #ifndef FTXUI_COMPONENT_RECEIVER_HPP_ #define FTXUI_COMPONENT_RECEIVER_HPP_ -#include -#include +#include // for atomic +#include // for condition_variable #include #include -#include -#include -#include +#include // for unique_ptr, make_unique +#include // for mutex, unique_lock +#include // for queue namespace ftxui { @@ -38,6 +38,7 @@ namespace ftxui { // clang-format off template class SenderImpl; template class ReceiverImpl; + template using Sender = std::unique_ptr>; template using Receiver = std::unique_ptr>; template Receiver MakeReceiver(); diff --git a/include/ftxui/component/screen_interactive.hpp b/include/ftxui/component/screen_interactive.hpp index c61132c..c3a3251 100644 --- a/include/ftxui/component/screen_interactive.hpp +++ b/include/ftxui/component/screen_interactive.hpp @@ -1,20 +1,18 @@ #ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP #define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP -#include -#include +#include // for atomic #include -#include -#include -#include -#include +#include // for unique_ptr +#include // for string -#include "ftxui/component/captured_mouse.hpp" +#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse #include "ftxui/component/event.hpp" -#include "ftxui/screen/screen.hpp" +#include "ftxui/screen/screen.hpp" // for Screen namespace ftxui { class Component; +struct Event; class ScreenInteractive : public Screen { public: diff --git a/include/ftxui/component/slider.hpp b/include/ftxui/component/slider.hpp index f9bff71..6b30d42 100644 --- a/include/ftxui/component/slider.hpp +++ b/include/ftxui/component/slider.hpp @@ -11,13 +11,8 @@ namespace ftxui { // float max = 100.f, // float increment = (max - min) * 0.05f); -template // T = {int, float} -ComponentPtr Slider(std::wstring label, - T* value, - T min, - T max, - T increment); - +template // T = {int, float} +ComponentPtr Slider(std::wstring label, T* value, T min, T max, T increment); } // namespace ftxui diff --git a/include/ftxui/component/toggle.hpp b/include/ftxui/component/toggle.hpp index 8e9a3f6..bbdd1f1 100644 --- a/include/ftxui/component/toggle.hpp +++ b/include/ftxui/component/toggle.hpp @@ -1,12 +1,15 @@ #ifndef FTXUI_COMPONENT_TOGGLE_H_ #define FTXUI_COMPONENT_TOGGLE_H_ -#include #include +#include #include "ftxui/component/component.hpp" +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { +struct Event; /// @brief An horizontal list of elements. The user can navigate through them. /// @ingroup component diff --git a/include/ftxui/dom/elements.hpp b/include/ftxui/dom/elements.hpp index 614b1c1..073b783 100644 --- a/include/ftxui/dom/elements.hpp +++ b/include/ftxui/dom/elements.hpp @@ -78,7 +78,7 @@ enum Direction { WIDTH, HEIGHT }; enum Constraint { LESS_THAN, EQUAL, GREATER_THAN }; Decorator size(Direction, Constraint, int value); -// -- +// -- Decorator reflect(Box& box); // --- Frame --- diff --git a/include/ftxui/dom/node.hpp b/include/ftxui/dom/node.hpp index 7998da6..3ca5139 100644 --- a/include/ftxui/dom/node.hpp +++ b/include/ftxui/dom/node.hpp @@ -1,16 +1,18 @@ #ifndef FTXUI_DOM_NODE_HPP #define FTXUI_DOM_NODE_HPP -#include -#include +#include // for shared_ptr +#include // for vector -#include "ftxui/dom/requirement.hpp" -#include "ftxui/screen/box.hpp" +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box #include "ftxui/screen/screen.hpp" namespace ftxui { class Node; +class Screen; + using Element = std::shared_ptr; using Elements = std::vector>; diff --git a/include/ftxui/dom/take_any_args.hpp b/include/ftxui/dom/take_any_args.hpp index fecee23..3adf223 100644 --- a/include/ftxui/dom/take_any_args.hpp +++ b/include/ftxui/dom/take_any_args.hpp @@ -1,3 +1,4 @@ +// IWYU pragma: private, include "ftxui/dom/elements.hpp" #include template diff --git a/include/ftxui/screen/color.hpp b/include/ftxui/screen/color.hpp index 6bb0c19..e8edbcb 100644 --- a/include/ftxui/screen/color.hpp +++ b/include/ftxui/screen/color.hpp @@ -1,8 +1,8 @@ #ifndef FTXUI_SCREEN_COLOR #define FTXUI_SCREEN_COLOR -#include -#include +#include // for uint8_t +#include // for wstring #ifdef RGB // Workaround for wingdi.h (via Windows.h) defining macros that break things. diff --git a/include/ftxui/screen/color_info.hpp b/include/ftxui/screen/color_info.hpp index b3c64ca..5a35fc5 100644 --- a/include/ftxui/screen/color_info.hpp +++ b/include/ftxui/screen/color_info.hpp @@ -1,6 +1,7 @@ #ifndef FTXUI_SCREEN_COLOR_INFO_HPP #define FTXUI_SCREEN_COLOR_INFO_HPP +#include #include namespace ftxui { diff --git a/iwyu.imp b/iwyu.imp new file mode 100644 index 0000000..feaf961 --- /dev/null +++ b/iwyu.imp @@ -0,0 +1,8 @@ +[ + { symbol: [ "VMIN", private, "", public ] }, + { symbol: [ "VTIME", private, "", public ] }, + { symbol: [ "ECHO", private, "", public ] }, + { symbol: [ "ICANON", private, "", public ] }, + { symbol: [ "termios", private, "", public ] }, + { symbol: [ "TCSANOW", private, "", public ] }, +] diff --git a/src/ftxui/component/button.cpp b/src/ftxui/component/button.cpp index 3ea1b77..357b594 100644 --- a/src/ftxui/component/button.cpp +++ b/src/ftxui/component/button.cpp @@ -1,7 +1,11 @@ -#include "ftxui/component/button.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include // for function +#include // for shared_ptr -#include +#include "ftxui/component/button.hpp" +#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse +#include "ftxui/component/event.hpp" // for Event, Event::Return +#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::Left, Mouse::Pressed +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive namespace ftxui { @@ -12,7 +16,7 @@ Element Button::Render() { bool Button::OnEvent(Event event) { if (event.is_mouse() && box_.Contain(event.mouse().x, event.mouse().y)) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; TakeFocus(); diff --git a/src/ftxui/component/checkbox.cpp b/src/ftxui/component/checkbox.cpp index 8c04a08..a7382d8 100644 --- a/src/ftxui/component/checkbox.cpp +++ b/src/ftxui/component/checkbox.cpp @@ -1,7 +1,11 @@ -#include "ftxui/component/checkbox.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include // for function +#include // for shared_ptr -#include +#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse +#include "ftxui/component/checkbox.hpp" +#include "ftxui/component/event.hpp" // for Event, Event::Return +#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::Left, Mouse::Pressed +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive namespace ftxui { @@ -27,7 +31,7 @@ bool CheckBox::OnEvent(Event event) { } bool CheckBox::OnMouseEvent(Event event) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; if (!box_.Contain(event.mouse().x, event.mouse().y)) return false; diff --git a/src/ftxui/component/component.cpp b/src/ftxui/component/component.cpp index d89de45..875d759 100644 --- a/src/ftxui/component/component.cpp +++ b/src/ftxui/component/component.cpp @@ -1,11 +1,20 @@ #include "ftxui/component/component.hpp" -#include - #include +#include "ftxui/component/captured_mouse.hpp" +#include "ftxui/component/event.hpp" +#include "ftxui/component/screen_interactive.hpp" + namespace ftxui { +namespace { +class CaptureMouseImpl : public CapturedMouseInterface { + public: + ~CaptureMouseImpl() override {} +}; +} + Component::~Component() { Detach(); } @@ -97,6 +106,16 @@ void Component::TakeFocus() { } } +/// @brief Take the CapturedMouse if available. There is only one component of +/// them. It represents a component taking priority over others. +/// @argument event +/// @ingroup component +CapturedMouse Component::CaptureMouse(const Event& event) { + if (!event.screen_) + return std::make_unique(); + return event.screen_->CaptureMouse(); +} + /// @brief Detach this children from its parent. /// @see Attach /// @see Detach diff --git a/src/ftxui/component/container.cpp b/src/ftxui/component/container.cpp index 0fdd438..7c01a1d 100644 --- a/src/ftxui/component/container.cpp +++ b/src/ftxui/component/container.cpp @@ -1,6 +1,8 @@ #include "ftxui/component/container.hpp" +#include #include +#include namespace ftxui { diff --git a/src/ftxui/component/container_test.cpp b/src/ftxui/component/container_test.cpp index 86f36ae..da47638 100644 --- a/src/ftxui/component/container_test.cpp +++ b/src/ftxui/component/container_test.cpp @@ -1,6 +1,10 @@ -#include "ftxui/component/container.hpp" +#include // for Message +#include // for TestPartResult, SuiteApiResolver +#include // for allocator -#include "gtest/gtest.h" +#include "ftxui/component/container.hpp" +#include "ftxui/screen/box.hpp" // for ftxui +#include "gtest/gtest_pred_impl.h" // for AssertionResult, EXPECT_EQ, EXPEC... using namespace ftxui; diff --git a/src/ftxui/component/event.cpp b/src/ftxui/component/event.cpp index 2fa0cf0..b8bc436 100644 --- a/src/ftxui/component/event.cpp +++ b/src/ftxui/component/event.cpp @@ -1,6 +1,6 @@ #include "ftxui/component/event.hpp" -#include +#include "ftxui/component/mouse.hpp" #include "ftxui/screen/string.hpp" namespace ftxui { diff --git a/src/ftxui/component/input.cpp b/src/ftxui/component/input.cpp index d39ec1b..c9a9daa 100644 --- a/src/ftxui/component/input.cpp +++ b/src/ftxui/component/input.cpp @@ -1,9 +1,11 @@ #include "ftxui/component/input.hpp" -#include "ftxui/component/screen_interactive.hpp" #include +#include -#include "ftxui/screen/string.hpp" +#include "ftxui/component/captured_mouse.hpp" +#include "ftxui/component/mouse.hpp" +#include "ftxui/component/screen_interactive.hpp" namespace ftxui { @@ -103,7 +105,7 @@ bool Input::OnEvent(Event event) { } bool Input::OnMouseEvent(Event event) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; if (!input_box_.Contain(event.mouse().x, event.mouse().y)) return false; diff --git a/src/ftxui/component/menu.cpp b/src/ftxui/component/menu.cpp index 44f5f36..90b1987 100644 --- a/src/ftxui/component/menu.cpp +++ b/src/ftxui/component/menu.cpp @@ -1,8 +1,13 @@ #include "ftxui/component/menu.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include #include -#include +#include +#include + +#include "ftxui/component/captured_mouse.hpp" +#include "ftxui/component/mouse.hpp" +#include "ftxui/component/screen_interactive.hpp" namespace ftxui { @@ -28,7 +33,7 @@ Element Menu::Render() { } bool Menu::OnEvent(Event event) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; if (event.is_mouse()) return OnMouseEvent(event); @@ -63,7 +68,7 @@ bool Menu::OnEvent(Event event) { } bool Menu::OnMouseEvent(Event event) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; for (int i = 0; i < boxes_.size(); ++i) { if (!boxes_[i].Contain(event.mouse().x, event.mouse().y)) diff --git a/src/ftxui/component/radiobox.cpp b/src/ftxui/component/radiobox.cpp index 7c50655..4d6c00a 100644 --- a/src/ftxui/component/radiobox.cpp +++ b/src/ftxui/component/radiobox.cpp @@ -1,8 +1,14 @@ #include "ftxui/component/radiobox.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include #include #include +#include +#include + +#include "ftxui/component/captured_mouse.hpp" +#include "ftxui/component/mouse.hpp" +#include "ftxui/component/screen_interactive.hpp" namespace ftxui { @@ -13,8 +19,9 @@ Element RadioBox::Render() { for (size_t i = 0; i < entries.size(); ++i) { auto style = (focused == int(i) && is_focused) ? focused_style : unfocused_style; - auto focus_management = - (focused != int(i)) ? nothing : is_focused ? focus : select; + auto focus_management = (focused != int(i)) ? nothing + : is_focused ? focus + : select; const std::wstring& symbol = selected == int(i) ? checked : unchecked; elements.push_back(hbox(text(symbol), text(entries[i]) | style) | @@ -24,7 +31,7 @@ Element RadioBox::Render() { } bool RadioBox::OnEvent(Event event) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; if (event.is_mouse()) return OnMouseEvent(event); @@ -58,7 +65,7 @@ bool RadioBox::OnEvent(Event event) { } bool RadioBox::OnMouseEvent(Event event) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; for (int i = 0; i < boxes_.size(); ++i) { if (!boxes_[i].Contain(event.mouse().x, event.mouse().y)) diff --git a/src/ftxui/component/radiobox_test.cpp b/src/ftxui/component/radiobox_test.cpp index 8fd5c2d..845dac0 100644 --- a/src/ftxui/component/radiobox_test.cpp +++ b/src/ftxui/component/radiobox_test.cpp @@ -1,6 +1,10 @@ -#include "ftxui/component/radiobox.hpp" +#include // for Message +#include // for TestPartResult, SuiteApiResolver, TestFactoryImpl -#include "gtest/gtest.h" +#include "ftxui/component/event.hpp" // for Event, Event::ArrowDown, Event::ArrowUp, Event::Tab, Event::TabReverse +#include "ftxui/component/mouse.hpp" // for ftxui +#include "ftxui/component/radiobox.hpp" +#include "gtest/gtest_pred_impl.h" // for EXPECT_EQ, Test, TEST using namespace ftxui; diff --git a/src/ftxui/component/receiver_test.cpp b/src/ftxui/component/receiver_test.cpp index 8d06cc8..bd4e1cb 100644 --- a/src/ftxui/component/receiver_test.cpp +++ b/src/ftxui/component/receiver_test.cpp @@ -1,8 +1,10 @@ +#include // for Message +#include // for TestPartResult +#include // for thread +#include // for move + #include "ftxui/component/receiver.hpp" - -#include - -#include "gtest/gtest.h" +#include "gtest/gtest_pred_impl.h" // for AssertionResult, Test, EXPECT_EQ using namespace ftxui; diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index 95cc26c..48bd747 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -1,19 +1,24 @@ #include "ftxui/component/screen_interactive.hpp" -#include +#include // for fileno, stdin +#include // for copy, max, min +#include // for signal, SIGINT +#include // for exit, NULL +#include // for cout, ostream +#include // for stack +#include // for thread +#include // for move +#include // for vector -#include -#include -#include -#include -#include -#include - -#include "ftxui/component/captured_mouse.hpp" -#include "ftxui/component/component.hpp" -#include "ftxui/component/terminal_input_parser.hpp" -#include "ftxui/screen/string.hpp" -#include "ftxui/screen/terminal.hpp" +#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse +#include "ftxui/component/component.hpp" // for Component +#include "ftxui/component/event.hpp" // for Event +#include "ftxui/component/mouse.hpp" // for Mouse +#include "ftxui/component/receiver.hpp" // for ReceiverImpl +#include "ftxui/component/terminal_input_parser.hpp" // for TerminalInputPa... +#include "ftxui/dom/node.hpp" // for Node, Render +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/terminal.hpp" // for Terminal::Dimen... #if defined(_WIN32) #define DEFINE_CONSOLEV2_PROPERTIES @@ -26,8 +31,9 @@ #error Must be compiled in UNICODE mode #endif #else -#include -#include +#include // for select, FD_ISSET +#include // for tcsetattr, tcge... +#include // for STDIN_FILENO, read #endif // Quick exit is missing in standard CLang headers @@ -48,8 +54,7 @@ constexpr int timeout_milliseconds = 20; constexpr int timeout_microseconds = timeout_milliseconds * 1000; #if defined(_WIN32) -void EventListener(std::atomic* quit, - Sender out) { +void EventListener(std::atomic* quit, Sender out) { auto console = GetStdHandle(STD_INPUT_HANDLE); auto parser = TerminalInputParser(out->Clone()); while (!*quit) { @@ -69,8 +74,7 @@ void EventListener(std::atomic* quit, std::vector records{number_of_events}; DWORD number_of_events_read = 0; - ReadConsoleInput(console, records.data(), - (DWORD)records.size(), + ReadConsoleInput(console, records.data(), (DWORD)records.size(), &number_of_events_read); records.resize(number_of_events_read); @@ -106,7 +110,7 @@ void EventListener(std::atomic* quit, Sender out) { char c; while (!*quit) { - while(read(STDIN_FILENO, &c, 1), c) + while (read(STDIN_FILENO, &c, 1), c) parser.Add(c); emscripten_sleep(1); @@ -115,7 +119,7 @@ void EventListener(std::atomic* quit, Sender out) { } #else -#include +#include // for timeval int CheckStdinReady(int usec_timeout) { timeval tv = {0, usec_timeout}; @@ -219,8 +223,7 @@ void OnResize(int /* signal */) { class CapturedMouseImpl : public CapturedMouseInterface { public: - CapturedMouseImpl(std::function callback) - : callback_(callback) {} + CapturedMouseImpl(std::function callback) : callback_(callback) {} ~CapturedMouseImpl() override { callback_(); } private: @@ -366,7 +369,7 @@ void ScreenInteractive::Loop(Component* component) { }); enable({ - //DECMode::kMouseVt200, + // DECMode::kMouseVt200, DECMode::kMouseAnyEvent, DECMode::kMouseUtf8, DECMode::kMouseSgrExtMode, @@ -406,7 +409,7 @@ void ScreenInteractive::Loop(Component* component) { event.mouse().y -= cursor_y_; } - event.SetScreen(this); + event.screen_ = this; component->OnEvent(event); } diff --git a/src/ftxui/component/slider.cpp b/src/ftxui/component/slider.cpp index 8ddb4fb..122e523 100644 --- a/src/ftxui/component/slider.cpp +++ b/src/ftxui/component/slider.cpp @@ -1,10 +1,18 @@ #include "ftxui/component/slider.hpp" + +#include +#include + #include "ftxui/component/captured_mouse.hpp" +#include "ftxui/component/mouse.hpp" #include "ftxui/component/screen_interactive.hpp" +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" namespace ftxui { -template +template class SliderImpl : public Component { public: SliderImpl(std::wstring label, T* value, T min, T max, T increment) @@ -55,7 +63,7 @@ class SliderImpl : public Component { } if (box_.Contain(event.mouse().x, event.mouse().y) && - event.screen()->CaptureMouse()) { + CaptureMouse(event)) { TakeFocus(); } @@ -63,7 +71,7 @@ class SliderImpl : public Component { event.mouse().motion == Mouse::Pressed && gauge_box_.Contain(event.mouse().x, event.mouse().y) && !captured_mouse_) { - captured_mouse_ = event.screen()->CaptureMouse(); + captured_mouse_ = CaptureMouse(event); } if (captured_mouse_) { @@ -105,3 +113,7 @@ template ComponentPtr Slider(std::wstring label, float increment); } // namespace ftxui + +// Copyright 2020 Arthur Sonzogni. All rights reserved. +// Use of this source code is governed by the MIT license that can be found in +// the LICENSE file. diff --git a/src/ftxui/component/terminal_input_parser.cpp b/src/ftxui/component/terminal_input_parser.cpp index b86d583..acab8e4 100644 --- a/src/ftxui/component/terminal_input_parser.cpp +++ b/src/ftxui/component/terminal_input_parser.cpp @@ -1,5 +1,8 @@ #include "ftxui/component/terminal_input_parser.hpp" +#include +#include "ftxui/component/event.hpp" + namespace ftxui { TerminalInputParser::TerminalInputParser(Sender out) @@ -61,7 +64,6 @@ void TerminalInputParser::Send(TerminalInputParser::Output output) { return; } // NOT_REACHED(). - } TerminalInputParser::Output TerminalInputParser::Parse() { @@ -227,3 +229,7 @@ TerminalInputParser::Output TerminalInputParser::ParseCursorReporting( } } // namespace ftxui + +// Copyright 2020 Arthur Sonzogni. All rights reserved. +// Use of this source code is governed by the MIT license that can be found in +// the LICENSE file. diff --git a/src/ftxui/component/terminal_input_parser.hpp b/src/ftxui/component/terminal_input_parser.hpp index d378694..69645a6 100644 --- a/src/ftxui/component/terminal_input_parser.hpp +++ b/src/ftxui/component/terminal_input_parser.hpp @@ -1,10 +1,13 @@ #ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER #define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER -#include "ftxui/component/event.hpp" -#include "ftxui/component/receiver.hpp" +#include // for unique_ptr +#include // for string +#include // for vector -#include +#include "ftxui/component/event.hpp" // IWYU pragma: keep +#include "ftxui/component/mouse.hpp" // for Mouse +#include "ftxui/component/receiver.hpp" // for SenderImpl namespace ftxui { diff --git a/src/ftxui/component/terminal_input_parser_test.cpp b/src/ftxui/component/terminal_input_parser_test.cpp index 6212a1c..b37b216 100644 --- a/src/ftxui/component/terminal_input_parser_test.cpp +++ b/src/ftxui/component/terminal_input_parser_test.cpp @@ -1,7 +1,9 @@ -#include "ftxui/component/terminal_input_parser.hpp" -#include "ftxui/component/receiver.hpp" +#include // for Message +#include // for TestPartResult -#include "gtest/gtest.h" +#include "ftxui/component/receiver.hpp" // for MakeReceiver, ReceiverImpl +#include "ftxui/component/terminal_input_parser.hpp" +#include "gtest/gtest_pred_impl.h" // for AssertionResult, Test, Suite... using namespace ftxui; diff --git a/src/ftxui/component/toggle.cpp b/src/ftxui/component/toggle.cpp index 8936096..ca06461 100644 --- a/src/ftxui/component/toggle.cpp +++ b/src/ftxui/component/toggle.cpp @@ -1,7 +1,12 @@ -#include "ftxui/component/toggle.hpp" -#include "ftxui/component/screen_interactive.hpp" +#include // for size_t +#include // for max, min +#include // for shared_ptr, alloca... +#include // for move -#include +#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse +#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::Left +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/component/toggle.hpp" namespace ftxui { @@ -60,7 +65,7 @@ bool Toggle::OnEvent(Event event) { } bool Toggle::OnMouseEvent(Event event) { - if (!event.screen()->CaptureMouse()) + if (!CaptureMouse(event)) return false; for (int i = 0; i < boxes_.size(); ++i) { if (!boxes_[i].Contain(event.mouse().x, event.mouse().y)) diff --git a/src/ftxui/component/toggle_test.cpp b/src/ftxui/component/toggle_test.cpp index acb19ef..4842d2c 100644 --- a/src/ftxui/component/toggle_test.cpp +++ b/src/ftxui/component/toggle_test.cpp @@ -1,6 +1,10 @@ -#include "ftxui/component/toggle.hpp" +#include // for Message +#include // for TestPartResult, SuiteApiResolver, TestFactoryImpl -#include "gtest/gtest.h" +#include "ftxui/component/event.hpp" // for Event, Event::ArrowLeft, Event::ArrowRight, Event::Return, Event::Tab, Event::TabReverse +#include "ftxui/component/mouse.hpp" // for ftxui +#include "ftxui/component/toggle.hpp" +#include "gtest/gtest_pred_impl.h" // for AssertionResult, EXPECT_EQ, Test, EXPECT_TRUE, EXPECT_FALSE, TEST using namespace ftxui; diff --git a/src/ftxui/dom/blink.cpp b/src/ftxui/dom/blink.cpp index 8356d83..57a3a23 100644 --- a/src/ftxui/dom/blink.cpp +++ b/src/ftxui/dom/blink.cpp @@ -1,5 +1,10 @@ +#include + #include "ftxui/dom/elements.hpp" +#include "ftxui/dom/node.hpp" #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/bold.cpp b/src/ftxui/dom/bold.cpp index f959e81..1d5c3c7 100644 --- a/src/ftxui/dom/bold.cpp +++ b/src/ftxui/dom/bold.cpp @@ -1,5 +1,10 @@ +#include + #include "ftxui/dom/elements.hpp" +#include "ftxui/dom/node.hpp" #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/border.cpp b/src/ftxui/dom/border.cpp index 2d14637..a7ce81c 100644 --- a/src/ftxui/dom/border.cpp +++ b/src/ftxui/dom/border.cpp @@ -1,7 +1,14 @@ -#include +#include // for max +#include // for begin, end +#include // for make_shared, __shared_ptr_access +#include // for move +#include // for vector -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" +#include "ftxui/dom/elements.hpp" // for unpack, Element, Decorator, Elements, border, borderWith, window +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box +#include "ftxui/screen/screen.hpp" // for Pixel, Screen namespace ftxui { diff --git a/src/ftxui/dom/clear_under.cpp b/src/ftxui/dom/clear_under.cpp index da0c600..23fb36c 100644 --- a/src/ftxui/dom/clear_under.cpp +++ b/src/ftxui/dom/clear_under.cpp @@ -1,5 +1,10 @@ +#include + #include "ftxui/dom/elements.hpp" +#include "ftxui/dom/node.hpp" #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/color.cpp b/src/ftxui/dom/color.cpp index 023dc8f..475d978 100644 --- a/src/ftxui/dom/color.cpp +++ b/src/ftxui/dom/color.cpp @@ -1,5 +1,10 @@ +#include + #include "ftxui/dom/elements.hpp" #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/color.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/composite_decorator.cpp b/src/ftxui/dom/composite_decorator.cpp index c818327..007057c 100644 --- a/src/ftxui/dom/composite_decorator.cpp +++ b/src/ftxui/dom/composite_decorator.cpp @@ -1,5 +1,5 @@ + #include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" namespace ftxui { diff --git a/src/ftxui/dom/dbox.cpp b/src/ftxui/dom/dbox.cpp index ea73791..e39283b 100644 --- a/src/ftxui/dom/dbox.cpp +++ b/src/ftxui/dom/dbox.cpp @@ -1,7 +1,12 @@ -#include +#include // for max +#include // for __shared_ptr_access, shared_ptr, make_shared +#include // for move +#include // for vector -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" +#include "ftxui/dom/elements.hpp" // for Element, Elements, dbox +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box namespace ftxui { diff --git a/src/ftxui/dom/dim.cpp b/src/ftxui/dom/dim.cpp index 7b6b68a..296ea1d 100644 --- a/src/ftxui/dom/dim.cpp +++ b/src/ftxui/dom/dim.cpp @@ -1,5 +1,10 @@ +#include + #include "ftxui/dom/elements.hpp" +#include "ftxui/dom/node.hpp" #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/flex.cpp b/src/ftxui/dom/flex.cpp index bf2942e..303481c 100644 --- a/src/ftxui/dom/flex.cpp +++ b/src/ftxui/dom/flex.cpp @@ -1,5 +1,10 @@ +#include +#include + #include "ftxui/dom/elements.hpp" #include "ftxui/dom/node.hpp" +#include "ftxui/dom/requirement.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { diff --git a/src/ftxui/dom/frame.cpp b/src/ftxui/dom/frame.cpp index 7e25c8c..05f3ea9 100644 --- a/src/ftxui/dom/frame.cpp +++ b/src/ftxui/dom/frame.cpp @@ -1,8 +1,14 @@ -#include +#include // for max, min +#include // for make_shared, shared_ptr, __shared_ptr_access +#include // for move +#include // for vector -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" -#include "ftxui/util/autoreset.hpp" +#include "ftxui/dom/elements.hpp" // for Element, unpack, focus, frame, select, xframe, yframe +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement, Requirement::FOCUSED, Requirement::SELECTED +#include "ftxui/screen/box.hpp" // for Box +#include "ftxui/screen/screen.hpp" // for Screen, Screen::Cursor +#include "ftxui/util/autoreset.hpp" // for AutoReset namespace ftxui { diff --git a/src/ftxui/dom/gauge.cpp b/src/ftxui/dom/gauge.cpp index d448036..fe45c4b 100644 --- a/src/ftxui/dom/gauge.cpp +++ b/src/ftxui/dom/gauge.cpp @@ -1,5 +1,9 @@ +#include + #include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" +#include "ftxui/dom/requirement.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/gauge_test.cpp b/src/ftxui/dom/gauge_test.cpp index 1056396..0eb3275 100644 --- a/src/ftxui/dom/gauge_test.cpp +++ b/src/ftxui/dom/gauge_test.cpp @@ -1,6 +1,12 @@ -#include "ftxui/dom/elements.hpp" -#include "ftxui/screen/screen.hpp" -#include "gtest/gtest.h" +#include // for Message +#include // for TestPartResult +#include // for allocator + +#include "ftxui/dom/elements.hpp" // for gauge +#include "ftxui/dom/node.hpp" // for Render +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/screen.hpp" // for Screen +#include "gtest/gtest_pred_impl.h" // for Test, SuiteApiResolver, EXPECT_EQ using namespace ftxui; using namespace ftxui; diff --git a/src/ftxui/dom/graph.cpp b/src/ftxui/dom/graph.cpp index 67f0cd3..4261bde 100644 --- a/src/ftxui/dom/graph.cpp +++ b/src/ftxui/dom/graph.cpp @@ -1,4 +1,12 @@ -#include "ftxui/dom/elements.hpp" +#include // for function +#include // for make_shared +#include // for vector + +#include "ftxui/dom/elements.hpp" // for GraphFunction, Element, graph +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box +#include "ftxui/screen/screen.hpp" // for Screen namespace ftxui { diff --git a/src/ftxui/dom/hbox.cpp b/src/ftxui/dom/hbox.cpp index 3ff91e0..43757e6 100644 --- a/src/ftxui/dom/hbox.cpp +++ b/src/ftxui/dom/hbox.cpp @@ -1,7 +1,12 @@ -#include +#include // for max +#include // for __shared_ptr_access, shared_ptr, make_shared +#include // for move +#include // for vector -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" +#include "ftxui/dom/elements.hpp" // for Element, Elements, hbox +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box namespace ftxui { diff --git a/src/ftxui/dom/hbox_test.cpp b/src/ftxui/dom/hbox_test.cpp index dbeac3a..fc5ca6c 100644 --- a/src/ftxui/dom/hbox_test.cpp +++ b/src/ftxui/dom/hbox_test.cpp @@ -1,6 +1,13 @@ -#include "ftxui/dom/elements.hpp" -#include "ftxui/screen/screen.hpp" -#include "gtest/gtest.h" +#include // for Message +#include // for TestPartResult +#include // for allocator, basic_string, string +#include // for vector + +#include "ftxui/dom/elements.hpp" // for text, operator|, Element, flex_grow +#include "ftxui/dom/node.hpp" // for Render +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/screen.hpp" // for Screen +#include "gtest/gtest_pred_impl.h" // for Test, SuiteApiResolver, EXPECT_EQ using namespace ftxui; using namespace ftxui; diff --git a/src/ftxui/dom/hflow.cpp b/src/ftxui/dom/hflow.cpp index ee6ff04..eb20233 100644 --- a/src/ftxui/dom/hflow.cpp +++ b/src/ftxui/dom/hflow.cpp @@ -1,7 +1,12 @@ -#include +#include // for max +#include // for __shared_ptr_access, make_shared, shared_ptr +#include // for move +#include // for vector -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" +#include "ftxui/dom/elements.hpp" // for Element, Elements, hflow +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box namespace ftxui { diff --git a/src/ftxui/dom/inverted.cpp b/src/ftxui/dom/inverted.cpp index 1054990..c859546 100644 --- a/src/ftxui/dom/inverted.cpp +++ b/src/ftxui/dom/inverted.cpp @@ -1,5 +1,10 @@ +#include +#include + #include "ftxui/dom/elements.hpp" #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/node.cpp b/src/ftxui/dom/node.cpp index d5f08c7..9ed078b 100644 --- a/src/ftxui/dom/node.cpp +++ b/src/ftxui/dom/node.cpp @@ -1,4 +1,7 @@ +#include + #include "ftxui/dom/node.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/node_decorator.cpp b/src/ftxui/dom/node_decorator.cpp index db5c39a..b98c2c2 100644 --- a/src/ftxui/dom/node_decorator.cpp +++ b/src/ftxui/dom/node_decorator.cpp @@ -1,4 +1,9 @@ +#include // for __shared_ptr_access +#include // for vector + #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box namespace ftxui { diff --git a/src/ftxui/dom/node_decorator.hpp b/src/ftxui/dom/node_decorator.hpp index 0336b04..a9f1d4f 100644 --- a/src/ftxui/dom/node_decorator.hpp +++ b/src/ftxui/dom/node_decorator.hpp @@ -1,9 +1,12 @@ #ifndef FTXUI_DOM_NODE_DECORATOR_H_ #define FTXUI_DOM_NODE_DECORATOR_H_ -#include "ftxui/dom/node.hpp" +#include // for move + +#include "ftxui/dom/node.hpp" // for Node, Elements namespace ftxui { +struct Box; // Helper class. class NodeDecorator : public Node { diff --git a/src/ftxui/dom/paragraph.cpp b/src/ftxui/dom/paragraph.cpp index 7a8a8e7..a90c18d 100644 --- a/src/ftxui/dom/paragraph.cpp +++ b/src/ftxui/dom/paragraph.cpp @@ -1,4 +1,5 @@ #include +#include #include "ftxui/dom/elements.hpp" diff --git a/src/ftxui/dom/reflect.cpp b/src/ftxui/dom/reflect.cpp index 0ce40e4..79998ad 100644 --- a/src/ftxui/dom/reflect.cpp +++ b/src/ftxui/dom/reflect.cpp @@ -1,7 +1,11 @@ #include +#include +#include + #include "ftxui/dom/elements.hpp" #include "ftxui/dom/node.hpp" -#include "ftxui/dom/node_decorator.hpp" +#include "ftxui/dom/requirement.hpp" +#include "ftxui/screen/box.hpp" namespace ftxui { diff --git a/src/ftxui/dom/separator.cpp b/src/ftxui/dom/separator.cpp index 0997d6e..243249d 100644 --- a/src/ftxui/dom/separator.cpp +++ b/src/ftxui/dom/separator.cpp @@ -1,5 +1,9 @@ +#include + #include "ftxui/dom/elements.hpp" #include "ftxui/dom/node.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/size.cpp b/src/ftxui/dom/size.cpp index 5bb4cb4..f5621b6 100644 --- a/src/ftxui/dom/size.cpp +++ b/src/ftxui/dom/size.cpp @@ -1,7 +1,13 @@ -#include +#include // for size_t +#include // for min, max +#include // for make_shared, __shared_ptr_access +#include // for move +#include // for vector -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" +#include "ftxui/dom/elements.hpp" // for Constraint, Direction, EQUAL, GREATER_THAN, LESS_THAN, WIDTH, unpack, Decorator, Element, size +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box namespace ftxui { diff --git a/src/ftxui/dom/spinner.cpp b/src/ftxui/dom/spinner.cpp index 24ea38b..e415acc 100644 --- a/src/ftxui/dom/spinner.cpp +++ b/src/ftxui/dom/spinner.cpp @@ -1,5 +1,9 @@ +#include +#include +#include +#include + #include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" namespace ftxui { diff --git a/src/ftxui/dom/text.cpp b/src/ftxui/dom/text.cpp index 0a30f7d..a8ade9a 100644 --- a/src/ftxui/dom/text.cpp +++ b/src/ftxui/dom/text.cpp @@ -1,7 +1,13 @@ -#include -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" -#include "ftxui/screen/string.hpp" +#include // for max +#include // for make_shared +#include // for wstring + +#include "ftxui/dom/elements.hpp" // for Element, text, vtext +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box +#include "ftxui/screen/screen.hpp" // for Screen +#include "ftxui/screen/string.hpp" // for wchar_width, wstring_width namespace ftxui { diff --git a/src/ftxui/dom/text_test.cpp b/src/ftxui/dom/text_test.cpp index 34fe2a5..a1a5551 100644 --- a/src/ftxui/dom/text_test.cpp +++ b/src/ftxui/dom/text_test.cpp @@ -1,8 +1,12 @@ -#include "ftxui/dom/elements.hpp" -#include "ftxui/screen/screen.hpp" -#include "gtest/gtest.h" +#include // for Message +#include // for TestPartResult +#include // for allocator + +#include "ftxui/dom/elements.hpp" // for text, Element, operator|, border +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/screen.hpp" // for Screen +#include "gtest/gtest_pred_impl.h" // for Test, SuiteApiResolver, EXPECT_EQ -using namespace ftxui; using namespace ftxui; TEST(TextTest, ScreenHeightSmaller) { diff --git a/src/ftxui/dom/underlined.cpp b/src/ftxui/dom/underlined.cpp index b04a110..7a3a50f 100644 --- a/src/ftxui/dom/underlined.cpp +++ b/src/ftxui/dom/underlined.cpp @@ -1,5 +1,10 @@ +#include +#include + #include "ftxui/dom/elements.hpp" #include "ftxui/dom/node_decorator.hpp" +#include "ftxui/screen/box.hpp" +#include "ftxui/screen/screen.hpp" namespace ftxui { diff --git a/src/ftxui/dom/util.cpp b/src/ftxui/dom/util.cpp index bc86b1b..1770611 100644 --- a/src/ftxui/dom/util.cpp +++ b/src/ftxui/dom/util.cpp @@ -1,4 +1,7 @@ -#include "ftxui/dom/elements.hpp" +#include // for function +#include // for move + +#include "ftxui/dom/elements.hpp" // for Decorator, Element, Elements, operator|, nothing namespace ftxui { diff --git a/src/ftxui/dom/vbox.cpp b/src/ftxui/dom/vbox.cpp index e514ae0..0686498 100644 --- a/src/ftxui/dom/vbox.cpp +++ b/src/ftxui/dom/vbox.cpp @@ -1,8 +1,12 @@ -#include -#include +#include // for max +#include // for __shared_ptr_access, shared_ptr, make_shared +#include // for move +#include // for vector -#include "ftxui/dom/elements.hpp" -#include "ftxui/dom/node.hpp" +#include "ftxui/dom/elements.hpp" // for Element, Elements, vbox +#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/box.hpp" // for Box namespace ftxui { diff --git a/src/ftxui/dom/vbox_test.cpp b/src/ftxui/dom/vbox_test.cpp index 917afd9..19aa8b9 100644 --- a/src/ftxui/dom/vbox_test.cpp +++ b/src/ftxui/dom/vbox_test.cpp @@ -1,6 +1,14 @@ -#include "ftxui/dom/elements.hpp" -#include "ftxui/screen/screen.hpp" -#include "gtest/gtest.h" +#include // for Message +#include // for TestPartResult +#include // for remove +#include // for allocator, basic_string, string +#include // for vector + +#include "ftxui/dom/elements.hpp" // for vtext, operator|, Element, flex_grow +#include "ftxui/dom/node.hpp" // for Render +#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/screen/screen.hpp" // for Screen +#include "gtest/gtest_pred_impl.h" // for Test, SuiteApiResolver, EXPECT_EQ using namespace ftxui; using namespace ftxui; diff --git a/src/ftxui/screen/color.cpp b/src/ftxui/screen/color.cpp index e71547e..ca2a459 100644 --- a/src/ftxui/screen/color.cpp +++ b/src/ftxui/screen/color.cpp @@ -1,7 +1,4 @@ #include "ftxui/screen/color.hpp" - -#include - #include "ftxui/screen/color_info.hpp" #include "ftxui/screen/string.hpp" #include "ftxui/screen/terminal.hpp" diff --git a/src/ftxui/screen/color_info.cpp b/src/ftxui/screen/color_info.cpp index 2a12a2f..a630011 100644 --- a/src/ftxui/screen/color_info.cpp +++ b/src/ftxui/screen/color_info.cpp @@ -1,4 +1,5 @@ #include "ftxui/screen/color_info.hpp" +#include "ftxui/screen/color.hpp" // for Color, Color::Palette16, Color::Palette256 namespace ftxui { diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index 3485ee6..5a3dbd1 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -1,12 +1,12 @@ +#include // for min +#include // for operator<<, basic_ostream, wstringstream, stringstream, flush, cout, ostream +#include // IWYU pragma: keep + +#include "ftxui/dom/node.hpp" // for Element, Node +#include "ftxui/dom/requirement.hpp" // for Requirement #include "ftxui/screen/screen.hpp" - -#include -#include -#include - -#include "ftxui/dom/node.hpp" -#include "ftxui/screen/string.hpp" -#include "ftxui/screen/terminal.hpp" +#include "ftxui/screen/string.hpp" // for to_string, wchar_width +#include "ftxui/screen/terminal.hpp" // for Terminal::Dimensions, Terminal #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN @@ -169,9 +169,9 @@ std::string Screen::ToString() { auto width = wchar_width(c); if (width <= 0) { - // Avoid an infinite loop for non-printable characters - c = L' '; - width = 1; + // Avoid an infinite loop for non-printable characters + c = L' '; + width = 1; } ss << c; x += width; diff --git a/src/ftxui/screen/terminal.cpp b/src/ftxui/screen/terminal.cpp index e86c82d..7e20220 100644 --- a/src/ftxui/screen/terminal.cpp +++ b/src/ftxui/screen/terminal.cpp @@ -1,20 +1,17 @@ +#include // for getenv +#include // for string, allocator + #include "ftxui/screen/terminal.hpp" -#include - -#include - #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include #else -#include -#include +#include // for winsize, ioctl, TIOCGWINSZ +#include // for STDOUT_FILENO #endif -#include - namespace ftxui { Terminal::Dimensions Terminal::Size() { diff --git a/src/ftxui/screen/wcwidth.cpp b/src/ftxui/screen/wcwidth.cpp index 6d3bcdb..7791a3e 100644 --- a/src/ftxui/screen/wcwidth.cpp +++ b/src/ftxui/screen/wcwidth.cpp @@ -59,7 +59,7 @@ * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c */ -#include +#include #include "ftxui/screen/string.hpp" diff --git a/tools/iwyu.sh b/tools/iwyu.sh new file mode 100755 index 0000000..1e1f62b --- /dev/null +++ b/tools/iwyu.sh @@ -0,0 +1,11 @@ +#!/bin/bash +cd "$(dirname "$0")" +cd .. +mapping_dir=$(pwd) +mkdir -p iwyu +cd iwyu +rm * -rf +echo $CMAKE_CXX_INCLUDE_WHAT_YOU_USE +cmake .. -DFTXUI_BUILD_TESTS=ON -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="iwyu;-Xiwyu;--cxx17ns;-Xiwyu;--mapping_file=${mapping_dir}/iwyu.imp;-Xiwyu;--verbose=3" +make -j 2>out +fix_include --comments < out