diff --git a/examples/component/input.cpp b/examples/component/input.cpp index c49f6b325d538998c145541a3334aa9643f906e3..85e16685ef1b42b48835be3b99873a76426f63be 100644 --- a/examples/component/input.cpp +++ b/examples/component/input.cpp @@ -1,12 +1,13 @@ #include <memory> // for allocator, __shared_ptr_access -#include <string> // for char_traits, operator+, wstring, basic_string +#include <string> // for char_traits, operator+, string, basic_string -#include "ftxui/component/captured_mouse.hpp" // for ftxui -#include "ftxui/component/component.hpp" // for Renderer, Vertical -#include "ftxui/component/component_base.hpp" // for ComponentBase +#include "ftxui/component/captured_mouse.hpp" // for ftxui +#include "ftxui/component/component.hpp" // for Input, Renderer, Vertical +#include "ftxui/component/component_base.hpp" // for ComponentBase #include "ftxui/component/component_options.hpp" // for InputOption #include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive -#include "ftxui/dom/elements.hpp" // for hbox, separator, Element, operator|, vbox, border +#include "ftxui/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border +#include "ftxui/util/ref.hpp" // for Ref int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/examples/component/menu_entries.cpp b/examples/component/menu_entries.cpp index b24173dff81d2f60a4268cc7e9a67bf1ea5358d1..e5e3cf261a2e5a4c7efcdd912dd1fc7e42461c1e 100644 --- a/examples/component/menu_entries.cpp +++ b/examples/component/menu_entries.cpp @@ -1,12 +1,15 @@ -#include <functional> // for function #include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream -#include <string> // for string, basic_string, allocator -#include <vector> // for vector +#include <memory> // for shared_ptr, __shared_ptr_access +#include <string> // for to_string, allocator -#include "ftxui/component/captured_mouse.hpp" // for ftxui -#include "ftxui/component/component.hpp" // for Menu -#include "ftxui/component/component_options.hpp" // for MenuOption +#include "ftxui/component/captured_mouse.hpp" // for ftxui +#include "ftxui/component/component.hpp" // for MenuEntry, Renderer, Vertical +#include "ftxui/component/component_base.hpp" // for ComponentBase +#include "ftxui/component/component_options.hpp" // for MenuEntryOption #include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive +#include "ftxui/dom/elements.hpp" // for operator|, separator, Element, Decorator, color, text, hbox, size, bold, frame, inverted, vbox, HEIGHT, LESS_THAN, border +#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Cyan, Color::Green, Color::Red, Color::Yellow + using namespace ftxui; // Define a special style for some menu entry. @@ -22,23 +25,6 @@ MenuEntryOption Colored(ftxui::Color c) { int main(int argc, const char* argv[]) { auto screen = ScreenInteractive::TerminalOutput(); - //Black = 0, - //Red = 1, - //Green = 2, - //Yellow = 3, - //Blue = 4, - //Magenta = 5, - //Cyan = 6, - //GrayLight = 7, - //GrayDark = 8, - //RedLight = 9, - //GreenLight = 10, - //YellowLight = 11, - //BlueLight = 12, - //MagentaLight = 13, - //CyanLight = 14, - //White = 15, - int selected = 0; auto menu = Container::Vertical( { diff --git a/examples/component/nested_screen.cpp b/examples/component/nested_screen.cpp index b492480a4b937369f8e0974257b8de94a23cb04a..5c38a59288855138ce10e22a063f6b7a881f4d90 100644 --- a/examples/component/nested_screen.cpp +++ b/examples/component/nested_screen.cpp @@ -1,12 +1,11 @@ -#include <memory> // for shared_ptr, __shared_ptr_access -#include <string> // for operator+, to_wstring +#include <memory> // for allocator, shared_ptr, __shared_ptr_access +#include <string> // for operator+, string, char_traits, basic_string #include "ftxui/component/captured_mouse.hpp" // for ftxui -#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer -#include "ftxui/component/component_base.hpp" // for ComponentBase -#include "ftxui/component/component_options.hpp" // for ButtonOption +#include "ftxui/component/component.hpp" // for Button, Vertical, Renderer +#include "ftxui/component/component_base.hpp" // for ComponentBase #include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive -#include "ftxui/dom/elements.hpp" // for separator, gauge, Element, operator|, vbox, border +#include "ftxui/dom/elements.hpp" // for separator, text, Element, operator|, vbox, border using namespace ftxui; @@ -24,13 +23,14 @@ void Nested(std::string path) { }); auto renderer = Renderer(layout, [&] { return vbox({ - text("path: " + path), - separator(), - back_button->Render(), - goto_1->Render(), - goto_2->Render(), - goto_3->Render(), - }) | border; + text("path: " + path), + separator(), + back_button->Render(), + goto_1->Render(), + goto_2->Render(), + goto_3->Render(), + }) | + border; }); screen.Loop(renderer); } @@ -40,8 +40,8 @@ int main(int argc, const char* argv[]) { auto button_quit = Button("Quit", screen.ExitLoopClosure()); auto button_nested = Button("Nested", [] { Nested(""); }); screen.Loop(Container::Vertical({ - button_quit, - button_nested, + button_quit, + button_nested, })); return 0; } diff --git a/examples/dom/separator_style.cpp b/examples/dom/separator_style.cpp index aaf2d2220ef41ed154b02b581e0775091e4afed7..f0bf6e276358061fe822c823a5a6832c7d6aa2c3 100644 --- a/examples/dom/separator_style.cpp +++ b/examples/dom/separator_style.cpp @@ -1,10 +1,10 @@ -#include <ftxui/dom/elements.hpp> // for text, operator|, vbox, border, Element, Fit, hbox -#include <ftxui/screen/screen.hpp> // for Full, Screen -#include <iostream> -#include <memory> // for allocator +#include <ftxui/screen/screen.hpp> // for Screen +#include <iostream> // for endl, cout, ostream +#include <memory> // for allocator -#include "ftxui/dom/node.hpp" // for Render -#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/dom/elements.hpp" // for text, hbox, separatorDouble, separatorHeavy, separatorLight, vbox, operator|, Element, Fit, borderDouble, borderHeavy, borderLight +#include "ftxui/dom/node.hpp" // for Render +#include "ftxui/screen/box.hpp" // for ftxui int main(int argc, const char* argv[]) { using namespace ftxui; diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index c2e6036e3fc78912cb8e7ad15e830cf0106ad7c4..ea037aa42a221fcad57c01c3b45004c8d2aa7fe8 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -19,6 +19,7 @@ struct InputOption; struct MenuOption; struct RadioboxOption; struct ToggleOption; +struct MenuEntryOption; template <class T, class... Args> std::shared_ptr<T> Make(Args&&... args) { diff --git a/include/ftxui/component/component_options.hpp b/include/ftxui/component/component_options.hpp index 03a16b76a461ffa1d2d97931ee4d39ec6beba4de..48249c61565237cd772eb9b12cb6affb6fcd05c7 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -43,11 +43,11 @@ struct ButtonOption { /// @brief Option for the Checkbox component. /// @ingroup component struct CheckboxOption { - std::string style_checked = "▣ "; ///< Prefix for a "checked" state. - std::string style_unchecked = "☐ "; ///< Prefix for a "unchecked" state. - Decorator style_normal = nothing; ///< style. - Decorator style_focused = inverted; ///< Style when focused. - Decorator style_selected = bold; ///< Style when selected. + std::string style_checked = "▣ "; ///< Prefix for a "checked" state. + std::string style_unchecked = "☐ "; ///< Prefix for a "unchecked" state. + Decorator style_normal = nothing; ///< style. + Decorator style_focused = inverted; ///< Style when focused. + Decorator style_selected = bold; ///< Style when selected. Decorator style_selected_focused = Decorator(inverted) | bold; ///< Style when selected and focused. @@ -74,8 +74,8 @@ struct InputOption { /// @brief Option for the Radiobox component. /// @ingroup component struct RadioboxOption { - std::string style_checked = "◉ "; ///< Prefix for a "checked" state. - std::string style_unchecked = "○ "; ///< Prefix for a "unchecked" state. + std::string style_checked = "◉ "; ///< Prefix for a "checked" state. + std::string style_unchecked = "○ "; ///< Prefix for a "unchecked" state. Decorator style_normal = nothing; ///< style. Decorator style_focused = inverted; ///< Style when focused. Decorator style_selected = bold; ///< Style when selected. diff --git a/include/ftxui/component/screen_interactive.hpp b/include/ftxui/component/screen_interactive.hpp index 5d53a9f40b76c4401fc9093bdc115387f2f35838..e6b0518771db9ec48c65a21415d061b34d162b1d 100644 --- a/include/ftxui/component/screen_interactive.hpp +++ b/include/ftxui/component/screen_interactive.hpp @@ -6,7 +6,7 @@ #include <functional> // for function #include <memory> // for shared_ptr #include <string> // for string -#include <thread> +#include <thread> // for thread #include "ftxui/component/captured_mouse.hpp" // for CapturedMouse #include "ftxui/component/event.hpp" // for Event diff --git a/include/ftxui/screen/color.hpp b/include/ftxui/screen/color.hpp index 8ebd59a2b9ede2a10a9af2a27ea2668c6b78b306..0bc069b4bbb2031bbe80798d8e72b817afa6b248 100644 --- a/include/ftxui/screen/color.hpp +++ b/include/ftxui/screen/color.hpp @@ -2,7 +2,7 @@ #define FTXUI_SCREEN_COLOR #include <stdint.h> // for uint8_t -#include <string> // for wstring +#include <string> // for wstring #ifdef RGB // Workaround for wingdi.h (via Windows.h) defining macros that break things. @@ -324,7 +324,7 @@ class Color { inline namespace literals { -/// @brief Creates a color from a combined hex RGB representation, +/// @brief Creates a color from a combined hex RGB representation, /// e.g. 0x808000_rgb Color operator""_rgb(unsigned long long int combined); diff --git a/iwyu.imp b/iwyu.imp index e1a5d3b95cd2c8deff3578aec85f85f6c5f9877b..4f6902bf3afead4b5408442ad8d6803c1512ccda 100644 --- a/iwyu.imp +++ b/iwyu.imp @@ -1,4 +1,5 @@ [ + { symbol: [ "char_traits", private, "<string>", public ] }, { symbol: [ "ECHO", private, "<termios.h>", public ] }, { symbol: [ "ICANON", private, "<termios.h>", public ] }, { symbol: [ "TCSANOW", private, "<termios.h>", public ] }, diff --git a/src/ftxui/component/container.cpp b/src/ftxui/component/container.cpp index 7a087e44089539c6713b3d811b2483e57e681d82..452129511cf0ee612a9e7e746b727d9bd215c5d0 100644 --- a/src/ftxui/component/container.cpp +++ b/src/ftxui/component/container.cpp @@ -1,13 +1,15 @@ #include <stddef.h> // for size_t #include <algorithm> // for max, min -#include <memory> // for __shared_ptr_access, shared_ptr, make_shared, allocator, __shared_ptr_access<>::element_type, allocator_traits<>::value_type +#include <memory> // for make_shared, __shared_ptr_access, allocator, shared_ptr, allocator_traits<>::value_type #include <utility> // for move #include <vector> // for vector, __alloc_traits<>::value_type -#include "ftxui/component/component.hpp" // for Component, Components, Horizontal, Vertical, Tab -#include "ftxui/component/component_base.hpp" // for ComponentBase +#include "ftxui/component/component.hpp" // for Horizontal, Vertical, Tab +#include "ftxui/component/component_base.hpp" // for Components, Component, ComponentBase #include "ftxui/component/event.hpp" // for Event, Event::Tab, Event::TabReverse, Event::ArrowDown, Event::ArrowLeft, Event::ArrowRight, Event::ArrowUp -#include "ftxui/dom/elements.hpp" // for text, Elements, Element, hbox, vbox +#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::WheelDown, Mouse::WheelUp +#include "ftxui/dom/elements.hpp" // for text, Elements, operator|, reflect, Element, hbox, vbox +#include "ftxui/screen/box.hpp" // for Box namespace ftxui { diff --git a/src/ftxui/component/menu.cpp b/src/ftxui/component/menu.cpp index e3d9382728e7ca7c484291d79be220ffd1572aa7..d166b24af2df43a01953e5262d1a949ce7637b7c 100644 --- a/src/ftxui/component/menu.cpp +++ b/src/ftxui/component/menu.cpp @@ -185,10 +185,10 @@ Component MenuEntry(ConstStringRef label, Ref<MenuEntryOption> option) { private: Element Render() override { bool focused = Focused(); - auto style = hovered_ ? (focused ? option_->style_selected_focused - : option_->style_selected) - : (focused ? option_->style_focused - : option_->style_normal); + auto style = + hovered_ ? (focused ? option_->style_selected_focused + : option_->style_selected) + : (focused ? option_->style_focused : option_->style_normal); auto focus_management = focused ? select : nothing; auto label = focused ? "> " + (*label_) // : " " + (*label_); diff --git a/src/ftxui/dom/border.cpp b/src/ftxui/dom/border.cpp index 4ad97aea2730078cbc420767402485d53d863e5f..4d11f654010b23d97a9aff03374ffd37a181fcdb 100644 --- a/src/ftxui/dom/border.cpp +++ b/src/ftxui/dom/border.cpp @@ -149,7 +149,6 @@ Element border(Element child) { return std::make_shared<Border>(unpack(std::move(child)), ROUNDED); } - /// @brief Same as border but with a constant Pixel around the element. /// @ingroup dom /// @see border diff --git a/src/ftxui/dom/box_helper.cpp b/src/ftxui/dom/box_helper.cpp index d90da2a5b651d80200ac6c6d343c96b3dd9a3468..4fa8fa2e8ec48dcae7bff8a8dc30e665435abe13 100644 --- a/src/ftxui/dom/box_helper.cpp +++ b/src/ftxui/dom/box_helper.cpp @@ -1,5 +1,7 @@ #include "ftxui/dom/box_helper.hpp" +#include <algorithm> // for max + namespace ftxui { namespace box_helper { @@ -83,3 +85,7 @@ void Compute(std::vector<Element>* elements, int target_size) { } // namespace box_helper } // namespace ftxui + +// Copyright 2021 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/dom/box_helper.hpp b/src/ftxui/dom/box_helper.hpp index 9e0ebda64392f354e9c1e1570cfce1df1dd8ad51..a0e9db625f519a5ac6555e84794742a2be9e9615 100644 --- a/src/ftxui/dom/box_helper.hpp +++ b/src/ftxui/dom/box_helper.hpp @@ -22,3 +22,7 @@ void Compute(std::vector<Element>* elements, int target_size); } // namespace ftxui #endif /* end of include guard: FTXUI_DOM_BOX_HELPER_HPP */ + +// Copyright 2021 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/dom/gauge.cpp b/src/ftxui/dom/gauge.cpp index 252b6c372f24c846331ed8831eb6db8c5ac54780..68de4cd2e3e443595760dee914f475590b403e24 100644 --- a/src/ftxui/dom/gauge.cpp +++ b/src/ftxui/dom/gauge.cpp @@ -1,6 +1,6 @@ -#include <cmath> -#include <memory> // for allocator, make_shared -#include <string> // for string +#include <algorithm> // for max, min +#include <memory> // for allocator, make_shared +#include <string> // for string #include "ftxui/dom/elements.hpp" // for Element, gauge #include "ftxui/dom/node.hpp" // for Node diff --git a/src/ftxui/dom/gridbox.cpp b/src/ftxui/dom/gridbox.cpp index be06ec16bf8af8e46997852daa34d875a90e494d..0cd619c064487059de43fb97a30ec9bbcffdca7d 100644 --- a/src/ftxui/dom/gridbox.cpp +++ b/src/ftxui/dom/gridbox.cpp @@ -1,16 +1,17 @@ -#include <iostream> -#include <algorithm> // for max -#include <memory> // for __shared_ptr_access, shared_ptr, make_shared -#include <utility> // for move -#include <vector> // for vector - -#include "ftxui/dom/box_helper.hpp" // for Requirement -#include "ftxui/dom/elements.hpp" // for Element, Elements, hbox +#include <stddef.h> // for size_t +#include <algorithm> // for max, min +#include <memory> // for __shared_ptr_access, shared_ptr, make_shared, allocator_traits<>::value_type +#include <utility> // for move +#include <vector> // for vector, __alloc_traits<>::value_type + +#include "ftxui/dom/box_helper.hpp" // for Element, Compute +#include "ftxui/dom/elements.hpp" // for Elements, filler, Element, gridbox #include "ftxui/dom/node.hpp" // for Node #include "ftxui/dom/requirement.hpp" // for Requirement #include "ftxui/screen/box.hpp" // for Box namespace ftxui { +class Screen; class GridBox : public Node { public: @@ -19,9 +20,9 @@ class GridBox : public Node { for (const auto& line : lines_) x_size = std::max(x_size, (int)line.size()); for (auto& line : lines_) { - while (line.size() < (size_t)y_size) { - line.push_back(filler()); - } + while (line.size() < (size_t)y_size) { + line.push_back(filler()); + } } } @@ -33,8 +34,8 @@ class GridBox : public Node { requirement_.flex_shrink_x = 0; requirement_.flex_shrink_y = 0; - for(auto& line : lines_) { - for(auto& cell : line) { + for (auto& line : lines_) { + for (auto& cell : line) { cell->ComputeRequirement(); // Determine focus based on the focused child. diff --git a/src/ftxui/dom/gridbox_test.cpp b/src/ftxui/dom/gridbox_test.cpp index a7506d74aa2f84700403ea12942b67d2ed9b083b..c8dae798b818b64ce85d19f8259610526fea811b 100644 --- a/src/ftxui/dom/gridbox_test.cpp +++ b/src/ftxui/dom/gridbox_test.cpp @@ -1,11 +1,12 @@ #include <gtest/gtest-message.h> // for Message #include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl, TestPartResult +#include <algorithm> // for remove #include <string> // for allocator, basic_string, string #include <vector> // for vector -#include "ftxui/dom/elements.hpp" // for text, operator|, Element, flex_grow, flex_shrink, gridbox -#include "ftxui/dom/node.hpp" // for Render -#include "ftxui/screen/box.hpp" // for ftxui +#include "ftxui/dom/elements.hpp" // for text, operator|, Element, flex, flex_grow, Elements, flex_shrink, vtext, gridbox, vbox, border +#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, EXPECT_EQ, TEST diff --git a/src/ftxui/dom/hbox.cpp b/src/ftxui/dom/hbox.cpp index 55bc115472dd6152934b6b1594d906cf354083a1..e75a64c042cb48cbee6f679331e051dbbc8ee201 100644 --- a/src/ftxui/dom/hbox.cpp +++ b/src/ftxui/dom/hbox.cpp @@ -1,11 +1,12 @@ +#include <stddef.h> // for size_t #include <algorithm> // for max -#include <memory> // for __shared_ptr_access, shared_ptr, make_shared -#include <utility> // for move -#include <vector> // for vector +#include <memory> // for __shared_ptr_access, shared_ptr, make_shared, allocator_traits<>::value_type +#include <utility> // for move +#include <vector> // for vector, __alloc_traits<>::value_type -#include "ftxui/dom/box_helper.hpp" // for Box +#include "ftxui/dom/box_helper.hpp" // for Element, Compute #include "ftxui/dom/elements.hpp" // for Element, Elements, hbox -#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/node.hpp" // for Node, Elements #include "ftxui/dom/requirement.hpp" // for Requirement #include "ftxui/screen/box.hpp" // for Box diff --git a/src/ftxui/dom/reflect.cpp b/src/ftxui/dom/reflect.cpp index 75d5846358b0481a40a5e954b7df1d0d8017b0ea..be86041e30d6b06ad7355425b3f04f35d15908e9 100644 --- a/src/ftxui/dom/reflect.cpp +++ b/src/ftxui/dom/reflect.cpp @@ -1,11 +1,12 @@ #include <memory> // for make_shared, __shared_ptr_access #include <utility> // for move -#include <vector> // for __alloc_traits<>::value_type, vector +#include <vector> // for __alloc_traits<>::value_type #include "ftxui/dom/elements.hpp" // for Element, unpack, Decorator, reflect -#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/node.hpp" // for Node, Elements #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/vbox.cpp b/src/ftxui/dom/vbox.cpp index f3eac99bf408fa6ec57a0d4c8e41faa9927f7a8d..82417e1452758fe186e936586dc600c439b9545e 100644 --- a/src/ftxui/dom/vbox.cpp +++ b/src/ftxui/dom/vbox.cpp @@ -1,11 +1,12 @@ +#include <stddef.h> // for size_t #include <algorithm> // for max -#include <memory> // for __shared_ptr_access, shared_ptr, make_shared -#include <utility> // for move -#include <vector> // for vector +#include <memory> // for __shared_ptr_access, shared_ptr, make_shared, allocator_traits<>::value_type +#include <utility> // for move +#include <vector> // for vector, __alloc_traits<>::value_type -#include "ftxui/dom/box_helper.hpp" // for Box +#include "ftxui/dom/box_helper.hpp" // for Element, Compute #include "ftxui/dom/elements.hpp" // for Element, Elements, vbox -#include "ftxui/dom/node.hpp" // for Node +#include "ftxui/dom/node.hpp" // for Node, Elements #include "ftxui/dom/requirement.hpp" // for Requirement #include "ftxui/screen/box.hpp" // for Box diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index e2b333b864736522848170ac84f013ad1c7cd4fe..f323c50eb1d04f0aea7b9bc69d3114128262acf6 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -1,7 +1,9 @@ +#include <stdint.h> // for uint16_t #include <iostream> // for operator<<, stringstream, basic_ostream, flush, cout, ostream -#include <map> -#include <memory> // for allocator +#include <map> // for _Rb_tree_const_iterator, map, operator!=, operator== +#include <memory> // for allocator, allocator_traits<>::value_type #include <sstream> // IWYU pragma: keep +#include <utility> // for pair #include "ftxui/screen/screen.hpp" #include "ftxui/screen/string.hpp" // for string_width