mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-06-25 00:52:09 +08:00
Implementation of the selection in the text node
This commit is contained in:
parent
011b9a1426
commit
23a8c94bef
@ -877,25 +877,6 @@ bool ScreenInteractive::HandleSelection(Event event) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenInteractive::RefreshSelection() {
|
|
||||||
if (!selection_enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selection_text = "";
|
|
||||||
|
|
||||||
for (int y = std::min(selection_region.y_min, selection_region.y_max);
|
|
||||||
y <= std::max(selection_region.y_min, selection_region.y_max); ++y) {
|
|
||||||
for (int x = std::min(selection_region.x_min, selection_region.x_max);
|
|
||||||
x <= std::max(selection_region.x_min, selection_region.x_max) - 1;
|
|
||||||
++x) {
|
|
||||||
if (PixelAt(x, y).selectable == true) {
|
|
||||||
PixelAt(x, y).inverted ^= true;
|
|
||||||
selection_text += PixelAt(x, y).character;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ScreenInteractive::GetSelection() {
|
std::string ScreenInteractive::GetSelection() {
|
||||||
return selection_text;
|
return selection_text;
|
||||||
}
|
}
|
||||||
@ -975,9 +956,10 @@ void ScreenInteractive::Draw(Component component) {
|
|||||||
#endif
|
#endif
|
||||||
previous_frame_resized_ = resized;
|
previous_frame_resized_ = resized;
|
||||||
|
|
||||||
Render(*this, document);
|
// Clear selection text.
|
||||||
|
selection_text = "";
|
||||||
|
|
||||||
RefreshSelection();
|
Render(*this, document);
|
||||||
|
|
||||||
// Set cursor position for user using tools to insert CJK characters.
|
// Set cursor position for user using tools to insert CJK characters.
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,15 @@ class Text : public Node {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
screen.PixelAt(x, y).character = cell;
|
screen.PixelAt(x, y).character = cell;
|
||||||
|
|
||||||
|
if(screen.PixelAt(x, y).selectable == true)
|
||||||
|
{
|
||||||
|
if(screen.selection_region.Contain(x, y)) {
|
||||||
|
screen.PixelAt(x, y).inverted ^= true;
|
||||||
|
screen.selection_text += screen.PixelAt(x, y).character;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user