Fix compiler nits.

This commit is contained in:
ArthurSonzogni 2025-03-22 17:30:34 +01:00
parent 96e8b8d92e
commit bc682d25a6
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C
15 changed files with 43 additions and 29 deletions

View File

@ -16,6 +16,7 @@
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, Element
#include "ftxui/dom/node.hpp" // for Node, Elements
#include "ftxui/screen/box.hpp" // for Box
namespace ftxui::animation {
class Params;

View File

@ -163,7 +163,7 @@ class VerticalContainer : public ContainerBase {
return false;
}
int old_selected = *selector_;
const int old_selected = *selector_;
if (event.mouse().button == Mouse::WheelUp) {
MoveSelector(-1);
}

View File

@ -16,7 +16,6 @@
#include "ftxui/dom/elements.hpp" // for operator|, text, Element, xflex, hbox, color, underlined, reflect, Decorator, dim, vcenter, focus, nothing, select, yflex, gaugeDirection
#include "ftxui/screen/box.hpp" // for Box
#include "ftxui/screen/color.hpp" // for Color, Color::GrayDark, Color::White
#include "ftxui/screen/util.hpp" // for clamp
#include "ftxui/util/ref.hpp" // for ConstRef, Ref, ConstStringRef
namespace ftxui {

View File

@ -23,7 +23,6 @@ class DBox : public Node {
void ComputeRequirement() override {
requirement_ = Requirement{};
for (auto& child : children_) {
child->ComputeRequirement();
// Propagate the focused requirement.

View File

@ -4,6 +4,7 @@
#include <algorithm> // for min, max
#include <cstddef> // for size_t
#include <memory> // for __shared_ptr_access, shared_ptr, allocator_traits<>::value_type, make_shared
#include <tuple> // for ignore
#include <utility> // for move, swap
#include <vector> // for vector
@ -12,6 +13,7 @@
#include "ftxui/dom/flexbox_helper.hpp" // for Block, Global, Compute
#include "ftxui/dom/node.hpp" // for Node, Elements, Node::Status
#include "ftxui/dom/requirement.hpp" // for Requirement
#include "ftxui/dom/selection.hpp" // for Selection
#include "ftxui/screen/box.hpp" // for Box
namespace ftxui {
@ -192,9 +194,9 @@ class Flexbox : public Node {
continue;
}
Selection selection_line =
IsColumnOriented() ? selection_lines.SaturateHorizontal(box)
: selection_lines.SaturateVertical(box);
Selection selection_line = IsColumnOriented()
? selection_lines.SaturateHorizontal(box)
: selection_lines.SaturateVertical(box);
for (auto& block : line.blocks) {
std::ignore = block;

View File

@ -46,7 +46,6 @@ struct Global {
int size_y;
};
void Compute(Global& global);
} // namespace ftxui::flexbox_helper

View File

@ -11,8 +11,8 @@
#include "ftxui/dom/elements.hpp" // for Element, Elements, hbox
#include "ftxui/dom/node.hpp" // for Node, Elements
#include "ftxui/dom/requirement.hpp" // for Requirement
#include "ftxui/dom/selection.hpp" // for Selection
#include "ftxui/screen/box.hpp" // for Box
namespace ftxui {
namespace {

View File

@ -2,11 +2,13 @@
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <ftxui/screen/box.hpp> // for Box
#include <utility> // for move
#include <string>
#include <utility> // for move
#include <cstddef>
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/selection.hpp" // for Selection
#include "ftxui/screen/screen.hpp" // for Screen
#include "ftxui/screen/util.hpp" // for clamp
namespace ftxui {

View File

@ -1,9 +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 <sstream> // for basic_istream, stringstream
#include <string> // for string, allocator, getline
#include <utility> // for move
#include <functional> // for function
#include <sstream> // for basic_istream, stringstream
#include <string> // for string, allocator, getline
#include <utility> // for move
#include "ftxui/dom/elements.hpp" // for flexbox, Element, text, Elements, operator|, xflex, paragraph, paragraphAlignCenter, paragraphAlignJustify, paragraphAlignLeft, paragraphAlignRight
#include "ftxui/dom/flexbox_config.hpp" // for FlexboxConfig, FlexboxConfig::JustifyContent, FlexboxConfig::JustifyContent::Center, FlexboxConfig::JustifyContent::FlexEnd, FlexboxConfig::JustifyContent::SpaceBetween
@ -22,7 +23,7 @@ Elements Split(const std::string& the_text) {
}
Element Split(const std::string& paragraph,
std::function<Element(std::string)> f) {
const std::function<Element(std::string)>& f) {
Elements output;
std::stringstream ss(paragraph);
std::string line;

View File

@ -4,8 +4,9 @@
#include "ftxui/dom/selection.hpp" // for Selection
#include <algorithm> // for max, min
#include <string> // for string
#include <tuple> // for ignore
#include "ftxui/dom/elements.hpp" // for Element, inverted
#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
namespace ftxui {
@ -15,14 +16,15 @@ class Unselectable : public NodeDecorator {
public:
using NodeDecorator::NodeDecorator;
void Select(Selection&) override {
void Select(Selection& ignored) override {
std::ignore = ignored;
// Overwrite the select method to do nothing.
}
};
} // namespace
/// @brief Create an empty selection.
Selection::Selection() : empty_(true) {}
Selection::Selection() = default;
/// @brief Create a selection.
/// @param start_x The x coordinate of the start of the selection.
@ -99,7 +101,9 @@ Selection Selection::SaturateHorizontal(Box box) {
end_y = box.y_min;
}
}
return Selection(start_x, start_y, end_x, end_y, parent_);
return {
start_x, start_y, end_x, end_y, parent_,
};
}
/// @brief Saturate the selection to be inside the box.
@ -136,12 +140,13 @@ Selection Selection::SaturateVertical(Box box) {
end_y = box.y_min;
}
}
return Selection(start_x, start_y, end_x, end_y, parent_);
return {start_x, start_y, end_x, end_y, parent_};
}
void Selection::AddPart(const std::string& part, int y, int left, int right) {
if (parent_ != this) {
return parent_->AddPart(part, y, left, right);
parent_->AddPart(part, y, left, right);
return;
}
[&] {
if (parts_.str().empty()) {

View File

@ -1,14 +1,15 @@
// Copyright 2024 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 make_shared
#include <utility> // for move
#include <functional> // for function
#include <memory> // for make_shared
#include <utility> // for move
#include "ftxui/dom/elements.hpp" // for Element, Decorator, bgcolor, color
#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
#include "ftxui/screen/box.hpp" // for Box
#include "ftxui/screen/color.hpp" // for Color
#include "ftxui/screen/screen.hpp" // for Pixel, Screen
#include "ftxui/screen/pixel.hpp" // for Pixel
#include "ftxui/screen/screen.hpp" // for Screen
namespace ftxui {
@ -16,7 +17,8 @@ namespace {
class SelectionStyleReset : public NodeDecorator {
public:
SelectionStyleReset(Element child) : NodeDecorator(std::move(child)) {}
explicit SelectionStyleReset(Element child)
: NodeDecorator(std::move(child)) {}
void Render(Screen& screen) final {
auto old_style = screen.GetSelectionStyle();
@ -28,7 +30,7 @@ class SelectionStyleReset : public NodeDecorator {
class SelectionStyle : public NodeDecorator {
public:
SelectionStyle(Element child, std::function<void(Pixel&)> style)
SelectionStyle(Element child, const std::function<void(Pixel&)>& style)
: NodeDecorator(std::move(child)), style_(style) {}
void Render(Screen& screen) final {
@ -80,6 +82,7 @@ Decorator selectionColor(Color foreground) {
/// @brief Set the style of an element when selected.
/// @param style The style to be applied.
/// Note that the style is applied on top of the existing style.
// NOLINTNEXTLINE
Decorator selectionStyle(std::function<void(Pixel&)> style) {
return [style](Element child) -> Element {
return std::make_shared<SelectionStyle>(std::move(child), style);

View File

@ -3,7 +3,8 @@
// the LICENSE file.
#include "ftxui/dom/table.hpp"
#include <algorithm> // for max
#include <algorithm> // for max
#include <initializer_list> // for initializer_list
#include <memory> // for allocator, shared_ptr, allocator_traits<>::value_type
#include <utility> // for move, swap
#include <vector> // for vector

View File

@ -11,6 +11,7 @@
#include "ftxui/dom/elements.hpp" // for Element, text, vtext
#include "ftxui/dom/node.hpp" // for Node
#include "ftxui/dom/requirement.hpp" // for Requirement
#include "ftxui/dom/selection.hpp" // for Selection
#include "ftxui/screen/box.hpp" // for Box
#include "ftxui/screen/screen.hpp" // for Pixel, Screen
#include "ftxui/screen/string.hpp" // for string_width, Utf8ToGlyphs, to_string
@ -35,7 +36,7 @@ class Text : public Node {
return;
}
Selection selection_saturated = selection.SaturateHorizontal(box_);
const Selection selection_saturated = selection.SaturateHorizontal(box_);
has_selection = true;
selection_start_ = selection_saturated.GetBox().x_min;

View File

@ -11,6 +11,7 @@
#include "ftxui/dom/elements.hpp" // for Element, Elements, vbox
#include "ftxui/dom/node.hpp" // for Node, Elements
#include "ftxui/dom/requirement.hpp" // for Requirement
#include "ftxui/dom/selection.hpp" // for Selection
#include "ftxui/screen/box.hpp" // for Box
namespace ftxui {

View File

@ -553,7 +553,7 @@ const Screen::SelectionStyle& Screen::GetSelectionStyle() const {
/// @brief Set the current selection style.
/// @see GetSelectionStyle
void Screen::SetSelectionStyle(SelectionStyle decorator) {
selection_style_ = decorator;
selection_style_ = std::move(decorator);
}
} // namespace ftxui