diff --git a/CMakeLists.txt b/CMakeLists.txt index 65f41dbdb448f3c395be6f7a09cfec8e0a4bc4ed..bf4a9dac3bf5266db00f8c9decc2a0df475fa94f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ else() ${FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT} OFF) endif() +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + include(cmake/ftxui_message.cmake) add_library(screen diff --git a/README.md b/README.md index bfb27e0fae282051d6e7c65546f46512909f1f73..e62b129da5d73fb58a7da27e09b4723fe0a21b15 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ A simple cross-platform C++ library for terminal based user interfaces! ## Feature * Functional style. Inspired by - [[1]](https://hackernoon.com/building-reactive-terminal-interfaces-in-c-d392ce34e649?gi=d9fb9ce35901) + [1](https://hackernoon.com/building-reactive-terminal-interfaces-in-c-d392ce34e649?gi=d9fb9ce35901) and [React](https://reactjs.org/) * Simple and elegant syntax (in my opinion) * Keyboard & mouse navigation. diff --git a/include/ftxui/component/animation.hpp b/include/ftxui/component/animation.hpp index c9f665ed6ee0b5c42357570ea4fdb5783d7cd688..a04aea56a8d3b7f3fd938b0e8fca6cdbf627c158 100644 --- a/include/ftxui/component/animation.hpp +++ b/include/ftxui/component/animation.hpp @@ -7,11 +7,7 @@ #include <chrono> // for milliseconds, duration, steady_clock, time_point #include <functional> // for function -#include "ftxui/component/event.hpp" - -namespace ftxui { - -namespace animation { +namespace ftxui::animation { // Components who haven't completed their animation can call this function to // request a new frame to be drawn later. // @@ -26,7 +22,7 @@ using Duration = std::chrono::duration<float>; // Parameter of Component::OnAnimation(param). class Params { public: - Params(Duration duration) : duration_(duration) {} + explicit Params(Duration duration) : duration_(duration) {} /// The duration this animation step represents. Duration duration() const { return duration_; } @@ -93,11 +89,11 @@ float BounceInOut(float p); class Animator { public: - Animator(float* from, - float to = 0.f, - Duration duration = std::chrono::milliseconds(250), - easing::Function easing_function = easing::Linear, - Duration delay = std::chrono::milliseconds(0)); + explicit Animator(float* from, + float to = 0.f, + Duration duration = std::chrono::milliseconds(250), + easing::Function easing_function = easing::Linear, + Duration delay = std::chrono::milliseconds(0)); void OnAnimation(Params&); @@ -112,7 +108,6 @@ class Animator { Duration current_; }; -} // namespace animation -} // namespace ftxui +} // namespace ftxui::animation #endif /* end of include guard: FTXUI_ANIMATION_HPP */ diff --git a/include/ftxui/component/captured_mouse.hpp b/include/ftxui/component/captured_mouse.hpp index 4ed6d75ae8adc57985e5b3c18d714defb4a8feb0..234e12f6eee59b0424c1ac25bc8fa296112c2adc 100644 --- a/include/ftxui/component/captured_mouse.hpp +++ b/include/ftxui/component/captured_mouse.hpp @@ -9,6 +9,11 @@ namespace ftxui { class CapturedMouseInterface { public: + CapturedMouseInterface() = default; + CapturedMouseInterface(const CapturedMouseInterface&) = default; + CapturedMouseInterface(CapturedMouseInterface&&) = delete; + CapturedMouseInterface& operator=(const CapturedMouseInterface&) = default; + CapturedMouseInterface& operator=(CapturedMouseInterface&&) = delete; virtual ~CapturedMouseInterface() = default; }; using CapturedMouse = std::unique_ptr<CapturedMouseInterface>; diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index d9b709987f7c9a8683bf6789854df16d57c21ea0..f405d126ad7979586e0e3a813af0f32227092a33 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -6,9 +6,7 @@ #include <functional> // for function #include <memory> // for make_shared, shared_ptr -#include <string> // for wstring #include <utility> // for forward -#include <vector> // for vector #include "ftxui/component/component_base.hpp" // for Component, Components #include "ftxui/component/component_options.hpp" // for ButtonOption, CheckboxOption, MenuOption @@ -96,9 +94,9 @@ Component Slider(ConstStringRef label, ConstRef<float> increment = 5.f); Component Slider(ConstStringRef label, Ref<long> value, - ConstRef<long> min = 0l, - ConstRef<long> max = 100l, - ConstRef<long> increment = 5l); + ConstRef<long> min = 0L, + ConstRef<long> max = 100L, + ConstRef<long> increment = 5L); Component ResizableSplit(ResizableSplitOption options); Component ResizableSplitLeft(Component main, Component back, int* main_size); diff --git a/include/ftxui/component/component_base.hpp b/include/ftxui/component/component_base.hpp index 1e3fa133f287d32db33a6abeb1e32b7f7856ec41..622af0a1de4328807eb5adbc2d4b1d3314d855cc 100644 --- a/include/ftxui/component/component_base.hpp +++ b/include/ftxui/component/component_base.hpp @@ -29,14 +29,16 @@ using Components = std::vector<Component>; /// @ingroup component class ComponentBase { public: - // virtual Destructor. + explicit ComponentBase(Components children) + : children_(std::move(children)) {} virtual ~ComponentBase(); - ComponentBase() = default; - // A component is not copiable. + // A component is not copyable/movable. ComponentBase(const ComponentBase&) = delete; - void operator=(const ComponentBase&) = delete; + ComponentBase(ComponentBase&&) = delete; + ComponentBase& operator=(const ComponentBase&) = delete; + ComponentBase& operator=(ComponentBase&&) = delete; // Component hierarchy: ComponentBase* Parent() const; diff --git a/include/ftxui/component/component_options.hpp b/include/ftxui/component/component_options.hpp index 73b8a0e0849a4ae9a5c44d455ced9e43cea4b6a7..b7e771e64ff9f4fb6166953581c7eb3b375ed617 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -10,7 +10,6 @@ #include <ftxui/dom/elements.hpp> // for Element, separator #include <ftxui/util/ref.hpp> // for Ref, ConstRef, StringRef #include <functional> // for function -#include <optional> // for optional #include <string> // for string #include "ftxui/component/component_base.hpp" // for Component diff --git a/include/ftxui/component/event.hpp b/include/ftxui/component/event.hpp index 2d6f562c9a073155c08164a543ba0ea2c9833caf..6ce20e06aadccd0377e57a57a85069aea5b1d5af 100644 --- a/include/ftxui/component/event.hpp +++ b/include/ftxui/component/event.hpp @@ -5,9 +5,7 @@ #define FTXUI_COMPONENT_EVENT_HPP #include <ftxui/component/mouse.hpp> // for Mouse -#include <functional> -#include <string> // for string, operator== -#include <vector> +#include <string> // for string, operator== namespace ftxui { diff --git a/include/ftxui/component/loop.hpp b/include/ftxui/component/loop.hpp index 41b340c7d34bca6cb58c238d9370f426bb14d437..faef475c65d350bcd7dd7c933a20eb55eab8e909 100644 --- a/include/ftxui/component/loop.hpp +++ b/include/ftxui/component/loop.hpp @@ -24,11 +24,14 @@ class Loop { void RunOnceBlocking(); void Run(); - private: - // This class is non copyable. + // This class is non copyable/movable. + Loop(const Loop&) = default; + Loop(Loop&&) = delete; + Loop& operator=(Loop&&) = delete; Loop(const ScreenInteractive&) = delete; Loop& operator=(const Loop&) = delete; + private: ScreenInteractive* screen_; Component component_; }; diff --git a/include/ftxui/component/receiver.hpp b/include/ftxui/component/receiver.hpp index 95f235397104fa00a998b4a6882c42b34a79d2ae..55189cf9f6f8011d25d50b2d619cd52c2f0db4b9 100644 --- a/include/ftxui/component/receiver.hpp +++ b/include/ftxui/component/receiver.hpp @@ -7,12 +7,10 @@ #include <algorithm> // for copy, max #include <atomic> // for atomic, __atomic_base #include <condition_variable> // for condition_variable -#include <functional> -#include <iostream> -#include <memory> // for unique_ptr, make_unique -#include <mutex> // for mutex, unique_lock -#include <queue> // for queue -#include <utility> // for move +#include <memory> // for unique_ptr, make_unique +#include <mutex> // for mutex, unique_lock +#include <queue> // for queue +#include <utility> // for move namespace ftxui { @@ -54,6 +52,10 @@ template<class T> Receiver<T> MakeReceiver(); template <class T> class SenderImpl { public: + SenderImpl(const SenderImpl&) = delete; + SenderImpl(SenderImpl&&) = delete; + SenderImpl& operator=(const SenderImpl&) = delete; + SenderImpl& operator=(SenderImpl&&) = delete; void Send(T t) { receiver_->Receive(std::move(t)); } ~SenderImpl() { receiver_->ReleaseSender(); } @@ -61,7 +63,7 @@ class SenderImpl { private: friend class ReceiverImpl<T>; - SenderImpl(ReceiverImpl<T>* consumer) : receiver_(consumer) {} + explicit SenderImpl(ReceiverImpl<T>* consumer) : receiver_(consumer) {} ReceiverImpl<T>* receiver_; }; @@ -73,15 +75,17 @@ class ReceiverImpl { senders_++; return std::unique_ptr<SenderImpl<T>>(new SenderImpl<T>(this)); } - ReceiverImpl() { senders_ = 0; } + ReceiverImpl() = default; bool Receive(T* t) { while (senders_ || !queue_.empty()) { std::unique_lock<std::mutex> lock(mutex_); - if (queue_.empty()) + if (queue_.empty()) { notifier_.wait(lock); - if (queue_.empty()) + } + if (queue_.empty()) { continue; + } *t = std::move(queue_.front()); queue_.pop(); return true; @@ -91,8 +95,9 @@ class ReceiverImpl { bool ReceiveNonBlocking(T* t) { std::unique_lock<std::mutex> lock(mutex_); - if (queue_.empty()) + if (queue_.empty()) { return false; + } *t = queue_.front(); queue_.pop(); return true; @@ -127,7 +132,7 @@ class ReceiverImpl { std::mutex mutex_; std::queue<T> queue_; std::condition_variable notifier_; - std::atomic<int> senders_; + std::atomic<int> senders_{0}; }; template <class T> diff --git a/include/ftxui/dom/deprecated.hpp b/include/ftxui/dom/deprecated.hpp index f4faf8db125e07d3a4b7425872db1dd8fe89c8cd..78c66f189fdb76c3b907857762f9fec881eed1ba 100644 --- a/include/ftxui/dom/deprecated.hpp +++ b/include/ftxui/dom/deprecated.hpp @@ -4,7 +4,8 @@ #ifndef FTXUI_DOM_DEPRECATED_HPP #define FTXUI_DOM_DEPRECATED_HPP -#include "ftxui/dom/elements.hpp" +#include <ftxui/dom/node.hpp> +#include <string> namespace ftxui { Element text(std::wstring text); diff --git a/include/ftxui/dom/elements.hpp b/include/ftxui/dom/elements.hpp index b2d1b8b7eb47e0df4ce55de1b52c90fd2bb05fb2..b17a71130e418be4a5a847cfcbbf7b372aecd875 100644 --- a/include/ftxui/dom/elements.hpp +++ b/include/ftxui/dom/elements.hpp @@ -14,7 +14,6 @@ #include "ftxui/dom/node.hpp" #include "ftxui/screen/box.hpp" #include "ftxui/screen/color.hpp" -#include "ftxui/screen/screen.hpp" #include "ftxui/screen/terminal.hpp" #include "ftxui/util/ref.hpp" @@ -80,9 +79,7 @@ Decorator borderStyled(BorderStyle); Decorator borderStyled(BorderStyle, Color); Decorator borderStyled(Color); Decorator borderWith(const Pixel&); -Element window(Element title, - Element content, - BorderStyle border = ROUNDED); +Element window(Element title, Element content, BorderStyle border = ROUNDED); Element spinner(int charset_index, size_t image_index); Element paragraph(const std::string& text); Element paragraphAlignLeft(const std::string& text); diff --git a/include/ftxui/dom/node.hpp b/include/ftxui/dom/node.hpp index a462b0a0608999d9fd91a1fcd79ff70a9cbdbc10..f43157a9d35c66ef2c75cfd46a0ea33d9d5876bc 100644 --- a/include/ftxui/dom/node.hpp +++ b/include/ftxui/dom/node.hpp @@ -22,7 +22,7 @@ using Elements = std::vector<Element>; class Node { public: Node(); - Node(Elements children); + explicit Node(Elements children); Node(const Node&) = delete; Node(const Node&&) = delete; Node& operator=(const Node&) = delete; diff --git a/include/ftxui/dom/table.hpp b/include/ftxui/dom/table.hpp index 5b7fd348629cd2ff35344fe0535672dd4ee09cd3..6cfc86f46b8e8abe390b4a2374163b4cb23300ee 100644 --- a/include/ftxui/dom/table.hpp +++ b/include/ftxui/dom/table.hpp @@ -4,7 +4,6 @@ #ifndef FTXUI_DOM_TABLE #define FTXUI_DOM_TABLE -#include <memory> #include <string> // for string #include <vector> // for vector @@ -37,8 +36,8 @@ class TableSelection; class Table { public: Table(); - Table(std::vector<std::vector<std::string>>); - Table(std::vector<std::vector<Element>>); + explicit Table(std::vector<std::vector<std::string>>); + explicit Table(std::vector<std::vector<Element>>); TableSelection SelectAll(); TableSelection SelectCell(int column, int row); TableSelection SelectRow(int row_index); diff --git a/include/ftxui/dom/take_any_args.hpp b/include/ftxui/dom/take_any_args.hpp index 79491efe66bf002160a34ed814233916fc5c8a3f..52c83248d4770ebd01f542f91c225f8d4dbc4d1b 100644 --- a/include/ftxui/dom/take_any_args.hpp +++ b/include/ftxui/dom/take_any_args.hpp @@ -5,7 +5,7 @@ #define FTXUI_DOM_TAKE_ANY_ARGS_HPP // IWYU pragma: private, include "ftxui/dom/elements.hpp" -#include <type_traits> +#include <ftxui/dom/node.hpp> namespace ftxui { @@ -19,8 +19,9 @@ inline void Merge(Elements& container, Element element) { template <> inline void Merge(Elements& container, Elements elements) { - for (auto& element : elements) + for (auto& element : elements) { container.push_back(std::move(element)); + } } // Turn a set of arguments into a vector. diff --git a/include/ftxui/screen/color.hpp b/include/ftxui/screen/color.hpp index 8939e5091d0cf329ab4e6c34ec2d6194c9d87e86..52f699b5e59e41026f1b1f6ed6a67ff285752b1d 100644 --- a/include/ftxui/screen/color.hpp +++ b/include/ftxui/screen/color.hpp @@ -6,7 +6,6 @@ #include <cstdint> // for uint8_t #include <string> // for string -#include <vector> // for vector #ifdef RGB // Workaround for wingdi.h (via Windows.h) defining macros that break things. @@ -24,10 +23,12 @@ class Color { enum Palette16 : uint8_t; enum Palette256 : uint8_t; + // NOLINTBEGIN Color(); // Transparent. Color(Palette1 index); // Transparent. Color(Palette16 index); // Implicit conversion from index to Color. Color(Palette256 index); // Implicit conversion from index to Color. + // NOLINTEND Color(uint8_t red, uint8_t green, uint8_t blue); static Color RGB(uint8_t red, uint8_t green, uint8_t blue); static Color HSV(uint8_t hue, uint8_t saturation, uint8_t value); diff --git a/include/ftxui/screen/image.hpp b/include/ftxui/screen/image.hpp index 1790a9710121809abeecc0ee93538edc90a3509b..77e471992b051fdf8973cc62929301e3eb8e3655 100644 --- a/include/ftxui/screen/image.hpp +++ b/include/ftxui/screen/image.hpp @@ -4,8 +4,6 @@ #ifndef FTXUI_SCREEN_IMAGE_HPP #define FTXUI_SCREEN_IMAGE_HPP -#include <cstdint> // for uint8_t -#include <memory> #include <string> // for string, basic_string, allocator #include <vector> // for vector diff --git a/include/ftxui/screen/screen.hpp b/include/ftxui/screen/screen.hpp index 2bc77a604c291c90f4abe78af5e77395d6b83cbe..51b83a03c1926e3b41695a421a87a6f2b2319b49 100644 --- a/include/ftxui/screen/screen.hpp +++ b/include/ftxui/screen/screen.hpp @@ -5,11 +5,9 @@ #define FTXUI_SCREEN_SCREEN_HPP #include <cstdint> // for uint8_t -#include <memory> -#include <string> // for string, basic_string, allocator -#include <vector> // for vector +#include <string> // for string, basic_string, allocator +#include <vector> // for vector -#include "ftxui/screen/color.hpp" // for Color, Color::Default #include "ftxui/screen/image.hpp" // for Pixel, Image #include "ftxui/screen/terminal.hpp" // for Dimensions diff --git a/include/ftxui/screen/string.hpp b/include/ftxui/screen/string.hpp index 70e761c9c5ca30514297f48020599a47d5301e5c..ca5397bc135c67858a47cd72604b68d9a1d79ca4 100644 --- a/include/ftxui/screen/string.hpp +++ b/include/ftxui/screen/string.hpp @@ -4,10 +4,8 @@ #ifndef FTXUI_SCREEN_STRING_HPP #define FTXUI_SCREEN_STRING_HPP -#include <stddef.h> // for size_t -#include <cstdint> // for uint8_t -#include <string> // for string, wstring, to_string -#include <vector> // for vector +#include <string> // for string, wstring, to_string +#include <vector> // for vector namespace ftxui { std::string to_string(const std::wstring& s); @@ -30,6 +28,4 @@ std::vector<int> CellToGlyphIndex(const std::string& input); } // namespace ftxui -#include "ftxui/screen/deprecated.hpp" - #endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */ diff --git a/include/ftxui/util/autoreset.hpp b/include/ftxui/util/autoreset.hpp index 2c8bf4ef63f02e3402fcd4747d5c76578b365a11..ab33293d1c2f9f887b96efd64017809c1453cba6 100644 --- a/include/ftxui/util/autoreset.hpp +++ b/include/ftxui/util/autoreset.hpp @@ -16,6 +16,10 @@ class AutoReset { : variable_(variable), previous_value_(std::move(*variable)) { *variable_ = std::move(new_value); } + AutoReset(const AutoReset&) = delete; + AutoReset(AutoReset&&) = delete; + AutoReset& operator=(const AutoReset&) = delete; + AutoReset& operator=(AutoReset&&) = delete; ~AutoReset() { *variable_ = std::move(previous_value_); } private: diff --git a/include/ftxui/util/ref.hpp b/include/ftxui/util/ref.hpp index 1128b91528dcf6d2636230a55ea3c7dc9ff9f282..15e03cf740c99d493b61722c8f963939abfe2106 100644 --- a/include/ftxui/util/ref.hpp +++ b/include/ftxui/util/ref.hpp @@ -15,10 +15,12 @@ template <typename T> class ConstRef { public: ConstRef() = default; + ConstRef(T t) : variant_(std::move(t)) {} // NOLINT + ConstRef(const T* t) : variant_(t) {} // NOLINT + ConstRef& operator=(ConstRef&&) noexcept = default; ConstRef(const ConstRef<T>&) = default; - ConstRef(ConstRef<T>&&) = default; - ConstRef(T t) : variant_(std::move(t)) {} - ConstRef(const T* t) : variant_(t) {} + ConstRef(ConstRef<T>&&) noexcept = default; + ~ConstRef() = default; // Make a "reseatable" reference ConstRef<T>& operator=(const ConstRef<T>&) = default; @@ -42,10 +44,12 @@ template <typename T> class Ref { public: Ref() = default; + Ref(T t) : variant_(std::move(t)) {} // NOLINT + Ref(T* t) : variant_(t) {} // NOLINT + ~Ref() = default; + Ref& operator=(Ref&&) noexcept = default; Ref(const Ref<T>&) = default; - Ref(Ref<T>&&) = default; - Ref(T t) : variant_(std::move(t)) {} - Ref(T* t) : variant_(t) {} + Ref(Ref<T>&&) noexcept = default; // Make a "reseatable" reference. Ref<T>& operator=(const Ref<T>&) = default; @@ -77,8 +81,10 @@ class StringRef : public Ref<std::string> { public: using Ref<std::string>::Ref; - StringRef(const wchar_t* ref) : StringRef(to_string(std::wstring(ref))) {} - StringRef(const char* ref) : StringRef(std::string(ref)) {} + StringRef(const wchar_t* ref) // NOLINT + : StringRef(to_string(std::wstring(ref))) {} + StringRef(const char* ref) // NOLINT + : StringRef(std::string(ref)) {} }; /// @brief An adapter. Own or reference a constant string. For convenience, this @@ -87,19 +93,27 @@ class ConstStringRef : public ConstRef<std::string> { public: using ConstRef<std::string>::ConstRef; - ConstStringRef(const std::wstring* ref) : ConstStringRef(to_string(*ref)) {} - ConstStringRef(const std::wstring ref) : ConstStringRef(to_string(ref)) {} - ConstStringRef(const wchar_t* ref) + ConstStringRef(const std::wstring* ref) // NOLINT + : ConstStringRef(to_string(*ref)) {} + ConstStringRef(const std::wstring ref) // NOLINT + : ConstStringRef(to_string(ref)) {} + ConstStringRef(const wchar_t* ref) // NOLINT : ConstStringRef(to_string(std::wstring(ref))) {} - ConstStringRef(const char* ref) : ConstStringRef(std::string(ref)) {} + ConstStringRef(const char* ref) // NOLINT + : ConstStringRef(std::string(ref)) {} }; /// @brief An adapter. Reference a list of strings. class ConstStringListRef { public: ConstStringListRef() = default; - ConstStringListRef(const std::vector<std::string>* ref) : ref_(ref) {} - ConstStringListRef(const std::vector<std::wstring>* ref) : ref_wide_(ref) {} + ~ConstStringListRef() = default; + ConstStringListRef(ConstStringListRef&&) = delete; + ConstStringListRef& operator=(ConstStringListRef&&) = delete; + ConstStringListRef(const std::vector<std::string>* ref) // NOLINT + : ref_(ref) {} + ConstStringListRef(const std::vector<std::wstring>* ref) // NOLINT + : ref_wide_(ref) {} ConstStringListRef(const ConstStringListRef& other) = default; ConstStringListRef& operator=(const ConstStringListRef& other) = default; diff --git a/src/ftxui/component/animation.cpp b/src/ftxui/component/animation.cpp index 77aae5d1db1933a29f7dc8a87be11addaacbe0bf..6b6a1a4d2b74c91237a37aa199be49552695ce77 100644 --- a/src/ftxui/component/animation.cpp +++ b/src/ftxui/component/animation.cpp @@ -1,5 +1,4 @@ #include <cmath> // for sin, pow, sqrt, cos -#include <ratio> // for ratio #include <utility> // for move #include "ftxui/component/animation.hpp" diff --git a/src/ftxui/component/button.cpp b/src/ftxui/component/button.cpp index 04a7f84bb4e268ac7496a8e28c2e2e099cf50fda..03c7f4a03944b2046ad8c621bc71955987ab696a 100644 --- a/src/ftxui/component/button.cpp +++ b/src/ftxui/component/button.cpp @@ -3,12 +3,10 @@ // the LICENSE file. #include <functional> // for function -#include <memory> // for shared_ptr #include <utility> // for move #include "ftxui/component/animation.hpp" // for Animator, Params (ptr only) -#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse -#include "ftxui/component/component.hpp" // for Make, Button +#include "ftxui/component/component.hpp" // for Make, Button #include "ftxui/component/component_base.hpp" // for ComponentBase #include "ftxui/component/component_options.hpp" // for ButtonOption, AnimatedColorOption, AnimatedColorsOption, EntryState #include "ftxui/component/event.hpp" // for Event, Event::Return diff --git a/src/ftxui/component/button_test.cpp b/src/ftxui/component/button_test.cpp index 664f0062523857b228be732765c64d8428e53d81..8860d78f594afb1ad1a90f272300e22573963b8b 100644 --- a/src/ftxui/component/button_test.cpp +++ b/src/ftxui/component/button_test.cpp @@ -1,8 +1,6 @@ // Copyright 2022 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include <chrono> // for operator""s, chrono_literals -#include <memory> // for __shared_ptr_access, shared_ptr, allocator #include <string> // for string #include "ftxui/component/animation.hpp" // for Duration, Params diff --git a/src/ftxui/component/catch_event.cpp b/src/ftxui/component/catch_event.cpp index b24cf1baba330d5b9cbe655279f093937ab145d9..a20b6cfdbed3279eeca3aa4648471ac6c0e28c8d 100644 --- a/src/ftxui/component/catch_event.cpp +++ b/src/ftxui/component/catch_event.cpp @@ -2,9 +2,7 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <functional> // for function -#include <memory> // for __shared_ptr_access, __shared_ptr_access<>::element_type, shared_ptr -#include <type_traits> // for remove_reference, remove_reference<>::type -#include <utility> // for move +#include <utility> // for move #include "ftxui/component/component.hpp" // for Make, CatchEvent, ComponentDecorator #include "ftxui/component/component_base.hpp" // for Component, ComponentBase diff --git a/src/ftxui/component/checkbox.cpp b/src/ftxui/component/checkbox.cpp index 0495e42f7d68794997aa169252fcc82ded550781..c2a10f18324c1ea41c18fa0802d85cef34a678d3 100644 --- a/src/ftxui/component/checkbox.cpp +++ b/src/ftxui/component/checkbox.cpp @@ -4,7 +4,6 @@ #include <functional> // for function #include <utility> // for move -#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse #include "ftxui/component/component.hpp" // for Make, Checkbox #include "ftxui/component/component_base.hpp" // for Component, ComponentBase #include "ftxui/component/component_options.hpp" // for CheckboxOption, EntryState @@ -137,7 +136,7 @@ Component Checkbox(CheckboxOption option) { /// ``` // NOLINTNEXTLINE Component Checkbox(ConstStringRef label, bool* checked, CheckboxOption option) { - option.label = label; + option.label = std::move(label); option.checked = checked; return Make<CheckboxBase>(std::move(option)); } diff --git a/src/ftxui/component/collapsible.cpp b/src/ftxui/component/collapsible.cpp index bcdc16ab6b40f67426b214a76b560c2763d5dd33..380ead2f333c60ae7f9d02e853e40da1760efe87 100644 --- a/src/ftxui/component/collapsible.cpp +++ b/src/ftxui/component/collapsible.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <functional> // for function -#include <memory> // for shared_ptr, allocator #include <utility> // for move #include "ftxui/component/component.hpp" // for Checkbox, Maybe, Make, Vertical, Collapsible diff --git a/src/ftxui/component/collapsible_test.cpp b/src/ftxui/component/collapsible_test.cpp index bbea5cc1b27b6365540a44e44c46d72063631427..4b07076802dcf5c52bb3a38aca5a522ac018c0a7 100644 --- a/src/ftxui/component/collapsible_test.cpp +++ b/src/ftxui/component/collapsible_test.cpp @@ -1,4 +1,3 @@ -#include <memory> // for __shared_ptr_access, shared_ptr, allocator #include <string> // for string #include "ftxui/component/component.hpp" // for Collapsible, Renderer diff --git a/src/ftxui/component/component_fuzzer.cpp b/src/ftxui/component/component_fuzzer.cpp index ee41536ea2965e703d5dde43c4aa03d286e3adbc..f0bd6ddc06fa223ad915249fa7c410caba49fd77 100644 --- a/src/ftxui/component/component_fuzzer.cpp +++ b/src/ftxui/component/component_fuzzer.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <cassert> -#include <iostream> #include <vector> #include "ftxui/component/component.hpp" #include "ftxui/component/terminal_input_parser.hpp" @@ -11,8 +10,9 @@ using namespace ftxui; namespace { bool GeneratorBool(const char*& data, size_t& size) { - if (size == 0) + if (size == 0) { return false; + } auto out = bool(data[0] % 2); data++; diff --git a/src/ftxui/component/component_test.cpp b/src/ftxui/component/component_test.cpp index adff775fbb6f1913b91ae68e1f2e0342be51b1ee..2ee5936c243d19d18a739307289968af27e6a643 100644 --- a/src/ftxui/component/component_test.cpp +++ b/src/ftxui/component/component_test.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <memory> // for shared_ptr, __shared_ptr_access, allocator, __shared_ptr_access<>::element_type, make_shared -#include <string> // for string #include "ftxui/component/component.hpp" // for Make #include "ftxui/component/component_base.hpp" // for ComponentBase, Component diff --git a/src/ftxui/component/container.cpp b/src/ftxui/component/container.cpp index 4b2d86ad790330d224f76a0c0fc05cf6ce0339a7..1948a47d9940a5817ed5a4716ac05aafbe925c7e 100644 --- a/src/ftxui/component/container.cpp +++ b/src/ftxui/component/container.cpp @@ -5,7 +5,6 @@ #include <cstddef> // for size_t #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 Horizontal, Vertical, Tab #include "ftxui/component/component_base.hpp" // for Components, Component, ComponentBase diff --git a/src/ftxui/component/container_test.cpp b/src/ftxui/component/container_test.cpp index 1fcc79a2e3991eff843edd110f911b82cda0c7f3..7661c5c0869328064de73dc41c2458f6a574fa5f 100644 --- a/src/ftxui/component/container_test.cpp +++ b/src/ftxui/component/container_test.cpp @@ -1,8 +1,6 @@ // Copyright 2020 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include <memory> // for __shared_ptr_access, shared_ptr, allocator -#include <string> // for string #include "ftxui/component/component.hpp" // for Horizontal, Vertical, Button, Tab #include "ftxui/component/component_base.hpp" // for ComponentBase, Component diff --git a/src/ftxui/component/dropdown.cpp b/src/ftxui/component/dropdown.cpp index e105852881440efdde1c0d4272023a1dd09c7494..9034d15d624cfafe41fbc8132ab862bd7fbd4fee 100644 --- a/src/ftxui/component/dropdown.cpp +++ b/src/ftxui/component/dropdown.cpp @@ -1,9 +1,9 @@ // 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. -#include <cstddef> // for size_t +#include <cstddef> // for size_t +#include <ftxui/component/event.hpp> #include <functional> // for function -#include <memory> // for __shared_ptr_access, allocator, shared_ptr #include <string> // for string #include "ftxui/component/component.hpp" // for Maybe, Checkbox, Make, Radiobox, Vertical, Dropdown @@ -96,14 +96,14 @@ Component Dropdown(DropdownOption option) { if (is_open) { const int max_height = 12; return vbox({ - checkbox_element, + std::move(checkbox_element), separator(), - radiobox_element | vscroll_indicator | frame | + std::move(radiobox_element) | vscroll_indicator | frame | size(HEIGHT, LESS_THAN, max_height), }) | border; } - return vbox({checkbox_element, filler()}) | border; + return vbox({std::move(checkbox_element), filler()}) | border; }; } } diff --git a/src/ftxui/component/hoverable_test.cpp b/src/ftxui/component/hoverable_test.cpp index 66df43a5025b1055b805a84c45693b04cca48532..e7ac66c7be15079397330461b5f3bbf6f11e4c92 100644 --- a/src/ftxui/component/hoverable_test.cpp +++ b/src/ftxui/component/hoverable_test.cpp @@ -2,8 +2,7 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <ftxui/dom/elements.hpp> // for Element, text -#include <memory> // for shared_ptr, __shared_ptr_access, allocator -#include <string> // for string +#include <string> // for string #include "ftxui/component/component.hpp" // for Hoverable, Horizontal, operator|=, Renderer #include "ftxui/component/component_base.hpp" // for ComponentBase, Component diff --git a/src/ftxui/component/input_test.cpp b/src/ftxui/component/input_test.cpp index 863569a2e64e9e365d4efdea7a79fbeb400fcad0..f6be4c46ff6a2d19d1a7103e1588e90908ba4b53 100644 --- a/src/ftxui/component/input_test.cpp +++ b/src/ftxui/component/input_test.cpp @@ -1,7 +1,6 @@ // Copyright 2023 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include <memory> // for __shared_ptr_access, shared_ptr, allocator #include <string> // for string #include "ftxui/component/component.hpp" // for Input diff --git a/src/ftxui/component/loop.cpp b/src/ftxui/component/loop.cpp index b7725b61db00d802a7fc405ab0141f017afabf65..d16c67b4d6806cbae127fa92cdf186958595ed44 100644 --- a/src/ftxui/component/loop.cpp +++ b/src/ftxui/component/loop.cpp @@ -15,8 +15,8 @@ namespace ftxui { /// @see Component, ScreenInteractive. /// @see ScreenInteractive::Loop(). /// @see ScreenInteractive::ExitLoop(). -/// @param screen The screen to use. -/// @param component The component to run. +/// @param[in] screen The screen to use. +/// @param[in] component The component to run. // NOLINTNEXTLINE Loop::Loop(ScreenInteractive* screen, Component component) : screen_(screen), component_(std::move(component)) { diff --git a/src/ftxui/component/maybe.cpp b/src/ftxui/component/maybe.cpp index 5289f9273d83fcfdcbd37b09dd4f7474d4e06989..8a05053deec378adfd04aa5aa1db8d13a0533726 100644 --- a/src/ftxui/component/maybe.cpp +++ b/src/ftxui/component/maybe.cpp @@ -3,8 +3,7 @@ // the LICENSE file. #include <functional> // for function #include <memory> // for make_unique, __shared_ptr_access, __shared_ptr_access<>::element_type, shared_ptr -#include <type_traits> // for remove_reference, remove_reference<>::type -#include <utility> // for move +#include <utility> // for move #include "ftxui/component/component.hpp" // for ComponentDecorator, Maybe, Make #include "ftxui/component/component_base.hpp" // for Component, ComponentBase diff --git a/src/ftxui/component/menu.cpp b/src/ftxui/component/menu.cpp index 76936364e5f61e3fe4e2ec61aaef91aee284c2b4..4de8ec818027cb2f1cde62f51ea365222d3713fe 100644 --- a/src/ftxui/component/menu.cpp +++ b/src/ftxui/component/menu.cpp @@ -5,13 +5,11 @@ #include <chrono> // for milliseconds #include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include <functional> // for function -#include <memory> // for allocator_traits<>::value_type, swap #include <string> // for operator+, string #include <utility> // for move #include <vector> // for vector, __alloc_traits<>::value_type -#include "ftxui/component/animation.hpp" // for Animator, Linear -#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse +#include "ftxui/component/animation.hpp" // for Animator, Linear #include "ftxui/component/component.hpp" // for Make, Menu, MenuEntry, Toggle #include "ftxui/component/component_base.hpp" // for ComponentBase #include "ftxui/component/component_options.hpp" // for MenuOption, MenuEntryOption, UnderlineOption, AnimatedColorOption, AnimatedColorsOption, EntryState @@ -70,7 +68,7 @@ bool IsHorizontal(Direction direction) { /// @ingroup component class MenuBase : public ComponentBase, public MenuOption { public: - explicit MenuBase(MenuOption option) : MenuOption(std::move(option)) {} + explicit MenuBase(const MenuOption& option) : MenuOption(option) {} bool IsHorizontal() { return ftxui::IsHorizontal(direction); } void OnChange() { @@ -547,7 +545,7 @@ Component Menu(MenuOption option) { Component Menu(ConstStringListRef entries, int* selected, MenuOption option) { option.entries = entries; option.selected = selected; - return Menu(std::move(option)); + return Menu(option); } /// @brief An horizontal list of elements. The user can navigate through them. @@ -586,7 +584,7 @@ Component Toggle(ConstStringListRef entries, int* selected) { /// entry 3 /// ``` Component MenuEntry(ConstStringRef label, MenuEntryOption option) { - option.label = label; + option.label = std::move(label); return MenuEntry(std::move(option)); } diff --git a/src/ftxui/component/menu_test.cpp b/src/ftxui/component/menu_test.cpp index 3cda65ec8ef002c4b249d8be80f57c54707420a0..b5465eb9713a4ef633637711e2cf8e5a43ecc717 100644 --- a/src/ftxui/component/menu_test.cpp +++ b/src/ftxui/component/menu_test.cpp @@ -2,11 +2,9 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <gtest/gtest.h> // for Test, EXPECT_EQ, Message, TestPartResult, TestInfo (ptr only), TEST -#include <chrono> // for operator""s, chrono_literals #include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up -#include <memory> // for __shared_ptr_access, shared_ptr, allocator -#include <string> // for string, basic_string -#include <vector> // for vector +#include <string> // for string, basic_string +#include <vector> // for vector #include "ftxui/component/animation.hpp" // for Duration, Params #include "ftxui/component/component.hpp" // for Menu diff --git a/src/ftxui/component/modal_test.cpp b/src/ftxui/component/modal_test.cpp index f13ddd9f617293b5d3238eb39570ce9d1acdc21a..bc76d61cf7f1e14c1ac1660dd9ece944d50e999a 100644 --- a/src/ftxui/component/modal_test.cpp +++ b/src/ftxui/component/modal_test.cpp @@ -3,7 +3,6 @@ // the LICENSE file. #include <gtest/gtest.h> #include <ftxui/dom/elements.hpp> // for Element, operator|, text, border -#include <memory> // for shared_ptr, allocator, __shared_ptr_access #include "ftxui/component/component.hpp" // for Renderer, Modal #include "ftxui/component/component_base.hpp" // for ComponentBase diff --git a/src/ftxui/component/radiobox.cpp b/src/ftxui/component/radiobox.cpp index d64e2b886e1b8cb0c8c2be9b43f6ef14ce7096a8..41f29b30d6f20a7d7c2c095ad5d88373a69b4534 100644 --- a/src/ftxui/component/radiobox.cpp +++ b/src/ftxui/component/radiobox.cpp @@ -2,11 +2,9 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <functional> // for function -#include <memory> // for allocator_traits<>::value_type #include <utility> // for move #include <vector> // for vector -#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse #include "ftxui/component/component.hpp" // for Make, Radiobox #include "ftxui/component/component_base.hpp" // for ComponentBase #include "ftxui/component/component_options.hpp" // for RadioboxOption, EntryState @@ -26,7 +24,8 @@ namespace { /// @ingroup component class RadioboxBase : public ComponentBase, public RadioboxOption { public: - explicit RadioboxBase(RadioboxOption option) : RadioboxOption(option) {} + explicit RadioboxBase(const RadioboxOption& option) + : RadioboxOption(option) {} private: Element Render() override { diff --git a/src/ftxui/component/radiobox_test.cpp b/src/ftxui/component/radiobox_test.cpp index 741119e4de3184b179fc093c422971ac4ccd1eb5..b5cc77cda310755e515c70ec49f30e7458eb3a7e 100644 --- a/src/ftxui/component/radiobox_test.cpp +++ b/src/ftxui/component/radiobox_test.cpp @@ -4,9 +4,8 @@ #include <ftxui/dom/elements.hpp> // for yframe #include <ftxui/dom/node.hpp> // for Render #include <ftxui/screen/screen.hpp> // for Screen -#include <memory> // for __shared_ptr_access, shared_ptr, allocator -#include <string> // for string, basic_string -#include <vector> // for vector +#include <string> // for string, basic_string +#include <vector> // for vector #include "ftxui/component/component.hpp" // for Radiobox, operator| #include "ftxui/component/component_base.hpp" // for ComponentBase, Component diff --git a/src/ftxui/component/receiver_test.cpp b/src/ftxui/component/receiver_test.cpp index 7f915823d463115ac91fd4ab18b2989d3c3abf91..cb2cde0766563a43f69d57e15c07b0a6b695484a 100644 --- a/src/ftxui/component/receiver_test.cpp +++ b/src/ftxui/component/receiver_test.cpp @@ -1,7 +1,6 @@ // Copyright 2020 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include <string> // for string #include <thread> // for thread #include <utility> // for move diff --git a/src/ftxui/component/renderer.cpp b/src/ftxui/component/renderer.cpp index 30157ac4ad3861a6e97b595885fc0d2ac8f88ebb..8754839ec326aebc5bfb7292e1c0735abc557725 100644 --- a/src/ftxui/component/renderer.cpp +++ b/src/ftxui/component/renderer.cpp @@ -2,10 +2,8 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <functional> // for function -#include <memory> // for __shared_ptr_access, shared_ptr #include <utility> // for move -#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse #include "ftxui/component/component.hpp" // for Make, Renderer #include "ftxui/component/component_base.hpp" // for Component, ComponentBase #include "ftxui/component/event.hpp" // for Event diff --git a/src/ftxui/component/resizable_split.cpp b/src/ftxui/component/resizable_split.cpp index 86a282069911ed9e1cbac105051585fb40c6e7c9..33cbb609866c0c7d7d5e16d8cb18fe531649af8a 100644 --- a/src/ftxui/component/resizable_split.cpp +++ b/src/ftxui/component/resizable_split.cpp @@ -5,8 +5,7 @@ #include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include <ftxui/util/ref.hpp> // for Ref #include <functional> // for function -#include <memory> // for __shared_ptr_access, shared_ptr, allocator -#include <utility> // for move +#include <utility> // for move #include "ftxui/component/captured_mouse.hpp" // for CapturedMouse #include "ftxui/component/component.hpp" // for Horizontal, Make, ResizableSplit, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop diff --git a/src/ftxui/component/resizable_split_test.cpp b/src/ftxui/component/resizable_split_test.cpp index 69636311eead827b426ceb88b14affedd2a5fb1c..d74906acd8b3a92a940fd2bd5ddf885b263db285 100644 --- a/src/ftxui/component/resizable_split_test.cpp +++ b/src/ftxui/component/resizable_split_test.cpp @@ -2,8 +2,7 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up -#include <memory> // for __shared_ptr_access, shared_ptr, allocator -#include <string> // for string +#include <string> // for string #include "ftxui/component/component.hpp" // for ResizableSplit, Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop #include "ftxui/component/component_base.hpp" // for ComponentBase, Component diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index 3317063682e9ee90d31522aa5a5ecffb926e623e..997f690ab1b79395be184e59d786e41c366bb166 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -248,7 +248,7 @@ void ExecuteSignalHandlers() { void InstallSignalHandler(int sig) { auto old_signal_handler = std::signal(sig, RecordSignal); - on_exit_functions.push( + on_exit_functions.emplace( [=] { std::ignore = std::signal(sig, old_signal_handler); }); } @@ -590,14 +590,14 @@ void ScreenInteractive::Install() { // After uninstalling the new configuration, flush it to the terminal to // ensure it is fully applied: - on_exit_functions.push([] { Flush(); }); + on_exit_functions.emplace([] { Flush(); }); - on_exit_functions.push([this] { ExitLoopClosure()(); }); + on_exit_functions.emplace([this] { ExitLoopClosure()(); }); // Request the terminal to report the current cursor shape. We will restore it // on exit. std::cout << DECRQSS_DECSCUSR; - on_exit_functions.push([=] { + on_exit_functions.emplace([=] { std::cout << "\033[?25h"; // Enable cursor. std::cout << "\033[" + std::to_string(cursor_reset_shape_) + " q"; }); @@ -646,7 +646,8 @@ void ScreenInteractive::Install() { struct termios terminal; // NOLINT tcgetattr(STDIN_FILENO, &terminal); - on_exit_functions.push([=] { tcsetattr(STDIN_FILENO, TCSANOW, &terminal); }); + on_exit_functions.emplace( + [=] { tcsetattr(STDIN_FILENO, TCSANOW, &terminal); }); // Enabling raw terminal input mode terminal.c_iflag &= ~IGNBRK; // Disable ignoring break condition @@ -680,12 +681,12 @@ void ScreenInteractive::Install() { auto enable = [&](const std::vector<DECMode>& parameters) { std::cout << Set(parameters); - on_exit_functions.push([=] { std::cout << Reset(parameters); }); + on_exit_functions.emplace([=] { std::cout << Reset(parameters); }); }; auto disable = [&](const std::vector<DECMode>& parameters) { std::cout << Reset(parameters); - on_exit_functions.push([=] { std::cout << Set(parameters); }); + on_exit_functions.emplace([=] { std::cout << Set(parameters); }); }; if (use_alternative_screen_) { diff --git a/src/ftxui/component/slider.cpp b/src/ftxui/component/slider.cpp index bc1a9d689c21e8de60e21b055d8910e7fbc0d825..b1075805cab66c73c675594f2237aaf23f682125 100644 --- a/src/ftxui/component/slider.cpp +++ b/src/ftxui/component/slider.cpp @@ -1,8 +1,7 @@ // Copyright 2020 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include <algorithm> // for max, min -#include <cstdint> // for uint8_t, uint16_t, uint32_t, uint64_t +#include <algorithm> // for max, min #include <ftxui/component/component_options.hpp> // for SliderOption #include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include <string> // for allocator diff --git a/src/ftxui/component/slider_test.cpp b/src/ftxui/component/slider_test.cpp index 42113557b05c041b2b7ab333204a3f7d0377e486..c2057555726b0f78d7e0d8b4f4e37b14256dc34b 100644 --- a/src/ftxui/component/slider_test.cpp +++ b/src/ftxui/component/slider_test.cpp @@ -6,8 +6,7 @@ #include <ftxui/component/mouse.hpp> // for Mouse, Mouse::Left, Mouse::Pressed, Mouse::Released #include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include <ftxui/dom/elements.hpp> // for frame -#include <memory> // for shared_ptr, __shared_ptr_access, allocator -#include <string> // for string, to_string +#include <string> // for string, to_string #include "ftxui/component/component.hpp" // for Slider, Vertical, operator|= #include "ftxui/component/component_base.hpp" // for ComponentBase diff --git a/src/ftxui/component/terminal_input_parser.hpp b/src/ftxui/component/terminal_input_parser.hpp index 55f3b157fe43ec33e664df0de5d5bd6d2bef4d1d..524994a2f0e0a10e1855d5047cc27f55b76f7169 100644 --- a/src/ftxui/component/terminal_input_parser.hpp +++ b/src/ftxui/component/terminal_input_parser.hpp @@ -4,11 +4,9 @@ #ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER #define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER -#include <memory> // for unique_ptr #include <string> // for string #include <vector> // for vector -#include "ftxui/component/event.hpp" // for Event (ptr only) #include "ftxui/component/mouse.hpp" // for Mouse #include "ftxui/component/receiver.hpp" // for Sender #include "ftxui/component/task.hpp" // for Task @@ -19,7 +17,7 @@ struct Event; // Parse a sequence of |char| accross |time|. Produces |Event|. class TerminalInputParser { public: - TerminalInputParser(Sender<Task> out); + explicit TerminalInputParser(Sender<Task> out); void Timeout(int time); void Add(char c); @@ -46,11 +44,12 @@ class TerminalInputParser { Type type; union { Mouse mouse; - CursorPosition cursor; + CursorPosition cursor{}; int cursor_shape; }; - Output(Type t) : type(t) {} + Output(Type t) // NOLINT + : type(t) {} }; void Send(Output output); diff --git a/src/ftxui/component/terminal_input_parser_test.cpp b/src/ftxui/component/terminal_input_parser_test.cpp index ae60ff7d81e929cf1c58265c8ccee5bdcc8672ad..fec73d9de4ccfe939dc32de74435666561bab647 100644 --- a/src/ftxui/component/terminal_input_parser_test.cpp +++ b/src/ftxui/component/terminal_input_parser_test.cpp @@ -5,7 +5,6 @@ #include <ftxui/component/task.hpp> // for Task #include <initializer_list> // for initializer_list #include <memory> // for allocator, unique_ptr -#include <variant> // for get #include "ftxui/component/event.hpp" // for Event, Event::Return, Event::ArrowDown, Event::ArrowLeft, Event::ArrowRight, Event::ArrowUp, Event::Backspace, Event::End, Event::Home, Event::Custom, Event::Delete, Event::F1, Event::F10, Event::F11, Event::F12, Event::F2, Event::F3, Event::F4, Event::F5, Event::F6, Event::F7, Event::F8, Event::F9, Event::PageDown, Event::PageUp, Event::Tab, Event::TabReverse, Event::Escape #include "ftxui/component/receiver.hpp" // for MakeReceiver, ReceiverImpl diff --git a/src/ftxui/component/terminal_input_parser_test_fuzzer.cpp b/src/ftxui/component/terminal_input_parser_test_fuzzer.cpp index a10ebdfe5b9e64eede26ed22858617492923f2b7..15ccbc8c42f3d294cf1053de9e230f547528bb79 100644 --- a/src/ftxui/component/terminal_input_parser_test_fuzzer.cpp +++ b/src/ftxui/component/terminal_input_parser_test_fuzzer.cpp @@ -1,7 +1,6 @@ // 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. -#include <vector> #include "ftxui/component/terminal_input_parser.hpp" extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) { @@ -9,12 +8,14 @@ extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) { auto event_receiver = MakeReceiver<Task>(); { auto parser = TerminalInputParser(event_receiver->MakeSender()); - for (size_t i = 0; i < size; ++i) + for (size_t i = 0; i < size; ++i) { parser.Add(data[i]); + } } Task received; - while (event_receiver->Receive(&received)) - ; + while (event_receiver->Receive(&received)) { + // Do nothing. + } return 0; // Non-zero return values are reserved for future use. } diff --git a/src/ftxui/component/toggle_test.cpp b/src/ftxui/component/toggle_test.cpp index d4b8b9d799ac412f28e3d2fee2948afebabfd8e5..4ffb3db9123d74aedf913437751d041c126b8b98 100644 --- a/src/ftxui/component/toggle_test.cpp +++ b/src/ftxui/component/toggle_test.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <functional> // for function -#include <memory> // for __shared_ptr_access, shared_ptr, allocator #include <string> // for string, basic_string #include <vector> // for vector diff --git a/src/ftxui/dom/box_helper.hpp b/src/ftxui/dom/box_helper.hpp index 00b5586bbaf9ed9d3dd797fbc100af4c8a8c7964..fbc85bd00a3b4ebcc9a3dd0a10cd0c8ed5572ff3 100644 --- a/src/ftxui/dom/box_helper.hpp +++ b/src/ftxui/dom/box_helper.hpp @@ -6,8 +6,7 @@ #include <vector> -namespace ftxui { -namespace box_helper { +namespace ftxui::box_helper { struct Element { // Input: @@ -21,7 +20,6 @@ struct Element { void Compute(std::vector<Element>* elements, int target_size); -} // namespace box_helper -} // namespace ftxui +} // namespace ftxui::box_helper #endif /* end of include guard: FTXUI_DOM_BOX_HELPER_HPP */ diff --git a/src/ftxui/dom/canvas.cpp b/src/ftxui/dom/canvas.cpp index 8bf20513cf35cea05e262d9f2a6ab503689c1c3f..a78b8948b09457ca4c402a51ccbab69714e4ed47 100644 --- a/src/ftxui/dom/canvas.cpp +++ b/src/ftxui/dom/canvas.cpp @@ -341,7 +341,7 @@ void Canvas::DrawPointEllipse(int x1, int dy = x * x; int err = dx + dy; - do { + do { // NOLINT DrawPoint(x1 - x, y1 + y, true, s); DrawPoint(x1 + x, y1 + y, true, s); DrawPoint(x1 + x, y1 - y, true, s); @@ -405,7 +405,7 @@ void Canvas::DrawPointEllipseFilled(int x1, int dy = x * x; int err = dx + dy; - do { + do { // NOLINT for (int xx = x1 + x; xx <= x1 - x; ++xx) { DrawPoint(xx, y1 + y, true, s); DrawPoint(xx, y1 - y, true, s); @@ -686,7 +686,7 @@ void Canvas::DrawBlockEllipse(int x1, int dy = x * x; int err = dx + dy; - do { + do { // NOLINT DrawBlock(x1 - x, 2 * (y1 + y), true, s); DrawBlock(x1 + x, 2 * (y1 + y), true, s); DrawBlock(x1 + x, 2 * (y1 - y), true, s); @@ -752,7 +752,7 @@ void Canvas::DrawBlockEllipseFilled(int x1, int dy = x * x; int err = dx + dy; - do { + do { // NOLINT for (int xx = x1 + x; xx <= x1 - x; ++xx) { DrawBlock(xx, 2 * (y1 + y), true, s); DrawBlock(xx, 2 * (y1 - y), true, s); diff --git a/src/ftxui/dom/dbox.cpp b/src/ftxui/dom/dbox.cpp index e26d3ddeff61cfa2c032e808f700115240abe819..92971c81fe67bc120651ec867e831e8577019753 100644 --- a/src/ftxui/dom/dbox.cpp +++ b/src/ftxui/dom/dbox.cpp @@ -4,7 +4,6 @@ #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/elements.hpp" // for Element, Elements, dbox #include "ftxui/dom/node.hpp" // for Node, Elements diff --git a/src/ftxui/dom/flexbox_helper.cpp b/src/ftxui/dom/flexbox_helper.cpp index d75824ed0846040a6e9b729b8523534cb73a138e..e1a0274e9016b837d6d31fb9247071cb2e561c85 100644 --- a/src/ftxui/dom/flexbox_helper.cpp +++ b/src/ftxui/dom/flexbox_helper.cpp @@ -6,7 +6,6 @@ #include <algorithm> // for max, min #include <cstddef> // for size_t #include <ftxui/dom/flexbox_config.hpp> // for FlexboxConfig, FlexboxConfig::Direction, FlexboxConfig::AlignContent, FlexboxConfig::JustifyContent, FlexboxConfig::Wrap, FlexboxConfig::Direction::RowInversed, FlexboxConfig::AlignItems, FlexboxConfig::Direction::Row, FlexboxConfig::Direction::Column, FlexboxConfig::Direction::ColumnInversed, FlexboxConfig::Wrap::WrapInversed, FlexboxConfig::AlignContent::Stretch, FlexboxConfig::JustifyContent::Stretch, FlexboxConfig::Wrap::Wrap, FlexboxConfig::AlignContent::Center, FlexboxConfig::AlignContent::FlexEnd, FlexboxConfig::AlignContent::FlexStart, FlexboxConfig::AlignContent::SpaceAround, FlexboxConfig::AlignContent::SpaceBetween, FlexboxConfig::AlignContent::SpaceEvenly, FlexboxConfig::AlignItems::Center, FlexboxConfig::AlignItems::FlexEnd, FlexboxConfig::AlignItems::FlexStart, FlexboxConfig::AlignItems::Stretch, FlexboxConfig::JustifyContent::Center, FlexboxConfig::JustifyContent::FlexEnd, FlexboxConfig::JustifyContent::FlexStart, FlexboxConfig::JustifyContent::SpaceAround, FlexboxConfig::JustifyContent::SpaceBetween, FlexboxConfig::JustifyContent::SpaceEvenly, FlexboxConfig::Wrap::NoWrap -#include <memory> // for allocator_traits<>::value_type #include <utility> // for swap, move #include "ftxui/dom/box_helper.hpp" // for Element, Compute diff --git a/src/ftxui/dom/flexbox_helper.hpp b/src/ftxui/dom/flexbox_helper.hpp index 73d2cf4a409b576ae3bb4aafbeafd066b9119e0d..8173f3bf15b20518733b2a393f84279a29cfc5d9 100644 --- a/src/ftxui/dom/flexbox_helper.hpp +++ b/src/ftxui/dom/flexbox_helper.hpp @@ -7,8 +7,7 @@ #include <vector> #include "ftxui/dom/flexbox_config.hpp" -namespace ftxui { -namespace flexbox_helper { +namespace ftxui::flexbox_helper { struct Block { // Input: @@ -20,8 +19,8 @@ struct Block { int flex_shrink_y = 0; // Output: - int line; - int line_position; + int line{}; + int line_position{}; int x = 0; int y = 0; int dim_x = 0; @@ -38,7 +37,6 @@ struct Global { void Compute(Global& global); -} // namespace flexbox_helper -} // namespace ftxui +} // namespace ftxui::flexbox_helper #endif /* end of include guard: FTXUI_DOM_FLEXBOX_HELPER_HPP*/ diff --git a/src/ftxui/dom/flexbox_helper_test.cpp b/src/ftxui/dom/flexbox_helper_test.cpp index 011bf314f4e4f28aaf85461172450817759b6e55..f717f41cd65fa4e102cf867d6565da0bc115e3a2 100644 --- a/src/ftxui/dom/flexbox_helper_test.cpp +++ b/src/ftxui/dom/flexbox_helper_test.cpp @@ -3,7 +3,6 @@ // the LICENSE file. #include <gtest/gtest.h> #include <ftxui/dom/flexbox_config.hpp> // for FlexboxConfig, FlexboxConfig::Direction, FlexboxConfig::Direction::Column, FlexboxConfig::Direction::ColumnInversed, FlexboxConfig::Direction::Row, FlexboxConfig::Direction::RowInversed -#include <memory> // for allocator_traits<>::value_type #include "ftxui/dom/flexbox_helper.hpp" diff --git a/src/ftxui/dom/frame.cpp b/src/ftxui/dom/frame.cpp index 99f19c87bd14119b6be8b14620fd4584dca7bd54..17619eed4ae38410fdb016e5a98ecfeef415b4ae 100644 --- a/src/ftxui/dom/frame.cpp +++ b/src/ftxui/dom/frame.cpp @@ -4,7 +4,6 @@ #include <algorithm> // for max, min #include <memory> // for make_shared, __shared_ptr_access #include <utility> // for move -#include <vector> // for __alloc_traits<>::value_type #include "ftxui/dom/elements.hpp" // for Element, unpack, Elements, focus, frame, select, xframe, yframe #include "ftxui/dom/node.hpp" // for Node, Elements diff --git a/src/ftxui/dom/gauge_test.cpp b/src/ftxui/dom/gauge_test.cpp index 08fcb68a458656f55701571d94744a2b5b18fbf4..17daf4e4856be3c228aa949860c50d04df58f749 100644 --- a/src/ftxui/dom/gauge_test.cpp +++ b/src/ftxui/dom/gauge_test.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <gtest/gtest.h> -#include <memory> // for allocator #include "ftxui/dom/elements.hpp" // for gauge, gaugeUp #include "ftxui/dom/node.hpp" // for Render diff --git a/src/ftxui/dom/gridbox.cpp b/src/ftxui/dom/gridbox.cpp index 37e88bf3d80f16d9cccbb8bfd68f7a39473f8af8..ec8f1e6eddb964df97aee47287dbbb35025cf6a7 100644 --- a/src/ftxui/dom/gridbox.cpp +++ b/src/ftxui/dom/gridbox.cpp @@ -35,7 +35,7 @@ int Integrate(std::vector<int>& elements) { class GridBox : public Node { public: explicit GridBox(std::vector<Elements> lines) : lines_(std::move(lines)) { - y_size = lines_.size(); + y_size = static_cast<int>(lines_.size()); for (const auto& line : lines_) { x_size = std::max(x_size, int(line.size())); } diff --git a/src/ftxui/dom/gridbox_test.cpp b/src/ftxui/dom/gridbox_test.cpp index 64382f7844beaf5608a75d8c40ea6e6e1ebd9270..449b1538150e3efa33007bbaddf06e9ce4528d62 100644 --- a/src/ftxui/dom/gridbox_test.cpp +++ b/src/ftxui/dom/gridbox_test.cpp @@ -4,7 +4,6 @@ #include <gtest/gtest.h> #include <algorithm> // for remove #include <cstddef> // for size_t -#include <memory> // for shared_ptr #include <string> // for allocator, basic_string, string #include <vector> // for vector diff --git a/src/ftxui/dom/linear_gradient_test.cpp b/src/ftxui/dom/linear_gradient_test.cpp index 81d6f1b03c02c5037330b378a90414647772551b..4de3211446c31c9428b0364d84e62855d49e7b35 100644 --- a/src/ftxui/dom/linear_gradient_test.cpp +++ b/src/ftxui/dom/linear_gradient_test.cpp @@ -3,7 +3,6 @@ // the LICENSE file. #include <gtest/gtest.h> // for Test, EXPECT_EQ, Message, TestPartResult, TestInfo (ptr only), TEST #include <ftxui/dom/linear_gradient.hpp> // for LinearGradient::Stop, LinearGradient -#include <memory> // for allocator_traits<>::value_type #include "ftxui/dom/elements.hpp" // for operator|, text, bgcolor, color, Element #include "ftxui/dom/node.hpp" // for Render diff --git a/src/ftxui/dom/node_decorator.cpp b/src/ftxui/dom/node_decorator.cpp index 8118d35c5216aee26440c12146cc663391016d84..db53f6b7371a5126fe9d56615a39140c7812a6ce 100644 --- a/src/ftxui/dom/node_decorator.cpp +++ b/src/ftxui/dom/node_decorator.cpp @@ -2,8 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <ftxui/dom/node.hpp> // for Node, Elements -#include <memory> // for __shared_ptr_access -#include <vector> // for __alloc_traits<>::value_type #include "ftxui/dom/node_decorator.hpp" #include "ftxui/dom/requirement.hpp" // for Requirement diff --git a/src/ftxui/dom/node_decorator.hpp b/src/ftxui/dom/node_decorator.hpp index 5d96d0dbb4718a26faab32d31d79818a3e1bb27f..a37751f4b1949b27ec9e92aa1521ba6066c93a0c 100644 --- a/src/ftxui/dom/node_decorator.hpp +++ b/src/ftxui/dom/node_decorator.hpp @@ -15,7 +15,7 @@ struct Box; // Helper class. class NodeDecorator : public Node { public: - NodeDecorator(Element child) : Node(unpack(std::move(child))) {} + explicit NodeDecorator(Element child) : Node(unpack(std::move(child))) {} void ComputeRequirement() override; void SetBox(Box box) override; }; diff --git a/src/ftxui/dom/reflect.cpp b/src/ftxui/dom/reflect.cpp index b3eccc91dfdca4c2c4683d6d38e4f8654b3022f6..3155ae8ee62298c430b4a6166bd9ec625814be17 100644 --- a/src/ftxui/dom/reflect.cpp +++ b/src/ftxui/dom/reflect.cpp @@ -3,7 +3,6 @@ // the LICENSE file. #include <memory> // for make_shared, __shared_ptr_access #include <utility> // for move -#include <vector> // for __alloc_traits<>::value_type #include "ftxui/dom/elements.hpp" // for Element, unpack, Decorator, reflect #include "ftxui/dom/node.hpp" // for Node, Elements diff --git a/src/ftxui/dom/scroll_indicator.cpp b/src/ftxui/dom/scroll_indicator.cpp index ec1386a043aa07fe7671f09460206581d463bce2..dd652cd493003056f192e4f3d870451123171ee0 100644 --- a/src/ftxui/dom/scroll_indicator.cpp +++ b/src/ftxui/dom/scroll_indicator.cpp @@ -5,7 +5,6 @@ #include <memory> // for make_shared, __shared_ptr_access #include <string> // for string #include <utility> // for move -#include <vector> // for __alloc_traits<>::value_type #include "ftxui/dom/elements.hpp" // for Element, vscroll_indicator, hscroll_indicator #include "ftxui/dom/node.hpp" // for Node, Elements diff --git a/src/ftxui/dom/scroll_indicator_test.cpp b/src/ftxui/dom/scroll_indicator_test.cpp index ae5cb0b96d13747d4e844cc98c3cc3b764defe6e..711cc7f85d04fcba0c620283b0fbdd6f9204c5c8 100644 --- a/src/ftxui/dom/scroll_indicator_test.cpp +++ b/src/ftxui/dom/scroll_indicator_test.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <gtest/gtest.h> -#include <memory> // for shared_ptr #include <string> // for allocator, to_string, string #include <utility> // for move diff --git a/src/ftxui/dom/size.cpp b/src/ftxui/dom/size.cpp index 06351e2bbc6d119832157649993607862ba0ade9..a805c0981bf5986e1e004d1d7aa23a9671ac7523 100644 --- a/src/ftxui/dom/size.cpp +++ b/src/ftxui/dom/size.cpp @@ -4,7 +4,6 @@ #include <algorithm> // for min, max #include <memory> // for make_shared, __shared_ptr_access #include <utility> // for move -#include <vector> // for __alloc_traits<>::value_type #include "ftxui/dom/elements.hpp" // for Constraint, WidthOrHeight, EQUAL, GREATER_THAN, LESS_THAN, WIDTH, unpack, Decorator, Element, size #include "ftxui/dom/node.hpp" // for Node, Elements diff --git a/src/ftxui/dom/spinner.cpp b/src/ftxui/dom/spinner.cpp index 7d0035ce1cc4677df33004ad945ce4b990e435fa..4ef08c43db0a71c38ca28fe87677c8a340194a0f 100644 --- a/src/ftxui/dom/spinner.cpp +++ b/src/ftxui/dom/spinner.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <cstddef> // for size_t -#include <memory> // for allocator, allocator_traits<>::value_type #include <string> // for basic_string, string #include <utility> // for move #include <vector> // for vector, __alloc_traits<>::value_type diff --git a/src/ftxui/dom/spinner_test.cpp b/src/ftxui/dom/spinner_test.cpp index 0d6b686a367414a36caba60a9b7d5bbb0c97df17..6b46ee7dcca28a84d2418b6f7d25c770d2c1e597 100644 --- a/src/ftxui/dom/spinner_test.cpp +++ b/src/ftxui/dom/spinner_test.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <gtest/gtest.h> -#include <string> // for allocator #include "ftxui/dom/elements.hpp" // for spinner #include "ftxui/dom/node.hpp" // for Render diff --git a/src/ftxui/dom/table.cpp b/src/ftxui/dom/table.cpp index 76b91cb607470d6b0ab764cbee1a8da7972f5f5f..eb63259607226419f15df1788d932fbbeb28561b 100644 --- a/src/ftxui/dom/table.cpp +++ b/src/ftxui/dom/table.cpp @@ -73,7 +73,7 @@ Table::Table(std::vector<std::vector<Element>> input) { // private void Table::Initialize(std::vector<std::vector<Element>> input) { - input_dim_y_ = input.size(); + input_dim_y_ = static_cast<int>(input.size()); input_dim_x_ = 0; for (auto& row : input) { input_dim_x_ = std::max(input_dim_x_, int(row.size())); diff --git a/src/ftxui/dom/table_test.cpp b/src/ftxui/dom/table_test.cpp index 99a4405ac7683790cd9d1b2db261b40db5de24b6..215f1f1dd4c2c797cd531c7462c8021f63e393e8 100644 --- a/src/ftxui/dom/table_test.cpp +++ b/src/ftxui/dom/table_test.cpp @@ -2,7 +2,6 @@ // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. #include <gtest/gtest.h> -#include <memory> // for allocator #include "ftxui/dom/elements.hpp" // for LIGHT, flex, center, EMPTY, DOUBLE #include "ftxui/dom/node.hpp" // for Render diff --git a/src/ftxui/dom/text.cpp b/src/ftxui/dom/text.cpp index e8117b5b4e6032ccf8ccdc5f5a1084175907329a..228e714210c8959547806eb51710a505d703968a 100644 --- a/src/ftxui/dom/text.cpp +++ b/src/ftxui/dom/text.cpp @@ -5,7 +5,6 @@ #include <memory> // for make_shared #include <string> // for string, wstring #include <utility> // for move -#include <vector> // for vector #include "ftxui/dom/deprecated.hpp" // for text, vtext #include "ftxui/dom/elements.hpp" // for Element, text, vtext diff --git a/src/ftxui/dom/util.cpp b/src/ftxui/dom/util.cpp index c404a3261ef4633532c0f1bcd061f5ad5072597a..8fc4a9de2f033d8b6542d3531ab541e6e1eef40a 100644 --- a/src/ftxui/dom/util.cpp +++ b/src/ftxui/dom/util.cpp @@ -1,12 +1,10 @@ // Copyright 2020 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include <algorithm> // for min -#include <functional> // for function -#include <memory> // for __shared_ptr_access, make_unique -#include <type_traits> // for remove_reference, remove_reference<>::type -#include <utility> // for move -#include <vector> // for vector +#include <algorithm> // for min +#include <functional> // for function +#include <memory> // for __shared_ptr_access, make_unique +#include <utility> // for move #include "ftxui/dom/elements.hpp" // for Element, Decorator, Elements, operator|, Fit, emptyElement, nothing, operator|= #include "ftxui/dom/node.hpp" // for Node, Node::Status diff --git a/src/ftxui/screen/color.cpp b/src/ftxui/screen/color.cpp index 4646b973fc0a0bcc3c16e7f4b001b1684973ca85..3d32b684fa648d363811317a875a3898d0ec53a4 100644 --- a/src/ftxui/screen/color.cpp +++ b/src/ftxui/screen/color.cpp @@ -6,7 +6,6 @@ #include <array> // for array #include <cmath> #include <cstdint> -#include <string_view> // for literals #include "ftxui/screen/color_info.hpp" // for GetColorInfo, ColorInfo #include "ftxui/screen/terminal.hpp" // for ColorSupport, Color, Palette256, TrueColor diff --git a/src/ftxui/screen/image.cpp b/src/ftxui/screen/image.cpp index 4df80fd25c523fdcdfc0e0e2154e01eb8bc96f50..3fa3fbefd1af4c019970c808abc53745935c7f48 100644 --- a/src/ftxui/screen/image.cpp +++ b/src/ftxui/screen/image.cpp @@ -1,16 +1,9 @@ // Copyright 2020 Arthur Sonzogni. All rights reserved. // Use of this source code is governed by the MIT license that can be found in // the LICENSE file. -#include <cstdint> // for size_t -#include <iostream> // for operator<<, stringstream, basic_ostream, flush, cout, ostream -#include <limits> -#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/image.hpp" -#include "ftxui/screen/string.hpp" // for string_width namespace ftxui { diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index 28ee76713db11d654a345e8c28785b73a6104616..1a272baaa9cd3a6fb07c5a339178bdd4e013df7a 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -5,7 +5,6 @@ #include <iostream> // for operator<<, stringstream, basic_ostream, flush, cout, ostream #include <limits> #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 diff --git a/src/ftxui/screen/string_internal.hpp b/src/ftxui/screen/string_internal.hpp index 8b58eb9bee0506d0cfaac1e0a01c1ee00c3f10ff..048f327810590a6817853fcf08b087edf5498754 100644 --- a/src/ftxui/screen/string_internal.hpp +++ b/src/ftxui/screen/string_internal.hpp @@ -5,6 +5,8 @@ #define FTXUI_SCREEN_STRING_INTERNAL_HPP #include <cstdint> +#include <string> +#include <vector> namespace ftxui { diff --git a/src/ftxui/screen/util.hpp b/src/ftxui/screen/util.hpp index 91a769b8a858d464274610f864ac017022ce17bf..0f2a5f27db4fbfc546beefae8d66e7221cfcb90a 100644 --- a/src/ftxui/screen/util.hpp +++ b/src/ftxui/screen/util.hpp @@ -4,8 +4,7 @@ #ifndef FTXUI_SCREEN_UTIL_HPP #define FTXUI_SCREEN_UTIL_HPP -namespace ftxui { -namespace util { +namespace ftxui::util { // Similar to std::clamp, but allow hi to be lower than lo. template <class T> @@ -13,7 +12,6 @@ constexpr const T& clamp(const T& v, const T& lo, const T& hi) { return v < lo ? lo : hi < v ? hi : v; } -} // namespace util -} // namespace ftxui +} // namespace ftxui::util #endif /* end of include guard: FTXUI_SCREEN_UTIL_HPP */