mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-07-25 22:01:14 +08:00
It somewhat works
This commit is contained in:
parent
cb2436f13f
commit
2339ead35c
@ -69,7 +69,7 @@ int main() {
|
|||||||
text("Your phone number is " + phoneNumber),
|
text("Your phone number is " + phoneNumber),
|
||||||
// text("select_start " + std::to_string(selection.startx) + ";" + std::to_string(selection.starty)),
|
// text("select_start " + std::to_string(selection.startx) + ";" + std::to_string(selection.starty)),
|
||||||
// text("select_end " + std::to_string(selection.endx) + ";" + std::to_string(selection.endy)),
|
// text("select_end " + std::to_string(selection.endx) + ";" + std::to_string(selection.endy)),
|
||||||
text("textToCopy " + textToCopy)
|
text("textToCopy is " + textToCopy)
|
||||||
}) |
|
}) |
|
||||||
border; // | selectable([&textToCopy](std::string txtSelected){textToCopy = txtSelected;})
|
border; // | selectable([&textToCopy](std::string txtSelected){textToCopy = txtSelected;})
|
||||||
});
|
});
|
||||||
|
@ -139,6 +139,7 @@ class ScreenInteractive : public Screen {
|
|||||||
bool force_handle_ctrl_z_ = true;
|
bool force_handle_ctrl_z_ = true;
|
||||||
|
|
||||||
Region selectedRegion;
|
Region selectedRegion;
|
||||||
|
std::string selectedText;
|
||||||
|
|
||||||
// The style of the cursor to restore on exit.
|
// The style of the cursor to restore on exit.
|
||||||
int cursor_reset_shape_ = 1;
|
int cursor_reset_shape_ = 1;
|
||||||
|
@ -357,7 +357,8 @@ ScreenInteractive::ScreenInteractive(int dimx,
|
|||||||
bool use_alternative_screen)
|
bool use_alternative_screen)
|
||||||
: Screen(dimx, dimy),
|
: Screen(dimx, dimy),
|
||||||
dimension_(dimension),
|
dimension_(dimension),
|
||||||
use_alternative_screen_(use_alternative_screen) {
|
use_alternative_screen_(use_alternative_screen),
|
||||||
|
selectedText("") {
|
||||||
task_receiver_ = MakeReceiver<Task>();
|
task_receiver_ = MakeReceiver<Task>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,15 +854,15 @@ bool ScreenInteractive::selectableCatchEvent(Event event) {
|
|||||||
selectedRegion.starty = mouse.y;
|
selectedRegion.starty = mouse.y;
|
||||||
selectedRegion.endx = mouse.x;
|
selectedRegion.endx = mouse.x;
|
||||||
selectedRegion.endy = mouse.y;
|
selectedRegion.endy = mouse.y;
|
||||||
refreshSelection();
|
// refreshSelection();
|
||||||
} else if (mouse.motion == Mouse::Released) {
|
} else if (mouse.motion == Mouse::Released) {
|
||||||
selectedRegion.endx = mouse.x;
|
selectedRegion.endx = mouse.x;
|
||||||
selectedRegion.endy = mouse.y;
|
selectedRegion.endy = mouse.y;
|
||||||
refreshSelection();
|
// refreshSelection();
|
||||||
} else if (mouse.motion == Mouse::Moved) {
|
} else if (mouse.motion == Mouse::Moved) {
|
||||||
selectedRegion.endx = mouse.x;
|
selectedRegion.endx = mouse.x;
|
||||||
selectedRegion.endy = mouse.y;
|
selectedRegion.endy = mouse.y;
|
||||||
refreshSelection();
|
// refreshSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -871,16 +872,26 @@ bool ScreenInteractive::selectableCatchEvent(Event event) {
|
|||||||
|
|
||||||
void ScreenInteractive::refreshSelection(void) {
|
void ScreenInteractive::refreshSelection(void) {
|
||||||
|
|
||||||
|
selectedText = "";
|
||||||
|
|
||||||
for (int y = std::min(selectedRegion.starty, selectedRegion.endy); y <= std::max(selectedRegion.starty, selectedRegion.endy); ++y) {
|
for (int y = std::min(selectedRegion.starty, selectedRegion.endy); y <= std::max(selectedRegion.starty, selectedRegion.endy); ++y) {
|
||||||
for (int x = std::min(selectedRegion.startx, selectedRegion.endx); x <= std::max(selectedRegion.startx, selectedRegion.endx)-1; ++x) {
|
for (int x = std::min(selectedRegion.startx, selectedRegion.endx); x <= std::max(selectedRegion.startx, selectedRegion.endx)-1; ++x) {
|
||||||
PixelAt(x, y).inverted ^= true;
|
if(PixelAt(x, y).selectable == true)
|
||||||
//selectedText += PixelAt(x, y).character;
|
{
|
||||||
|
PixelAt(x, y).inverted ^= true;
|
||||||
|
selectedText += PixelAt(x, y).character;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ScreenInteractive::getSelection(void) {
|
std::string ScreenInteractive::getSelection(void) {
|
||||||
return "Kikoo";
|
|
||||||
|
// std::ofstream MyFile("debug.log", std::ios_base::app);
|
||||||
|
// MyFile << "Top dog!" << std::endl;
|
||||||
|
// MyFile.close();
|
||||||
|
|
||||||
|
return selectedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private
|
// private
|
||||||
@ -960,6 +971,8 @@ void ScreenInteractive::Draw(Component component) {
|
|||||||
|
|
||||||
Render(*this, document);
|
Render(*this, document);
|
||||||
|
|
||||||
|
refreshSelection();
|
||||||
|
|
||||||
// Set cursor position for user using tools to insert CJK characters.
|
// Set cursor position for user using tools to insert CJK characters.
|
||||||
{
|
{
|
||||||
const int dx = dimx_ - 1 - cursor_.x + int(dimx_ != terminal.dimx);
|
const int dx = dimx_ - 1 - cursor_.x + int(dimx_ != terminal.dimx);
|
||||||
|
Loading…
Reference in New Issue
Block a user