From 8a2a9b07992c5cf556bc717996bc2f912db8bf25 Mon Sep 17 00:00:00 2001 From: Arthur Sonzogni Date: Wed, 1 May 2024 11:40:49 +0200 Subject: [PATCH] Generate compile commands for clangd. (#855) Fix all the diagnostics reported. Bug: https://github.com/ArthurSonzogni/FTXUI/issues/828 --- CMakeLists.txt | 2 + README.md | 2 +- include/ftxui/component/animation.hpp | 21 ++++------ include/ftxui/component/captured_mouse.hpp | 5 +++ include/ftxui/component/component.hpp | 8 ++-- include/ftxui/component/component_base.hpp | 10 +++-- include/ftxui/component/component_options.hpp | 1 - include/ftxui/component/event.hpp | 4 +- include/ftxui/component/loop.hpp | 7 +++- include/ftxui/component/receiver.hpp | 29 +++++++------ include/ftxui/dom/deprecated.hpp | 3 +- include/ftxui/dom/elements.hpp | 5 +-- include/ftxui/dom/node.hpp | 2 +- include/ftxui/dom/table.hpp | 5 +-- include/ftxui/dom/take_any_args.hpp | 5 ++- include/ftxui/screen/color.hpp | 3 +- include/ftxui/screen/image.hpp | 2 - include/ftxui/screen/screen.hpp | 6 +-- include/ftxui/screen/string.hpp | 8 +--- include/ftxui/util/autoreset.hpp | 4 ++ include/ftxui/util/ref.hpp | 42 ++++++++++++------- src/ftxui/component/animation.cpp | 1 - src/ftxui/component/button.cpp | 4 +- src/ftxui/component/button_test.cpp | 2 - src/ftxui/component/catch_event.cpp | 4 +- src/ftxui/component/checkbox.cpp | 3 +- src/ftxui/component/collapsible.cpp | 1 - src/ftxui/component/collapsible_test.cpp | 1 - src/ftxui/component/component_fuzzer.cpp | 4 +- src/ftxui/component/component_test.cpp | 1 - src/ftxui/component/container.cpp | 1 - src/ftxui/component/container_test.cpp | 2 - src/ftxui/component/dropdown.cpp | 10 ++--- src/ftxui/component/hoverable_test.cpp | 3 +- src/ftxui/component/input_test.cpp | 1 - src/ftxui/component/loop.cpp | 4 +- src/ftxui/component/maybe.cpp | 3 +- src/ftxui/component/menu.cpp | 10 ++--- src/ftxui/component/menu_test.cpp | 6 +-- src/ftxui/component/modal_test.cpp | 1 - src/ftxui/component/radiobox.cpp | 5 +-- src/ftxui/component/radiobox_test.cpp | 5 +-- src/ftxui/component/receiver_test.cpp | 1 - src/ftxui/component/renderer.cpp | 2 - src/ftxui/component/resizable_split.cpp | 3 +- src/ftxui/component/resizable_split_test.cpp | 3 +- src/ftxui/component/screen_interactive.cpp | 15 +++---- src/ftxui/component/slider.cpp | 3 +- src/ftxui/component/slider_test.cpp | 3 +- src/ftxui/component/terminal_input_parser.hpp | 9 ++-- .../component/terminal_input_parser_test.cpp | 1 - .../terminal_input_parser_test_fuzzer.cpp | 9 ++-- src/ftxui/component/toggle_test.cpp | 1 - src/ftxui/dom/box_helper.hpp | 6 +-- src/ftxui/dom/canvas.cpp | 8 ++-- src/ftxui/dom/dbox.cpp | 1 - src/ftxui/dom/flexbox_helper.cpp | 1 - src/ftxui/dom/flexbox_helper.hpp | 10 ++--- src/ftxui/dom/flexbox_helper_test.cpp | 1 - src/ftxui/dom/frame.cpp | 1 - src/ftxui/dom/gauge_test.cpp | 1 - src/ftxui/dom/gridbox.cpp | 2 +- src/ftxui/dom/gridbox_test.cpp | 1 - src/ftxui/dom/linear_gradient_test.cpp | 1 - src/ftxui/dom/node_decorator.cpp | 2 - src/ftxui/dom/node_decorator.hpp | 2 +- src/ftxui/dom/reflect.cpp | 1 - src/ftxui/dom/scroll_indicator.cpp | 1 - src/ftxui/dom/scroll_indicator_test.cpp | 1 - src/ftxui/dom/size.cpp | 1 - src/ftxui/dom/spinner.cpp | 1 - src/ftxui/dom/spinner_test.cpp | 1 - src/ftxui/dom/table.cpp | 2 +- src/ftxui/dom/table_test.cpp | 1 - src/ftxui/dom/text.cpp | 1 - src/ftxui/dom/util.cpp | 10 ++--- src/ftxui/screen/color.cpp | 1 - src/ftxui/screen/image.cpp | 7 ---- src/ftxui/screen/screen.cpp | 1 - src/ftxui/screen/string_internal.hpp | 2 + src/ftxui/screen/util.hpp | 6 +-- 81 files changed, 161 insertions(+), 209 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65f41db..bf4a9da 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 bfb27e0..e62b129 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 c9f665e..a04aea5 100644 --- a/include/ftxui/component/animation.hpp +++ b/include/ftxui/component/animation.hpp @@ -7,11 +7,7 @@ #include // for milliseconds, duration, steady_clock, time_point #include // 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; // 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 4ed6d75..234e12f 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; diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index d9b7099..f405d12 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -6,9 +6,7 @@ #include // for function #include // for make_shared, shared_ptr -#include // for wstring #include // for forward -#include // 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 increment = 5.f); Component Slider(ConstStringRef label, Ref value, - ConstRef min = 0l, - ConstRef max = 100l, - ConstRef increment = 5l); + ConstRef min = 0L, + ConstRef max = 100L, + ConstRef 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 1e3fa13..622af0a 100644 --- a/include/ftxui/component/component_base.hpp +++ b/include/ftxui/component/component_base.hpp @@ -29,14 +29,16 @@ using Components = std::vector; /// @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 73b8a0e..b7e771e 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -10,7 +10,6 @@ #include // for Element, separator #include // for Ref, ConstRef, StringRef #include // for function -#include // for optional #include // 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 2d6f562..6ce20e0 100644 --- a/include/ftxui/component/event.hpp +++ b/include/ftxui/component/event.hpp @@ -5,9 +5,7 @@ #define FTXUI_COMPONENT_EVENT_HPP #include // for Mouse -#include -#include // for string, operator== -#include +#include // for string, operator== namespace ftxui { diff --git a/include/ftxui/component/loop.hpp b/include/ftxui/component/loop.hpp index 41b340c..faef475 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 95f2353..55189cf 100644 --- a/include/ftxui/component/receiver.hpp +++ b/include/ftxui/component/receiver.hpp @@ -7,12 +7,10 @@ #include // for copy, max #include // for atomic, __atomic_base #include // for condition_variable -#include -#include -#include // for unique_ptr, make_unique -#include // for mutex, unique_lock -#include // for queue -#include // for move +#include // for unique_ptr, make_unique +#include // for mutex, unique_lock +#include // for queue +#include // for move namespace ftxui { @@ -54,6 +52,10 @@ template Receiver MakeReceiver(); template 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; - SenderImpl(ReceiverImpl* consumer) : receiver_(consumer) {} + explicit SenderImpl(ReceiverImpl* consumer) : receiver_(consumer) {} ReceiverImpl* receiver_; }; @@ -73,15 +75,17 @@ class ReceiverImpl { senders_++; return std::unique_ptr>(new SenderImpl(this)); } - ReceiverImpl() { senders_ = 0; } + ReceiverImpl() = default; bool Receive(T* t) { while (senders_ || !queue_.empty()) { std::unique_lock 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 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 queue_; std::condition_variable notifier_; - std::atomic senders_; + std::atomic senders_{0}; }; template diff --git a/include/ftxui/dom/deprecated.hpp b/include/ftxui/dom/deprecated.hpp index f4faf8d..78c66f1 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 +#include namespace ftxui { Element text(std::wstring text); diff --git a/include/ftxui/dom/elements.hpp b/include/ftxui/dom/elements.hpp index b2d1b8b..b17a711 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 a462b0a..f43157a 100644 --- a/include/ftxui/dom/node.hpp +++ b/include/ftxui/dom/node.hpp @@ -22,7 +22,7 @@ using Elements = std::vector; 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 5b7fd34..6cfc86f 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 #include // for string #include // for vector @@ -37,8 +36,8 @@ class TableSelection; class Table { public: Table(); - Table(std::vector>); - Table(std::vector>); + explicit Table(std::vector>); + explicit Table(std::vector>); 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 79491ef..52c8324 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 +#include 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 8939e50..52f699b 100644 --- a/include/ftxui/screen/color.hpp +++ b/include/ftxui/screen/color.hpp @@ -6,7 +6,6 @@ #include // for uint8_t #include // for string -#include // 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 1790a97..77e4719 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 // for uint8_t -#include #include // for string, basic_string, allocator #include // for vector diff --git a/include/ftxui/screen/screen.hpp b/include/ftxui/screen/screen.hpp index 2bc77a6..51b83a0 100644 --- a/include/ftxui/screen/screen.hpp +++ b/include/ftxui/screen/screen.hpp @@ -5,11 +5,9 @@ #define FTXUI_SCREEN_SCREEN_HPP #include // for uint8_t -#include -#include // for string, basic_string, allocator -#include // for vector +#include // for string, basic_string, allocator +#include // 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 70e761c..ca5397b 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 // for size_t -#include // for uint8_t -#include // for string, wstring, to_string -#include // for vector +#include // for string, wstring, to_string +#include // for vector namespace ftxui { std::string to_string(const std::wstring& s); @@ -30,6 +28,4 @@ std::vector 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 2c8bf4e..ab33293 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 1128b91..15e03cf 100644 --- a/include/ftxui/util/ref.hpp +++ b/include/ftxui/util/ref.hpp @@ -15,10 +15,12 @@ template 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&) = default; - ConstRef(ConstRef&&) = default; - ConstRef(T t) : variant_(std::move(t)) {} - ConstRef(const T* t) : variant_(t) {} + ConstRef(ConstRef&&) noexcept = default; + ~ConstRef() = default; // Make a "reseatable" reference ConstRef& operator=(const ConstRef&) = default; @@ -42,10 +44,12 @@ template 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&) = default; - Ref(Ref&&) = default; - Ref(T t) : variant_(std::move(t)) {} - Ref(T* t) : variant_(t) {} + Ref(Ref&&) noexcept = default; // Make a "reseatable" reference. Ref& operator=(const Ref&) = default; @@ -77,8 +81,10 @@ class StringRef : public Ref { public: using Ref::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 { public: using ConstRef::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* ref) : ref_(ref) {} - ConstStringListRef(const std::vector* ref) : ref_wide_(ref) {} + ~ConstStringListRef() = default; + ConstStringListRef(ConstStringListRef&&) = delete; + ConstStringListRef& operator=(ConstStringListRef&&) = delete; + ConstStringListRef(const std::vector* ref) // NOLINT + : ref_(ref) {} + ConstStringListRef(const std::vector* 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 77aae5d..6b6a1a4 100644 --- a/src/ftxui/component/animation.cpp +++ b/src/ftxui/component/animation.cpp @@ -1,5 +1,4 @@ #include // for sin, pow, sqrt, cos -#include // for ratio #include // for move #include "ftxui/component/animation.hpp" diff --git a/src/ftxui/component/button.cpp b/src/ftxui/component/button.cpp index 04a7f84..03c7f4a 100644 --- a/src/ftxui/component/button.cpp +++ b/src/ftxui/component/button.cpp @@ -3,12 +3,10 @@ // the LICENSE file. #include // for function -#include // for shared_ptr #include // 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 664f006..8860d78 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 // for operator""s, chrono_literals -#include // for __shared_ptr_access, shared_ptr, allocator #include // 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 b24cf1b..a20b6cf 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 // for function -#include // for __shared_ptr_access, __shared_ptr_access<>::element_type, shared_ptr -#include // for remove_reference, remove_reference<>::type -#include // for move +#include // 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 0495e42..c2a10f1 100644 --- a/src/ftxui/component/checkbox.cpp +++ b/src/ftxui/component/checkbox.cpp @@ -4,7 +4,6 @@ #include // for function #include // 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(std::move(option)); } diff --git a/src/ftxui/component/collapsible.cpp b/src/ftxui/component/collapsible.cpp index bcdc16a..380ead2 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 // for function -#include // for shared_ptr, allocator #include // 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 bbea5cc..4b07076 100644 --- a/src/ftxui/component/collapsible_test.cpp +++ b/src/ftxui/component/collapsible_test.cpp @@ -1,4 +1,3 @@ -#include // for __shared_ptr_access, shared_ptr, allocator #include // 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 ee41536..f0bd6dd 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 -#include #include #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 adff775..2ee5936 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 // for shared_ptr, __shared_ptr_access, allocator, __shared_ptr_access<>::element_type, make_shared -#include // 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 4b2d86a..1948a47 100644 --- a/src/ftxui/component/container.cpp +++ b/src/ftxui/component/container.cpp @@ -5,7 +5,6 @@ #include // for size_t #include // for make_shared, __shared_ptr_access, allocator, shared_ptr, allocator_traits<>::value_type #include // for move -#include // 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 1fcc79a..7661c5c 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 // for __shared_ptr_access, shared_ptr, allocator -#include // 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 e105852..9034d15 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 // for size_t +#include // for size_t +#include #include // for function -#include // for __shared_ptr_access, allocator, shared_ptr #include // 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 66df43a..e7ac66c 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 // for Element, text -#include // for shared_ptr, __shared_ptr_access, allocator -#include // for string +#include // 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 863569a..f6be4c4 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 // for __shared_ptr_access, shared_ptr, allocator #include // for string #include "ftxui/component/component.hpp" // for Input diff --git a/src/ftxui/component/loop.cpp b/src/ftxui/component/loop.cpp index b7725b6..d16c67b 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 5289f92..8a05053 100644 --- a/src/ftxui/component/maybe.cpp +++ b/src/ftxui/component/maybe.cpp @@ -3,8 +3,7 @@ // the LICENSE file. #include // for function #include // for make_unique, __shared_ptr_access, __shared_ptr_access<>::element_type, shared_ptr -#include // for remove_reference, remove_reference<>::type -#include // for move +#include // 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 7693636..4de8ec8 100644 --- a/src/ftxui/component/menu.cpp +++ b/src/ftxui/component/menu.cpp @@ -5,13 +5,11 @@ #include // for milliseconds #include // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include // for function -#include // for allocator_traits<>::value_type, swap #include // for operator+, string #include // for move #include // 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 3cda65e..b5465eb 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 // for Test, EXPECT_EQ, Message, TestPartResult, TestInfo (ptr only), TEST -#include // for operator""s, chrono_literals #include // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up -#include // for __shared_ptr_access, shared_ptr, allocator -#include // for string, basic_string -#include // for vector +#include // for string, basic_string +#include // 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 f13ddd9..bc76d61 100644 --- a/src/ftxui/component/modal_test.cpp +++ b/src/ftxui/component/modal_test.cpp @@ -3,7 +3,6 @@ // the LICENSE file. #include #include // for Element, operator|, text, border -#include // 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 d64e2b8..41f29b3 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 // for function -#include // for allocator_traits<>::value_type #include // for move #include // 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 741119e..b5cc77c 100644 --- a/src/ftxui/component/radiobox_test.cpp +++ b/src/ftxui/component/radiobox_test.cpp @@ -4,9 +4,8 @@ #include // for yframe #include // for Render #include // for Screen -#include // for __shared_ptr_access, shared_ptr, allocator -#include // for string, basic_string -#include // for vector +#include // for string, basic_string +#include // 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 7f91582..cb2cde0 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 // for string #include // for thread #include // for move diff --git a/src/ftxui/component/renderer.cpp b/src/ftxui/component/renderer.cpp index 30157ac..8754839 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 // for function -#include // for __shared_ptr_access, shared_ptr #include // 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 86a2820..33cbb60 100644 --- a/src/ftxui/component/resizable_split.cpp +++ b/src/ftxui/component/resizable_split.cpp @@ -5,8 +5,7 @@ #include // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include // for Ref #include // for function -#include // for __shared_ptr_access, shared_ptr, allocator -#include // for move +#include // 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 6963631..d74906a 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 // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up -#include // for __shared_ptr_access, shared_ptr, allocator -#include // for string +#include // 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 3317063..997f690 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& 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& 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 bc1a9d6..b107580 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 // for max, min -#include // for uint8_t, uint16_t, uint32_t, uint64_t +#include // for max, min #include // for SliderOption #include // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include // for allocator diff --git a/src/ftxui/component/slider_test.cpp b/src/ftxui/component/slider_test.cpp index 4211355..c205755 100644 --- a/src/ftxui/component/slider_test.cpp +++ b/src/ftxui/component/slider_test.cpp @@ -6,8 +6,7 @@ #include // for Mouse, Mouse::Left, Mouse::Pressed, Mouse::Released #include // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up #include // for frame -#include // for shared_ptr, __shared_ptr_access, allocator -#include // for string, to_string +#include // 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 55f3b15..524994a 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 // for unique_ptr #include // for string #include // 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 out); + explicit TerminalInputParser(Sender 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 ae60ff7..fec73d9 100644 --- a/src/ftxui/component/terminal_input_parser_test.cpp +++ b/src/ftxui/component/terminal_input_parser_test.cpp @@ -5,7 +5,6 @@ #include // for Task #include // for initializer_list #include // for allocator, unique_ptr -#include // 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 a10ebdf..15ccbc8 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 #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(); { 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 d4b8b9d..4ffb3db 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 // for function -#include // for __shared_ptr_access, shared_ptr, allocator #include // for string, basic_string #include // for vector diff --git a/src/ftxui/dom/box_helper.hpp b/src/ftxui/dom/box_helper.hpp index 00b5586..fbc85bd 100644 --- a/src/ftxui/dom/box_helper.hpp +++ b/src/ftxui/dom/box_helper.hpp @@ -6,8 +6,7 @@ #include -namespace ftxui { -namespace box_helper { +namespace ftxui::box_helper { struct Element { // Input: @@ -21,7 +20,6 @@ struct Element { void Compute(std::vector* 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 8bf2051..a78b894 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 e26d3dd..92971c8 100644 --- a/src/ftxui/dom/dbox.cpp +++ b/src/ftxui/dom/dbox.cpp @@ -4,7 +4,6 @@ #include // for max #include // for __shared_ptr_access, shared_ptr, make_shared #include // for move -#include // 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 d75824e..e1a0274 100644 --- a/src/ftxui/dom/flexbox_helper.cpp +++ b/src/ftxui/dom/flexbox_helper.cpp @@ -6,7 +6,6 @@ #include // for max, min #include // for size_t #include // 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 // for allocator_traits<>::value_type #include // 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 73d2cf4..8173f3b 100644 --- a/src/ftxui/dom/flexbox_helper.hpp +++ b/src/ftxui/dom/flexbox_helper.hpp @@ -7,8 +7,7 @@ #include #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 011bf31..f717f41 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 #include // for FlexboxConfig, FlexboxConfig::Direction, FlexboxConfig::Direction::Column, FlexboxConfig::Direction::ColumnInversed, FlexboxConfig::Direction::Row, FlexboxConfig::Direction::RowInversed -#include // 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 99f19c8..17619ee 100644 --- a/src/ftxui/dom/frame.cpp +++ b/src/ftxui/dom/frame.cpp @@ -4,7 +4,6 @@ #include // for max, min #include // for make_shared, __shared_ptr_access #include // for move -#include // 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 08fcb68..17daf4e 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 -#include // 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 37e88bf..ec8f1e6 100644 --- a/src/ftxui/dom/gridbox.cpp +++ b/src/ftxui/dom/gridbox.cpp @@ -35,7 +35,7 @@ int Integrate(std::vector& elements) { class GridBox : public Node { public: explicit GridBox(std::vector lines) : lines_(std::move(lines)) { - y_size = lines_.size(); + y_size = static_cast(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 64382f7..449b153 100644 --- a/src/ftxui/dom/gridbox_test.cpp +++ b/src/ftxui/dom/gridbox_test.cpp @@ -4,7 +4,6 @@ #include #include // for remove #include // for size_t -#include // for shared_ptr #include // for allocator, basic_string, string #include // for vector diff --git a/src/ftxui/dom/linear_gradient_test.cpp b/src/ftxui/dom/linear_gradient_test.cpp index 81d6f1b..4de3211 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 // for Test, EXPECT_EQ, Message, TestPartResult, TestInfo (ptr only), TEST #include // for LinearGradient::Stop, LinearGradient -#include // 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 8118d35..db53f6b 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 // for Node, Elements -#include // for __shared_ptr_access -#include // 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 5d96d0d..a37751f 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 b3eccc9..3155ae8 100644 --- a/src/ftxui/dom/reflect.cpp +++ b/src/ftxui/dom/reflect.cpp @@ -3,7 +3,6 @@ // the LICENSE file. #include // for make_shared, __shared_ptr_access #include // for move -#include // 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 ec1386a..dd652cd 100644 --- a/src/ftxui/dom/scroll_indicator.cpp +++ b/src/ftxui/dom/scroll_indicator.cpp @@ -5,7 +5,6 @@ #include // for make_shared, __shared_ptr_access #include // for string #include // for move -#include // 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 ae5cb0b..711cc7f 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 -#include // for shared_ptr #include // for allocator, to_string, string #include // for move diff --git a/src/ftxui/dom/size.cpp b/src/ftxui/dom/size.cpp index 06351e2..a805c09 100644 --- a/src/ftxui/dom/size.cpp +++ b/src/ftxui/dom/size.cpp @@ -4,7 +4,6 @@ #include // for min, max #include // for make_shared, __shared_ptr_access #include // for move -#include // 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 7d0035c..4ef08c4 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 // for size_t -#include // for allocator, allocator_traits<>::value_type #include // for basic_string, string #include // for move #include // for vector, __alloc_traits<>::value_type diff --git a/src/ftxui/dom/spinner_test.cpp b/src/ftxui/dom/spinner_test.cpp index 0d6b686..6b46ee7 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 -#include // 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 76b91cb..eb63259 100644 --- a/src/ftxui/dom/table.cpp +++ b/src/ftxui/dom/table.cpp @@ -73,7 +73,7 @@ Table::Table(std::vector> input) { // private void Table::Initialize(std::vector> input) { - input_dim_y_ = input.size(); + input_dim_y_ = static_cast(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 99a4405..215f1f1 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 -#include // 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 e8117b5..228e714 100644 --- a/src/ftxui/dom/text.cpp +++ b/src/ftxui/dom/text.cpp @@ -5,7 +5,6 @@ #include // for make_shared #include // for string, wstring #include // for move -#include // 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 c404a32..8fc4a9d 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 // for min -#include // for function -#include // for __shared_ptr_access, make_unique -#include // for remove_reference, remove_reference<>::type -#include // for move -#include // for vector +#include // for min +#include // for function +#include // for __shared_ptr_access, make_unique +#include // 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 4646b97..3d32b68 100644 --- a/src/ftxui/screen/color.cpp +++ b/src/ftxui/screen/color.cpp @@ -6,7 +6,6 @@ #include // for array #include #include -#include // 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 4df80fd..3fa3fbe 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 // for size_t -#include // for operator<<, stringstream, basic_ostream, flush, cout, ostream -#include -#include // for _Rb_tree_const_iterator, map, operator!=, operator== -#include // for allocator, allocator_traits<>::value_type #include // IWYU pragma: keep -#include // 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 28ee767..1a272ba 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -5,7 +5,6 @@ #include // for operator<<, stringstream, basic_ostream, flush, cout, ostream #include #include // for _Rb_tree_const_iterator, map, operator!=, operator== -#include // for allocator, allocator_traits<>::value_type #include // IWYU pragma: keep #include // for pair diff --git a/src/ftxui/screen/string_internal.hpp b/src/ftxui/screen/string_internal.hpp index 8b58eb9..048f327 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 +#include +#include namespace ftxui { diff --git a/src/ftxui/screen/util.hpp b/src/ftxui/screen/util.hpp index 91a769b..0f2a5f2 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 @@ -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 */