mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Add recursive selection style.
This commit is contained in:
@@ -113,7 +113,11 @@ Decorator focusPositionRelative(float x, float y);
|
||||
Element automerge(Element child);
|
||||
Decorator hyperlink(std::string link);
|
||||
Element hyperlink(std::string link, Element child);
|
||||
Element unselectable(Element child);
|
||||
Element selectionStyleReset(Element);
|
||||
Decorator selectionColor(Color foreground);
|
||||
Decorator selectionBackgroundColor(Color foreground);
|
||||
Decorator selectionForegroundColor(Color foreground);
|
||||
Decorator selectionStyle(std::function<void(Pixel&)> style);
|
||||
|
||||
// --- Layout is
|
||||
// Horizontal, Vertical or stacked set of elements.
|
||||
|
||||
@@ -7,34 +7,16 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "ftxui/screen/box.hpp" // for Box
|
||||
#include "ftxui/screen/box.hpp" // for Box
|
||||
#include "ftxui/screen/pixel.hpp" // for Pixel
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
/// @brief Option for the selection of content.
|
||||
/// @ingroup component
|
||||
struct SelectionOption {
|
||||
/// @brief Selection is simply inverted:
|
||||
static SelectionOption Simple();
|
||||
|
||||
// Style:
|
||||
std::function<void(Pixel& pixel)> transform = [](Pixel& pixel) {
|
||||
|
||||
pixel.inverted = true;
|
||||
};
|
||||
|
||||
// Observers:
|
||||
/// Called when the selection changed.
|
||||
std::function<void()> on_change = [] {};
|
||||
};
|
||||
|
||||
/// @brief Represent a selection in the terminal.
|
||||
class Selection {
|
||||
public:
|
||||
Selection(int start_x, int start_y, int end_x, int end_y, SelectionOption option = SelectionOption::Simple());
|
||||
Selection(int start_x, int start_y, int end_x, int end_y);
|
||||
const Box& GetBox() const;
|
||||
const SelectionOption& GetOption() const;
|
||||
|
||||
Selection SaturateHorizontal(Box box);
|
||||
Selection SaturateVertical(Box box);
|
||||
@@ -46,7 +28,6 @@ class Selection {
|
||||
const int end_x_;
|
||||
const int end_y_;
|
||||
const Box box_;
|
||||
const SelectionOption option;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
Reference in New Issue
Block a user