mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-05-06 07:07:51 +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/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
||||||
#include "ftxui/dom/elements.hpp" // for text, Element
|
#include "ftxui/dom/elements.hpp" // for text, Element
|
||||||
#include "ftxui/dom/node.hpp" // for Node, Elements
|
#include "ftxui/dom/node.hpp" // for Node, Elements
|
||||||
|
#include "ftxui/screen/box.hpp" // for Box
|
||||||
|
|
||||||
namespace ftxui::animation {
|
namespace ftxui::animation {
|
||||||
class Params;
|
class Params;
|
||||||
|
@ -163,7 +163,7 @@ class VerticalContainer : public ContainerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int old_selected = *selector_;
|
const int old_selected = *selector_;
|
||||||
if (event.mouse().button == Mouse::WheelUp) {
|
if (event.mouse().button == Mouse::WheelUp) {
|
||||||
MoveSelector(-1);
|
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/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/box.hpp" // for Box
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::GrayDark, Color::White
|
#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
|
#include "ftxui/util/ref.hpp" // for ConstRef, Ref, ConstStringRef
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
@ -23,7 +23,6 @@ class DBox : public Node {
|
|||||||
void ComputeRequirement() override {
|
void ComputeRequirement() override {
|
||||||
requirement_ = Requirement{};
|
requirement_ = Requirement{};
|
||||||
for (auto& child : children_) {
|
for (auto& child : children_) {
|
||||||
|
|
||||||
child->ComputeRequirement();
|
child->ComputeRequirement();
|
||||||
|
|
||||||
// Propagate the focused requirement.
|
// Propagate the focused requirement.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <algorithm> // for min, max
|
#include <algorithm> // for min, max
|
||||||
#include <cstddef> // for size_t
|
#include <cstddef> // for size_t
|
||||||
#include <memory> // for __shared_ptr_access, shared_ptr, allocator_traits<>::value_type, make_shared
|
#include <memory> // for __shared_ptr_access, shared_ptr, allocator_traits<>::value_type, make_shared
|
||||||
|
#include <tuple> // for ignore
|
||||||
#include <utility> // for move, swap
|
#include <utility> // for move, swap
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
@ -12,6 +13,7 @@
|
|||||||
#include "ftxui/dom/flexbox_helper.hpp" // for Block, Global, Compute
|
#include "ftxui/dom/flexbox_helper.hpp" // for Block, Global, Compute
|
||||||
#include "ftxui/dom/node.hpp" // for Node, Elements, Node::Status
|
#include "ftxui/dom/node.hpp" // for Node, Elements, Node::Status
|
||||||
#include "ftxui/dom/requirement.hpp" // for Requirement
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
||||||
|
#include "ftxui/dom/selection.hpp" // for Selection
|
||||||
#include "ftxui/screen/box.hpp" // for Box
|
#include "ftxui/screen/box.hpp" // for Box
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
@ -192,9 +194,9 @@ class Flexbox : public Node {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection selection_line =
|
Selection selection_line = IsColumnOriented()
|
||||||
IsColumnOriented() ? selection_lines.SaturateHorizontal(box)
|
? selection_lines.SaturateHorizontal(box)
|
||||||
: selection_lines.SaturateVertical(box);
|
: selection_lines.SaturateVertical(box);
|
||||||
|
|
||||||
for (auto& block : line.blocks) {
|
for (auto& block : line.blocks) {
|
||||||
std::ignore = block;
|
std::ignore = block;
|
||||||
|
@ -46,7 +46,6 @@ struct Global {
|
|||||||
int size_y;
|
int size_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void Compute(Global& global);
|
void Compute(Global& global);
|
||||||
|
|
||||||
} // namespace ftxui::flexbox_helper
|
} // namespace ftxui::flexbox_helper
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
#include "ftxui/dom/elements.hpp" // for Element, Elements, hbox
|
#include "ftxui/dom/elements.hpp" // for Element, Elements, hbox
|
||||||
#include "ftxui/dom/node.hpp" // for Node, Elements
|
#include "ftxui/dom/node.hpp" // for Node, Elements
|
||||||
#include "ftxui/dom/requirement.hpp" // for Requirement
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
||||||
|
#include "ftxui/dom/selection.hpp" // for Selection
|
||||||
#include "ftxui/screen/box.hpp" // for Box
|
#include "ftxui/screen/box.hpp" // for Box
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
// Use of this source code is governed by the MIT license that can be found in
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include <ftxui/screen/box.hpp> // for Box
|
#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/node.hpp"
|
||||||
|
#include "ftxui/dom/selection.hpp" // for Selection
|
||||||
#include "ftxui/screen/screen.hpp" // for Screen
|
#include "ftxui/screen/screen.hpp" // for Screen
|
||||||
#include "ftxui/screen/util.hpp" // for clamp
|
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include <sstream> // for basic_istream, stringstream
|
#include <functional> // for function
|
||||||
#include <string> // for string, allocator, getline
|
#include <sstream> // for basic_istream, stringstream
|
||||||
#include <utility> // for move
|
#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/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
|
#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,
|
Element Split(const std::string& paragraph,
|
||||||
std::function<Element(std::string)> f) {
|
const std::function<Element(std::string)>& f) {
|
||||||
Elements output;
|
Elements output;
|
||||||
std::stringstream ss(paragraph);
|
std::stringstream ss(paragraph);
|
||||||
std::string line;
|
std::string line;
|
||||||
|
@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
#include "ftxui/dom/selection.hpp" // for Selection
|
#include "ftxui/dom/selection.hpp" // for Selection
|
||||||
#include <algorithm> // for max, min
|
#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
|
#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
@ -15,14 +16,15 @@ class Unselectable : public NodeDecorator {
|
|||||||
public:
|
public:
|
||||||
using NodeDecorator::NodeDecorator;
|
using NodeDecorator::NodeDecorator;
|
||||||
|
|
||||||
void Select(Selection&) override {
|
void Select(Selection& ignored) override {
|
||||||
|
std::ignore = ignored;
|
||||||
// Overwrite the select method to do nothing.
|
// Overwrite the select method to do nothing.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
/// @brief Create an empty selection.
|
/// @brief Create an empty selection.
|
||||||
Selection::Selection() : empty_(true) {}
|
Selection::Selection() = default;
|
||||||
|
|
||||||
/// @brief Create a selection.
|
/// @brief Create a selection.
|
||||||
/// @param start_x The x coordinate of the start of the 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;
|
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.
|
/// @brief Saturate the selection to be inside the box.
|
||||||
@ -136,12 +140,13 @@ Selection Selection::SaturateVertical(Box box) {
|
|||||||
end_y = box.y_min;
|
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) {
|
void Selection::AddPart(const std::string& part, int y, int left, int right) {
|
||||||
if (parent_ != this) {
|
if (parent_ != this) {
|
||||||
return parent_->AddPart(part, y, left, right);
|
parent_->AddPart(part, y, left, right);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
[&] {
|
[&] {
|
||||||
if (parts_.str().empty()) {
|
if (parts_.str().empty()) {
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
// Copyright 2024 Arthur Sonzogni. All rights reserved.
|
// Copyright 2024 Arthur Sonzogni. All rights reserved.
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include <memory> // for make_shared
|
#include <functional> // for function
|
||||||
#include <utility> // for move
|
#include <memory> // for make_shared
|
||||||
|
#include <utility> // for move
|
||||||
|
|
||||||
#include "ftxui/dom/elements.hpp" // for Element, Decorator, bgcolor, color
|
#include "ftxui/dom/elements.hpp" // for Element, Decorator, bgcolor, color
|
||||||
#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
|
#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/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 {
|
namespace ftxui {
|
||||||
|
|
||||||
@ -16,7 +17,8 @@ namespace {
|
|||||||
|
|
||||||
class SelectionStyleReset : public NodeDecorator {
|
class SelectionStyleReset : public NodeDecorator {
|
||||||
public:
|
public:
|
||||||
SelectionStyleReset(Element child) : NodeDecorator(std::move(child)) {}
|
explicit SelectionStyleReset(Element child)
|
||||||
|
: NodeDecorator(std::move(child)) {}
|
||||||
|
|
||||||
void Render(Screen& screen) final {
|
void Render(Screen& screen) final {
|
||||||
auto old_style = screen.GetSelectionStyle();
|
auto old_style = screen.GetSelectionStyle();
|
||||||
@ -28,7 +30,7 @@ class SelectionStyleReset : public NodeDecorator {
|
|||||||
|
|
||||||
class SelectionStyle : public NodeDecorator {
|
class SelectionStyle : public NodeDecorator {
|
||||||
public:
|
public:
|
||||||
SelectionStyle(Element child, std::function<void(Pixel&)> style)
|
SelectionStyle(Element child, const std::function<void(Pixel&)>& style)
|
||||||
: NodeDecorator(std::move(child)), style_(style) {}
|
: NodeDecorator(std::move(child)), style_(style) {}
|
||||||
|
|
||||||
void Render(Screen& screen) final {
|
void Render(Screen& screen) final {
|
||||||
@ -80,6 +82,7 @@ Decorator selectionColor(Color foreground) {
|
|||||||
/// @brief Set the style of an element when selected.
|
/// @brief Set the style of an element when selected.
|
||||||
/// @param style The style to be applied.
|
/// @param style The style to be applied.
|
||||||
/// Note that the style is applied on top of the existing style.
|
/// Note that the style is applied on top of the existing style.
|
||||||
|
// NOLINTNEXTLINE
|
||||||
Decorator selectionStyle(std::function<void(Pixel&)> style) {
|
Decorator selectionStyle(std::function<void(Pixel&)> style) {
|
||||||
return [style](Element child) -> Element {
|
return [style](Element child) -> Element {
|
||||||
return std::make_shared<SelectionStyle>(std::move(child), style);
|
return std::make_shared<SelectionStyle>(std::move(child), style);
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include "ftxui/dom/table.hpp"
|
#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 <memory> // for allocator, shared_ptr, allocator_traits<>::value_type
|
||||||
#include <utility> // for move, swap
|
#include <utility> // for move, swap
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "ftxui/dom/elements.hpp" // for Element, text, vtext
|
#include "ftxui/dom/elements.hpp" // for Element, text, vtext
|
||||||
#include "ftxui/dom/node.hpp" // for Node
|
#include "ftxui/dom/node.hpp" // for Node
|
||||||
#include "ftxui/dom/requirement.hpp" // for Requirement
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
||||||
|
#include "ftxui/dom/selection.hpp" // for Selection
|
||||||
#include "ftxui/screen/box.hpp" // for Box
|
#include "ftxui/screen/box.hpp" // for Box
|
||||||
#include "ftxui/screen/screen.hpp" // for Pixel, Screen
|
#include "ftxui/screen/screen.hpp" // for Pixel, Screen
|
||||||
#include "ftxui/screen/string.hpp" // for string_width, Utf8ToGlyphs, to_string
|
#include "ftxui/screen/string.hpp" // for string_width, Utf8ToGlyphs, to_string
|
||||||
@ -35,7 +36,7 @@ class Text : public Node {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection selection_saturated = selection.SaturateHorizontal(box_);
|
const Selection selection_saturated = selection.SaturateHorizontal(box_);
|
||||||
|
|
||||||
has_selection = true;
|
has_selection = true;
|
||||||
selection_start_ = selection_saturated.GetBox().x_min;
|
selection_start_ = selection_saturated.GetBox().x_min;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "ftxui/dom/elements.hpp" // for Element, Elements, vbox
|
#include "ftxui/dom/elements.hpp" // for Element, Elements, vbox
|
||||||
#include "ftxui/dom/node.hpp" // for Node, Elements
|
#include "ftxui/dom/node.hpp" // for Node, Elements
|
||||||
#include "ftxui/dom/requirement.hpp" // for Requirement
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
||||||
|
#include "ftxui/dom/selection.hpp" // for Selection
|
||||||
#include "ftxui/screen/box.hpp" // for Box
|
#include "ftxui/screen/box.hpp" // for Box
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
@ -553,7 +553,7 @@ const Screen::SelectionStyle& Screen::GetSelectionStyle() const {
|
|||||||
/// @brief Set the current selection style.
|
/// @brief Set the current selection style.
|
||||||
/// @see GetSelectionStyle
|
/// @see GetSelectionStyle
|
||||||
void Screen::SetSelectionStyle(SelectionStyle decorator) {
|
void Screen::SetSelectionStyle(SelectionStyle decorator) {
|
||||||
selection_style_ = decorator;
|
selection_style_ = std::move(decorator);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
Loading…
Reference in New Issue
Block a user