diff --git a/examples/component/homescreen.cpp b/examples/component/homescreen.cpp index 778ae01..10abfd1 100644 --- a/examples/component/homescreen.cpp +++ b/examples/component/homescreen.cpp @@ -10,7 +10,6 @@ #include "ftxui/component/toggle.hpp" #include "ftxui/screen/string.hpp" - using namespace ftxui; int shift = 0; diff --git a/examples/component/tab_vertical.cpp b/examples/component/tab_vertical.cpp index ca8d643..3fc4804 100644 --- a/examples/component/tab_vertical.cpp +++ b/examples/component/tab_vertical.cpp @@ -9,55 +9,50 @@ using namespace ftxui; class MyComponent : public Component { - public: - MyComponent() { - Add(&container_); - container_.Add(&menu_); + public: + MyComponent() { + Add(&container_); + container_.Add(&menu_); - menu_.entries = { - L"menu_1", - L"menu_2", - L"menu_3", - }; + menu_.entries = { + L"menu_1", + L"menu_2", + L"menu_3", + }; - container_.Add(&tab_container_); - - menu_1_.entries = { - L"Forest", - L"Water", - L"I don't know" - }; - tab_container_.Add(&menu_1_); + container_.Add(&tab_container_); - menu_2_.entries = { - L"Hello", - L"Hi", - L"Hay", - }; - tab_container_.Add(&menu_2_); + menu_1_.entries = {L"Forest", L"Water", L"I don't know"}; + tab_container_.Add(&menu_1_); - menu_3_.entries = { - L"Table", - L"Nothing", - L"Is", - L"Empty", - }; - tab_container_.Add(&menu_3_); - } + menu_2_.entries = { + L"Hello", + L"Hi", + L"Hay", + }; + tab_container_.Add(&menu_2_); - std::function on_enter = [](){}; - private: - Menu menu_; - Container container_ = Container::Horizontal(); - Container tab_container_ = Container::Tab(&(menu_.selected)); - Menu menu_1_; - Menu menu_2_; - Menu menu_3_; + menu_3_.entries = { + L"Table", + L"Nothing", + L"Is", + L"Empty", + }; + tab_container_.Add(&menu_3_); + } + + std::function on_enter = []() {}; + + private: + Menu menu_; + Container container_ = Container::Horizontal(); + Container tab_container_ = Container::Tab(&(menu_.selected)); + Menu menu_1_; + Menu menu_2_; + Menu menu_3_; }; - -int main(int argc, const char *argv[]) -{ +int main(int argc, const char* argv[]) { auto screen = ScreenInteractive::TerminalOutput(); MyComponent component; component.on_enter = screen.ExitLoopClosure(); diff --git a/examples/dom/gauge.cpp b/examples/dom/gauge.cpp index db2ba7a..098137a 100644 --- a/examples/dom/gauge.cpp +++ b/examples/dom/gauge.cpp @@ -5,7 +5,6 @@ #include "ftxui/dom/elements.hpp" #include "ftxui/screen/screen.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 96bd573..e6d43c8 100644 --- a/examples/dom/graph.cpp +++ b/examples/dom/graph.cpp @@ -7,7 +7,6 @@ #include "ftxui/screen/screen.hpp" #include "ftxui/screen/string.hpp" - class Graph { public: std::vector operator()(int width, int height) { diff --git a/examples/dom/spinner.cpp b/examples/dom/spinner.cpp index c038252..cf26e70 100644 --- a/examples/dom/spinner.cpp +++ b/examples/dom/spinner.cpp @@ -2,21 +2,20 @@ #include #include -#include "ftxui/screen/screen.hpp" #include "ftxui/dom/elements.hpp" +#include "ftxui/screen/screen.hpp" #include "ftxui/screen/string.hpp" -int main(int argc, const char *argv[]) -{ +int main(int argc, const char* argv[]) { using namespace ftxui; using namespace std::chrono_literals; std::string reset_position; - for(int index = 0; index < 200; ++index) { + for (int index = 0; index < 200; ++index) { std::vector entries; - for(int i = 0; i<22; ++i) { + for (int i = 0; i < 22; ++i) { if (i != 0) - entries.push_back(separator()); + entries.push_back(separator()); // clang-format off entries.push_back( hbox( diff --git a/examples/dom/style_dim.cpp b/examples/dom/style_dim.cpp index 96d29ab..eeee5af 100644 --- a/examples/dom/style_dim.cpp +++ b/examples/dom/style_dim.cpp @@ -1,9 +1,9 @@ -#include "ftxui/dom/elements.hpp" -#include "ftxui/screen/screen.hpp" #include -int main(int argc, const char *argv[]) -{ +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/screen.hpp" + +int main(int argc, const char* argv[]) { using namespace ftxui; // clang-format off auto document = diff --git a/examples/dom/style_gallery.cpp b/examples/dom/style_gallery.cpp index 54b1660..4715baa 100644 --- a/examples/dom/style_gallery.cpp +++ b/examples/dom/style_gallery.cpp @@ -1,9 +1,9 @@ -#include "ftxui/screen/screen.hpp" -#include "ftxui/dom/elements.hpp" #include -int main(int argc, const char *argv[]) -{ +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/screen.hpp" + +int main(int argc, const char* argv[]) { using namespace ftxui; // clang-format off auto document = diff --git a/examples/dom/style_inverted.cpp b/examples/dom/style_inverted.cpp index f81572a..0fc599d 100644 --- a/examples/dom/style_inverted.cpp +++ b/examples/dom/style_inverted.cpp @@ -1,9 +1,9 @@ -#include "ftxui/screen/screen.hpp" -#include "ftxui/dom/elements.hpp" #include -int main(int argc, const char *argv[]) -{ +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/screen.hpp" + +int main(int argc, const char* argv[]) { using namespace ftxui; // clang-format off auto document = diff --git a/examples/dom/style_underlined.cpp b/examples/dom/style_underlined.cpp index fdd98fe..9175c5c 100644 --- a/examples/dom/style_underlined.cpp +++ b/examples/dom/style_underlined.cpp @@ -1,9 +1,9 @@ -#include "ftxui/screen/screen.hpp" -#include "ftxui/dom/elements.hpp" #include -int main(int argc, const char *argv[]) -{ +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/screen.hpp" + +int main(int argc, const char* argv[]) { using namespace ftxui; // clang-format off auto document = diff --git a/examples/dom/vbox_hbox.cpp b/examples/dom/vbox_hbox.cpp index ed1f35e..0d55812 100644 --- a/examples/dom/vbox_hbox.cpp +++ b/examples/dom/vbox_hbox.cpp @@ -1,10 +1,9 @@ -#include "ftxui/screen/screen.hpp" -#include "ftxui/dom/elements.hpp" #include +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/screen.hpp" -int main(int argc, const char *argv[]) -{ +int main(int argc, const char* argv[]) { using namespace ftxui; // clang-format off auto document = diff --git a/examples/util/print_key_press.cpp b/examples/util/print_key_press.cpp index e5cd3f9..dc8c968 100644 --- a/examples/util/print_key_press.cpp +++ b/examples/util/print_key_press.cpp @@ -16,14 +16,14 @@ class DrawKey : public Component { Elements children; for (size_t i = std::max(0, (int)keys.size() - 10); i < keys.size(); ++i) { std::wstring code; - for(auto& it : keys[i].input()) + for (auto& it : keys[i].input()) code += L" " + std::to_wstring((unsigned int)it); code = L"(" + code + L" ) -> "; if (keys[i].is_character()) - code += keys[i].character(); + code += keys[i].character(); else - code += L"(special)"; + code += L"(special)"; children.push_back(text(code)); } return vbox(std::move(children)); diff --git a/include/ftxui/component/receiver.hpp b/include/ftxui/component/receiver.hpp index e396d2f..1d75445 100644 --- a/include/ftxui/component/receiver.hpp +++ b/include/ftxui/component/receiver.hpp @@ -1,11 +1,10 @@ #ifndef FTXUI_COMPONENT_RECEIVER_HPP_ #define FTXUI_COMPONENT_RECEIVER_HPP_ -#include - #include #include #include +#include #include #include #include @@ -50,7 +49,7 @@ template class SenderImpl { public: void Send(T t) { receiver_->Receive(std::move(t)); } - ~SenderImpl() { receiver_->ReleaseSender();} + ~SenderImpl() { receiver_->ReleaseSender(); } private: friend class ReceiverImpl; diff --git a/src/ftxui/component/radiobox_test.cpp b/src/ftxui/component/radiobox_test.cpp index 8632d9b..593cacd 100644 --- a/src/ftxui/component/radiobox_test.cpp +++ b/src/ftxui/component/radiobox_test.cpp @@ -75,5 +75,4 @@ TEST(RadioboxTest, Navigation) { radiobox.OnEvent(Event::TabReverse); EXPECT_EQ(radiobox.focused, 1); radiobox.OnEvent(Event::TabReverse); - } diff --git a/src/ftxui/component/receiver_test.cpp b/src/ftxui/component/receiver_test.cpp index 212e3af..5305631 100644 --- a/src/ftxui/component/receiver_test.cpp +++ b/src/ftxui/component/receiver_test.cpp @@ -58,10 +58,14 @@ TEST(Receiver, BasicWithThread) { s1_bis.reset(); char c; - EXPECT_TRUE(r3->Receive(&c));EXPECT_EQ(c, '1'); - EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '2'); - EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '3'); - EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '4'); + EXPECT_TRUE(r3->Receive(&c)); + EXPECT_EQ(c, '1'); + EXPECT_TRUE(r3->Receive(&c)); + EXPECT_EQ(c, '2'); + EXPECT_TRUE(r3->Receive(&c)); + EXPECT_EQ(c, '3'); + EXPECT_TRUE(r3->Receive(&c)); + EXPECT_EQ(c, '4'); EXPECT_FALSE(r3->Receive(&c)); // Thread will end at the end of the stream. diff --git a/src/ftxui/component/toggle_test.cpp b/src/ftxui/component/toggle_test.cpp index e2a5aca..c806c9d 100644 --- a/src/ftxui/component/toggle_test.cpp +++ b/src/ftxui/component/toggle_test.cpp @@ -70,5 +70,4 @@ TEST(ToggleTest, Tab) { toggle.OnEvent(Event::TabReverse); EXPECT_EQ(toggle.selected, 1); toggle.OnEvent(Event::TabReverse); - } diff --git a/src/ftxui/dom/hbox_test.cpp b/src/ftxui/dom/hbox_test.cpp index 4985cf5..bca1c19 100644 --- a/src/ftxui/dom/hbox_test.cpp +++ b/src/ftxui/dom/hbox_test.cpp @@ -6,114 +6,79 @@ using namespace ftxui; using namespace ftxui; TEST(HBoxTest, ScreenSmaller1) { - auto root = hbox( - text(L"text_1"), - text(L"text_2") - ); - Screen screen(11,1); + auto root = hbox(text(L"text_1"), text(L"text_2")); + Screen screen(11, 1); Render(screen, root.get()); EXPECT_EQ("text_1text_", screen.ToString()); } TEST(HBoxTest, ScreenSmaller2) { - auto root = hbox( - text(L"text_1"), - text(L"text_2") - ); - Screen screen(10,1); + auto root = hbox(text(L"text_1"), text(L"text_2")); + Screen screen(10, 1); Render(screen, root.get()); EXPECT_EQ("text_1text", screen.ToString()); } TEST(HBoxTest, ScreenFit) { - auto root = hbox( - text(L"text_1"), - text(L"text_2") - ); - Screen screen(12,1); + auto root = hbox(text(L"text_1"), text(L"text_2")); + Screen screen(12, 1); Render(screen, root.get()); EXPECT_EQ("text_1text_2", screen.ToString()); } TEST(HBoxTest, ScreenBigger1) { - auto root = hbox( - text(L"text_1"), - text(L"text_2") - ); - Screen screen(13,1); + auto root = hbox(text(L"text_1"), text(L"text_2")); + Screen screen(13, 1); Render(screen, root.get()); EXPECT_EQ("text_1text_2 ", screen.ToString()); } TEST(HBoxTest, ScreenBigger2) { - auto root = hbox( - text(L"text_1"), - text(L"text_2") - ); - Screen screen(14,1); + auto root = hbox(text(L"text_1"), text(L"text_2")); + Screen screen(14, 1); Render(screen, root.get()); EXPECT_EQ("text_1text_2 ", screen.ToString()); } TEST(HBoxTest, ScreenSmaller1Flex) { - auto root = hbox( - text(L"text_1"), - filler(), - text(L"text_2") - ); - Screen screen(11,1); + auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); + Screen screen(11, 1); Render(screen, root.get()); EXPECT_EQ("text_1text_", screen.ToString()); } TEST(HBoxTest, ScreenSmaller2Flex) { - auto root = hbox( - text(L"text_1"), - filler(), - text(L"text_2") - ); - Screen screen(10,1); + auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); + Screen screen(10, 1); Render(screen, root.get()); EXPECT_EQ("text_1text", screen.ToString()); } TEST(HBoxTest, ScreenFitFlex) { - auto root = hbox( - text(L"text_1"), - filler(), - text(L"text_2") - ); - Screen screen(12,1); + auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); + Screen screen(12, 1); Render(screen, root.get()); EXPECT_EQ("text_1text_2", screen.ToString()); } TEST(HBoxTest, ScreenBigger1Flex) { - auto root = hbox( - text(L"text_1"), - filler(), - text(L"text_2") - ); - Screen screen(13,1); + auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); + Screen screen(13, 1); Render(screen, root.get()); EXPECT_EQ("text_1 text_2", screen.ToString()); } TEST(HBoxTest, ScreenBigger2Flex) { - auto root = hbox( - text(L"text_1"), - filler(), - text(L"text_2") - ); - Screen screen(14,1); + auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); + Screen screen(14, 1); Render(screen, root.get()); EXPECT_EQ("text_1 text_2", screen.ToString()); diff --git a/src/ftxui/dom/vbox.cpp b/src/ftxui/dom/vbox.cpp index 2e173b4..25e0697 100644 --- a/src/ftxui/dom/vbox.cpp +++ b/src/ftxui/dom/vbox.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include "ftxui/dom/elements.hpp" #include "ftxui/dom/node.hpp" diff --git a/src/ftxui/dom/vbox_test.cpp b/src/ftxui/dom/vbox_test.cpp index c787b0a..3da7784 100644 --- a/src/ftxui/dom/vbox_test.cpp +++ b/src/ftxui/dom/vbox_test.cpp @@ -50,12 +50,12 @@ TEST(VBoxTest, ScreenFitFlex) { Render(screen, root.get()); EXPECT_EQ( - "text_1 \n" - " \n" - " \n" - " \n" - "text_2 " - ,screen.ToString()); + "text_1 \n" + " \n" + " \n" + " \n" + "text_2 ", + screen.ToString()); } TEST(VBoxTest, ScreenBigger1Flex) { diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index 14aecc5..42e46c0 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -7,7 +7,6 @@ #include "ftxui/screen/string.hpp" #include "ftxui/screen/terminal.hpp" - #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #define NOMINMAX diff --git a/src/ftxui/screen/string.cpp b/src/ftxui/screen/string.cpp index 5f797b0..46a029e 100644 --- a/src/ftxui/screen/string.cpp +++ b/src/ftxui/screen/string.cpp @@ -3,10 +3,9 @@ #include #include - #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4996) // codecvt_utf8_utf16 is deprecated + #pragma warning(push) + #pragma warning(disable : 4996) // codecvt_utf8_utf16 is deprecated #endif std::string to_string(const std::wstring& s) { @@ -20,5 +19,5 @@ std::wstring to_wstring(const std::string& s) { } #ifdef _MSC_VER -#pragma warning(pop) + #pragma warning(pop) #endif \ No newline at end of file diff --git a/src/ftxui/screen/terminal.cpp b/src/ftxui/screen/terminal.cpp index 58d771d..0598667 100644 --- a/src/ftxui/screen/terminal.cpp +++ b/src/ftxui/screen/terminal.cpp @@ -2,7 +2,6 @@ #include - #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #define NOMINMAX