Skip to content

Commit

Permalink
Execute clang-tidy and IWYU. (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurSonzogni authored Feb 12, 2023
1 parent a4e70df commit 3e35f45
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 28 deletions.
3 changes: 1 addition & 2 deletions include/ftxui/component/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ Component Radiobox(ConstStringListRef entries,
Ref<RadioboxOption> option = {});
Component Toggle(ConstStringListRef entries, int* selected);


// General slider constructor:
template <typename T>
template <typename T>
Component Slider(SliderOption<T> options = {});

// Shorthand without the `SliderOption` constructor:
Expand Down
2 changes: 1 addition & 1 deletion include/ftxui/screen/screen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define FTXUI_SCREEN_SCREEN_HPP

#include <memory>
#include <string> // for string, allocator, basic_string
#include <string> // for allocator, string, basic_string
#include <vector> // for vector

#include "ftxui/screen/box.hpp" // for Box
Expand Down
3 changes: 2 additions & 1 deletion src/ftxui/component/animation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cmath> // IWYU pragma: keep
#include <cmath> // for sin, pow, sqrt, cos
#include <compare> // for operator<=, operator>=, partial_ordering
#include <ratio> // for ratio
#include <utility> // for move

Expand Down
8 changes: 4 additions & 4 deletions src/ftxui/component/screen_interactive.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <algorithm> // for copy, max, min
#include <array> // for array
#include <chrono> // for operator-, milliseconds, operator>=, duration, common_type<>::type, time_point
#include <chrono> // for operator-, milliseconds, operator<=>, duration, common_type<>::type, time_point
#include <compare> // for operator>=, strong_ordering
#include <csignal> // for signal, SIGTSTP, SIGABRT, SIGWINCH, raise, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM, __sighandler_t, size_t
#include <cstdio> // for fileno, stdin
#include <ftxui/component/task.hpp> // for Task, Closure, AnimationTask
Expand All @@ -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
Expand Down Expand Up @@ -107,7 +107,7 @@ void EventListener(std::atomic<bool>* quit, Sender<Task> 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;
Expand Down
36 changes: 19 additions & 17 deletions src/ftxui/component/slider_test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#include <gtest/gtest.h> // for AssertionResult, Message, TestPartResult, Test, EXPECT_TRUE, EXPECT_EQ, SuiteApiResolver, TestInfo (ptr only), EXPECT_FALSE, TEST, TestFactoryImpl
#include <gtest/gtest.h> // for AssertionResult, Message, TestPartResult, Test, EXPECT_EQ, EXPECT_TRUE, TestInfo (ptr only), EXPECT_FALSE, TEST
#include <stddef.h> // for size_t
#include <array> // for array
#include <ftxui/component/mouse.hpp> // for Mouse, Mouse::Left, Mouse::Pressed, Mouse::Released
#include <ftxui/dom/elements.hpp> // for GaugeDirection, GaugeDirection::Down, GaugeDirection::Left, GaugeDirection::Right, GaugeDirection::Up
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
#include <ftxui/dom/elements.hpp> // for GaugeDirection, GaugeDirection::Down, GaugeDirection::Left, GaugeDirection::Right, GaugeDirection::Up, frame
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
#include <string> // 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

Expand Down Expand Up @@ -133,53 +135,53 @@ TEST(SliderTest, Up) {
TEST(SliderTest, Focus) {
static std::array<int, 10> values;
auto container = Container::Vertical({});
for(size_t i = 0; i<values.size(); ++i) {
for (size_t i = 0; i < values.size(); ++i) {
container->Add(Slider(std::to_string(i), &values[i]));
}
container |= frame;

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));
}

Expand Down
2 changes: 1 addition & 1 deletion src/ftxui/dom/scroll_indicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ftxui/dom/scroll_indicator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ TEST(ScrollIndicator, HorizontalFlexbox) {
"╰────╯");
}

}
} // namespace

} // namespace ftxui

Expand Down
1 change: 1 addition & 0 deletions src/ftxui/screen/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void WindowsEmulateVT100Terminal() {
}
#endif

// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void UpdatePixelStyle(std::stringstream& ss,
Pixel& previous,
const Pixel& next) {
Expand Down

0 comments on commit 3e35f45

Please sign in to comment.