mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-16 08:04:21 +08:00
Start the tree-aware selection.
This commit is contained in:
@@ -68,7 +68,9 @@ class ScreenInteractive : public Screen {
|
||||
void ForceHandleCtrlC(bool force);
|
||||
void ForceHandleCtrlZ(bool force);
|
||||
|
||||
std::string GetSelection();
|
||||
// Selection API.
|
||||
//void OnSelectionChange(std::function<void(std::
|
||||
//void ClearSelection();
|
||||
|
||||
private:
|
||||
void ExitNow();
|
||||
@@ -133,6 +135,11 @@ class ScreenInteractive : public Screen {
|
||||
// The style of the cursor to restore on exit.
|
||||
int cursor_reset_shape_ = 1;
|
||||
|
||||
// Selection API:
|
||||
bool selection_enabled_ = false;
|
||||
CapturedMouse selection_pending_;
|
||||
Box selection_box_;
|
||||
|
||||
friend class Loop;
|
||||
|
||||
public:
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#ifndef FTXUI_DOM_NODE_HPP
|
||||
#define FTXUI_DOM_NODE_HPP
|
||||
|
||||
#include <list> // for list
|
||||
#include <memory> // for shared_ptr
|
||||
#include <vector> // for vector
|
||||
|
||||
@@ -40,7 +41,11 @@ class Node {
|
||||
// Propagated from Parents to Children.
|
||||
virtual void SetBox(Box box);
|
||||
|
||||
// Step 3: Draw this element.
|
||||
// Step 3: (optional) Selection
|
||||
// Propagated from Parents to Children.
|
||||
virtual void Selection(Box selection, std::vector<Box>* selected);
|
||||
|
||||
// Step 4: Draw this element.
|
||||
virtual void Render(Screen& screen);
|
||||
|
||||
// Layout may not resolve within a single iteration for some elements. This
|
||||
@@ -52,11 +57,6 @@ class Node {
|
||||
};
|
||||
virtual void Check(Status* status);
|
||||
|
||||
// Selection.
|
||||
// Propagated from Parents to Children.
|
||||
virtual void Select(Box selected_area) {
|
||||
// TODO: Implement this.
|
||||
}
|
||||
|
||||
protected:
|
||||
Elements children_;
|
||||
@@ -66,6 +66,7 @@ class Node {
|
||||
|
||||
void Render(Screen& screen, const Element& element);
|
||||
void Render(Screen& screen, Node* node);
|
||||
void Render(Screen& screen, Node* node, Box selection);
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
|
@@ -11,13 +11,10 @@ struct Box {
|
||||
int x_max = 0;
|
||||
int y_min = 0;
|
||||
int y_max = 0;
|
||||
bool isXInverted = false; // false means the box box from x_min to x_max (in the case of a selection for example)
|
||||
bool isYInverted = false; // false means the box box from y_min to y_max (in the case of a selection for example)
|
||||
|
||||
static auto Intersection(Box a, Box b) -> Box;
|
||||
static auto Union(Box a, Box b) -> Box;
|
||||
bool Contain(int x, int y) const;
|
||||
Box Clean() const;
|
||||
bool IsEmpty() const;
|
||||
bool operator==(const Box& other) const;
|
||||
bool operator!=(const Box& other) const;
|
||||
|
@@ -63,12 +63,6 @@ class Screen : public Image {
|
||||
Cursor cursor() const { return cursor_; }
|
||||
void SetCursor(Cursor cursor) { cursor_ = cursor; }
|
||||
|
||||
bool selection_enabled = false;
|
||||
CapturedMouse selection_pending;
|
||||
Box mouse_selection_region;
|
||||
Box selection_region;
|
||||
std::string selection_text;
|
||||
|
||||
// Store an hyperlink in the screen. Return the id of the hyperlink. The id is
|
||||
// used to identify the hyperlink when the user click on it.
|
||||
uint8_t RegisterHyperlink(const std::string& link);
|
||||
|
Reference in New Issue
Block a user