mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-05-05 22:01:13 +08:00
Fix compiler nits.
This commit is contained in:
parent
96e8b8d92e
commit
bc682d25a6
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -23,7 +23,6 @@ class DBox : public Node {
|
||||
void ComputeRequirement() override {
|
||||
requirement_ = Requirement{};
|
||||
for (auto& child : children_) {
|
||||
|
||||
child->ComputeRequirement();
|
||||
|
||||
// Propagate the focused requirement.
|
||||
|
@ -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,8 +194,8 @@ class Flexbox : public Node {
|
||||
continue;
|
||||
}
|
||||
|
||||
Selection selection_line =
|
||||
IsColumnOriented() ? selection_lines.SaturateHorizontal(box)
|
||||
Selection selection_line = IsColumnOriented()
|
||||
? selection_lines.SaturateHorizontal(box)
|
||||
: selection_lines.SaturateVertical(box);
|
||||
|
||||
for (auto& block : line.blocks) {
|
||||
|
@ -46,7 +46,6 @@ struct Global {
|
||||
int size_y;
|
||||
};
|
||||
|
||||
|
||||
void Compute(Global& global);
|
||||
|
||||
} // namespace ftxui::flexbox_helper
|
||||
|
@ -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 {
|
||||
|
@ -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 <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 {
|
||||
|
||||
|
@ -1,6 +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 <functional> // for function
|
||||
#include <sstream> // for basic_istream, stringstream
|
||||
#include <string> // for string, allocator, getline
|
||||
#include <utility> // for move
|
||||
@ -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;
|
||||
|
@ -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()) {
|
||||
|
@ -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 <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);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "ftxui/dom/table.hpp"
|
||||
|
||||
#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
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user