diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index 679cd1b..0a8df02 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -67,9 +67,8 @@ Component Radiobox(ConstStringListRef entries, Ref option = {}); Component Toggle(ConstStringListRef entries, int* selected); - // General slider constructor: -template +template Component Slider(SliderOption options = {}); // Shorthand without the `SliderOption` constructor: diff --git a/include/ftxui/screen/screen.hpp b/include/ftxui/screen/screen.hpp index d8a5329..b6e82fc 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 string, allocator, basic_string +#include // for allocator, string, 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 6938602..1a0a501 100644 --- a/src/ftxui/component/animation.cpp +++ b/src/ftxui/component/animation.cpp @@ -1,4 +1,5 @@ -#include // IWYU pragma: keep +#include // for sin, pow, sqrt, cos +#include // for operator<=, operator>=, partial_ordering #include // for ratio #include // for move diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index b77cab2..f9db0a4 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -1,6 +1,7 @@ #include // for copy, max, min #include // for array -#include // for operator-, milliseconds, operator>=, duration, common_type<>::type, time_point +#include // for operator-, milliseconds, operator<=>, duration, common_type<>::type, time_point +#include // for operator>=, strong_ordering #include // for signal, SIGTSTP, SIGABRT, SIGWINCH, raise, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM, __sighandler_t, size_t #include // for fileno, stdin #include // for Task, Closure, AnimationTask @@ -26,8 +27,7 @@ #include "ftxui/component/terminal_input_parser.hpp" // for TerminalInputParser #include "ftxui/dom/node.hpp" // for Node, Render #include "ftxui/dom/requirement.hpp" // for Requirement -#include "ftxui/screen/string.hpp" -#include "ftxui/screen/terminal.hpp" // for Size, Dimensions +#include "ftxui/screen/terminal.hpp" // for Dimensions, Size #if defined(_WIN32) #define DEFINE_CONSOLEV2_PROPERTIES @@ -107,7 +107,7 @@ void EventListener(std::atomic* quit, Sender out) { continue; std::wstring wstring; wstring += key_event.uChar.UnicodeChar; - for(auto it : to_string(wstring)) { + for (auto it : to_string(wstring)) { parser.Add(it); } } break; diff --git a/src/ftxui/component/slider_test.cpp b/src/ftxui/component/slider_test.cpp index 12f60ce..98a8a19 100644 --- a/src/ftxui/component/slider_test.cpp +++ b/src/ftxui/component/slider_test.cpp @@ -1,12 +1,14 @@ -#include // for AssertionResult, Message, TestPartResult, Test, EXPECT_TRUE, EXPECT_EQ, SuiteApiResolver, TestInfo (ptr only), EXPECT_FALSE, TEST, TestFactoryImpl +#include // for AssertionResult, Message, TestPartResult, Test, EXPECT_EQ, EXPECT_TRUE, TestInfo (ptr only), EXPECT_FALSE, TEST +#include // for size_t #include // for array #include // for Mouse, Mouse::Left, Mouse::Pressed, Mouse::Released -#include // for GaugeDirection, GaugeDirection::Down, GaugeDirection::Left, GaugeDirection::Right, GaugeDirection::Up -#include // for __shared_ptr_access, shared_ptr, allocator +#include // for GaugeDirection, GaugeDirection::Down, GaugeDirection::Left, GaugeDirection::Right, GaugeDirection::Up, frame +#include // for shared_ptr, __shared_ptr_access, allocator +#include // for to_string -#include "ftxui/component/component.hpp" // for Slider +#include "ftxui/component/component.hpp" // for Slider, Vertical, operator|= #include "ftxui/component/component_base.hpp" // for ComponentBase -#include "ftxui/component/event.hpp" // for Event +#include "ftxui/component/event.hpp" // for Event, Event::ArrowDown #include "ftxui/dom/node.hpp" // for Render #include "ftxui/screen/screen.hpp" // for Screen @@ -133,7 +135,7 @@ TEST(SliderTest, Up) { TEST(SliderTest, Focus) { static std::array values; auto container = Container::Vertical({}); - for(size_t i = 0; iAdd(Slider(std::to_string(i), &values[i])); } container |= frame; @@ -141,45 +143,45 @@ TEST(SliderTest, Focus) { Screen screen(10, 3); Render(screen, container->Render()); - EXPECT_EQ(screen.at(0, 0), "0"); // Select 0 + EXPECT_EQ(screen.at(0, 0), "0"); // Select 0 EXPECT_EQ(screen.at(0, 1), "1"); EXPECT_EQ(screen.at(0, 2), "2"); EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); Render(screen, container->Render()); EXPECT_EQ(screen.at(0, 0), "0"); - EXPECT_EQ(screen.at(0, 1), "1"); // Select 1 + EXPECT_EQ(screen.at(0, 1), "1"); // Select 1 EXPECT_EQ(screen.at(0, 2), "2"); EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); Render(screen, container->Render()); EXPECT_EQ(screen.at(0, 0), "1"); - EXPECT_EQ(screen.at(0, 1), "2"); // Select 2 + EXPECT_EQ(screen.at(0, 1), "2"); // Select 2 EXPECT_EQ(screen.at(0, 2), "3"); - EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 3 - EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 4 - EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 5 - EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 6 + EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 3 + EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 4 + EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 5 + EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); // Select 6 EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); Render(screen, container->Render()); EXPECT_EQ(screen.at(0, 0), "6"); - EXPECT_EQ(screen.at(0, 1), "7"); // Select 7 + EXPECT_EQ(screen.at(0, 1), "7"); // Select 7 EXPECT_EQ(screen.at(0, 2), "8"); EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); Render(screen, container->Render()); EXPECT_EQ(screen.at(0, 0), "7"); - EXPECT_EQ(screen.at(0, 1), "8"); // Select 8 + EXPECT_EQ(screen.at(0, 1), "8"); // Select 8 EXPECT_EQ(screen.at(0, 2), "9"); EXPECT_TRUE(container->OnEvent(Event::ArrowDown)); Render(screen, container->Render()); EXPECT_EQ(screen.at(0, 0), "7"); EXPECT_EQ(screen.at(0, 1), "8"); - EXPECT_EQ(screen.at(0, 2), "9"); // Select 9 - + EXPECT_EQ(screen.at(0, 2), "9"); // Select 9 + EXPECT_FALSE(container->OnEvent(Event::ArrowDown)); } diff --git a/src/ftxui/dom/scroll_indicator.cpp b/src/ftxui/dom/scroll_indicator.cpp index 3111b17..753b239 100644 --- a/src/ftxui/dom/scroll_indicator.cpp +++ b/src/ftxui/dom/scroll_indicator.cpp @@ -27,7 +27,7 @@ Element vscroll_indicator(Element child) { } void SetBox(Box box) override { - Node::SetBox(box); + box_ = box; box.x_max--; children_[0]->SetBox(box); } diff --git a/src/ftxui/dom/scroll_indicator_test.cpp b/src/ftxui/dom/scroll_indicator_test.cpp index b49d303..4713772 100644 --- a/src/ftxui/dom/scroll_indicator_test.cpp +++ b/src/ftxui/dom/scroll_indicator_test.cpp @@ -109,7 +109,7 @@ namespace { Element MakeHorizontalFlexboxList(int n) { Elements list; for (int i = 0; i < n; ++i) { - list.push_back(text(std::to_string(i%10))); + list.push_back(text(std::to_string(i % 10))); } return flexbox(std::move(list)) | vscroll_indicator | yframe | border; } @@ -194,7 +194,7 @@ TEST(ScrollIndicator, HorizontalFlexbox) { "╰────╯"); } -} +} // namespace } // namespace ftxui diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index 21a93ca..a358966 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -49,6 +49,7 @@ void WindowsEmulateVT100Terminal() { } #endif +// NOLINTNEXTLINE(readability-function-cognitive-complexity) void UpdatePixelStyle(std::stringstream& ss, Pixel& previous, const Pixel& next) {