From c8ec151154deb124f1900df8fe5a2824c19836f1 Mon Sep 17 00:00:00 2001 From: Arthur Sonzogni Date: Sat, 3 Sep 2022 12:12:59 +0200 Subject: [PATCH] Bring back C++17 minimal requirement. (#475) --- cmake/ftxui_set_options.cmake | 1 - cmake/ftxui_test.cmake | 1 + codecov.yml | 2 +- examples/component/slider_direction.cpp | 22 ++++++++++--- include/ftxui/screen/screen.hpp | 2 +- src/ftxui/component/animation.cpp | 1 - src/ftxui/component/radiobox.cpp | 3 +- src/ftxui/component/screen_interactive.cpp | 5 ++- src/ftxui/component/slider.cpp | 36 +++++++++++----------- src/ftxui/screen/color.cpp | 2 +- 10 files changed, 42 insertions(+), 33 deletions(-) diff --git a/cmake/ftxui_set_options.cmake b/cmake/ftxui_set_options.cmake index 6fd7baf..b274df3 100644 --- a/cmake/ftxui_set_options.cmake +++ b/cmake/ftxui_set_options.cmake @@ -9,7 +9,6 @@ endif() function(ftxui_set_options library) set_target_properties(${library} PROPERTIES VERSION ${PROJECT_VERSION} - CXX_STANDARD 20 OUTPUT_NAME "ftxui-${library}" ) diff --git a/cmake/ftxui_test.cmake b/cmake/ftxui_test.cmake index 5aabb2c..0382e6a 100644 --- a/cmake/ftxui_test.cmake +++ b/cmake/ftxui_test.cmake @@ -71,6 +71,7 @@ target_include_directories(tests PRIVATE src ) ftxui_set_options(tests) +target_compile_features(tests PUBLIC cxx_std_20) include(GoogleTest) gtest_discover_tests(tests diff --git a/codecov.yml b/codecov.yml index 6daa6cc..e4cf1fc 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,7 +1,7 @@ codecov: require_ci_to_pass: no notify: - after_n_builds: 3 + after_n_builds: 4 wait_for_ci: yes coverage: diff --git a/examples/component/slider_direction.cpp b/examples/component/slider_direction.cpp index 1a0a390..69a0044 100644 --- a/examples/component/slider_direction.cpp +++ b/examples/component/slider_direction.cpp @@ -1,8 +1,10 @@ -#include // for array -#include // for sin -#include // for ComponentBase -#include // for size, GaugeDirection, GaugeDirection::Up, GREATER_THAN, HEIGHT -#include // for shared_ptr, __shared_ptr_access +#include // for array +#include // for sin +#include // for ComponentBase +#include // for SliderOption +#include // for size, GREATER_THAN, GaugeDirection, GaugeDirection::Up, HEIGHT +#include // for ConstRef, Ref +#include // for shared_ptr, __shared_ptr_access #include "ftxui/component/captured_mouse.hpp" // for ftxui #include "ftxui/component/component.hpp" // for Horizontal, Slider, operator|= @@ -19,12 +21,22 @@ int main(int argc, const char* argv[]) { auto layout_horizontal = Container::Horizontal({}); for (int i = 0; i < values.size(); ++i) { + // In C++17: + SliderOption option; + option.value = &values[i]; + option.max = 100; + option.increment = 5; + option.direction = GaugeDirection::Up; + layout_horizontal->Add(Slider(option)); + + /* In C++20: layout_horizontal->Add(Slider({ .value = &values[i], .max = 100, .increment = 5, .direction = GaugeDirection::Up, })); + */ } layout_horizontal |= size(HEIGHT, GREATER_THAN, 20); diff --git a/include/ftxui/screen/screen.hpp b/include/ftxui/screen/screen.hpp index 6ca7e5a..21eb377 100644 --- a/include/ftxui/screen/screen.hpp +++ b/include/ftxui/screen/screen.hpp @@ -2,7 +2,7 @@ #define FTXUI_SCREEN_SCREEN_HPP #include -#include // for allocator, string, basic_string +#include // for string, allocator, basic_string #include // for vector #include "ftxui/screen/box.hpp" // for Box diff --git a/src/ftxui/component/animation.cpp b/src/ftxui/component/animation.cpp index db904ba..bba5783 100644 --- a/src/ftxui/component/animation.cpp +++ b/src/ftxui/component/animation.cpp @@ -1,5 +1,4 @@ #include // IWYU pragma: keep -#include // for operator<=, operator>=, partial_ordering #include // for ratio #include // for move diff --git a/src/ftxui/component/radiobox.cpp b/src/ftxui/component/radiobox.cpp index b7b0ff7..d55f2ed 100644 --- a/src/ftxui/component/radiobox.cpp +++ b/src/ftxui/component/radiobox.cpp @@ -26,8 +26,7 @@ class RadioboxBase : public ComponentBase { RadioboxBase(ConstStringListRef entries, int* selected, Ref option) - : entries_(entries), selected_(selected), option_(std::move(option)) { - } + : entries_(entries), selected_(selected), option_(std::move(option)) {} private: Element Render() override { diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index e506f13..9248dea 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -1,7 +1,6 @@ -#include // for min +#include // for copy, max, min #include // for array -#include // for operator-, milliseconds, duration, operator<=>, time_point, common_type<>::type -#include // for operator>=, strong_ordering +#include // for operator-, milliseconds, duration, operator>=, time_point, common_type<>::type #include // for signal, raise, SIGTSTP, SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM, SIGWINCH #include // for fileno, size_t, stdin #include // for Task, Closure, AnimationTask diff --git a/src/ftxui/component/slider.cpp b/src/ftxui/component/slider.cpp index 5312751..6216551 100644 --- a/src/ftxui/component/slider.cpp +++ b/src/ftxui/component/slider.cpp @@ -266,12 +266,12 @@ Component Slider(ConstStringRef label, ConstRef min, ConstRef max, ConstRef increment) { - auto slider = Make>(SliderOption({ - .value = value, - .min = min, - .max = max, - .increment = increment, - })); + SliderOption option; + option.value = value; + option.min = min; + option.max = max; + option.increment = increment; + auto slider = Make>(option); return Make(label, slider); } @@ -280,12 +280,12 @@ Component Slider(ConstStringRef label, ConstRef min, ConstRef max, ConstRef increment) { - auto slider = Make>(SliderOption({ - .value = value, - .min = min, - .max = max, - .increment = increment, - })); + SliderOption option; + option.value = value; + option.min = min; + option.max = max; + option.increment = increment; + auto slider = Make>(option); return Make(label, slider); } Component Slider(ConstStringRef label, @@ -293,12 +293,12 @@ Component Slider(ConstStringRef label, ConstRef min, ConstRef max, ConstRef increment) { - auto slider = Make>(SliderOption({ - .value = value, - .min = min, - .max = max, - .increment = increment, - })); + SliderOption option; + option.value = value; + option.min = min; + option.max = max; + option.increment = increment; + auto slider = Make>(option); return Make(label, slider); } diff --git a/src/ftxui/screen/color.cpp b/src/ftxui/screen/color.cpp index d8b3cd0..490246d 100644 --- a/src/ftxui/screen/color.cpp +++ b/src/ftxui/screen/color.cpp @@ -145,7 +145,7 @@ Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) { // static Color Color::HSV(uint8_t h, uint8_t s, uint8_t v) { if (s == 0) { - return {0,0,0}; + return {0, 0, 0}; } uint8_t region = h / 43; // NOLINT