mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-26 20:47:05 +08:00
We can act on the screen
This commit is contained in:
parent
dea2d6408b
commit
e4a63318ad
@ -55,6 +55,9 @@ int main() {
|
||||
|
||||
// Tweak how the component tree is rendered:
|
||||
auto renderer = Renderer(component, [&] {
|
||||
|
||||
textToCopy = screen.getSelection();
|
||||
|
||||
return vbox({
|
||||
hbox(text(" First name : "), input_first_name->Render()),
|
||||
hbox(text(" Last name : ") | selectable(), input_last_name->Render()),
|
||||
|
@ -32,7 +32,6 @@ typedef struct {
|
||||
uint16_t endx = 0;
|
||||
uint16_t starty = 0;
|
||||
uint16_t endy = 0;
|
||||
bool changed = false;
|
||||
} Region;
|
||||
|
||||
class ScreenInteractive : public Screen {
|
||||
@ -77,6 +76,8 @@ class ScreenInteractive : public Screen {
|
||||
void ForceHandleCtrlC(bool force);
|
||||
void ForceHandleCtrlZ(bool force);
|
||||
|
||||
std::string getSelection(void);
|
||||
|
||||
private:
|
||||
void ExitNow();
|
||||
|
||||
@ -92,7 +93,7 @@ class ScreenInteractive : public Screen {
|
||||
|
||||
void HandleTask(Component component, Task& task);
|
||||
bool selectableCatchEvent(Event event);
|
||||
std::string getSelection(void);
|
||||
void refreshSelection(void);
|
||||
void Draw(Component component);
|
||||
void ResetCursorPosition();
|
||||
|
||||
|
@ -116,9 +116,6 @@ Element hyperlink(std::string link, Element child);
|
||||
Element selectable(Element child);
|
||||
Decorator selectable(void);
|
||||
|
||||
// -- Selection --
|
||||
std::string getSelection(void);
|
||||
|
||||
// --- Layout is
|
||||
// Horizontal, Vertical or stacked set of elements.
|
||||
Element hbox(Elements);
|
||||
|
@ -853,15 +853,15 @@ bool ScreenInteractive::selectableCatchEvent(Event event) {
|
||||
selectedRegion.starty = mouse.y;
|
||||
selectedRegion.endx = mouse.x;
|
||||
selectedRegion.endy = mouse.y;
|
||||
selectedRegion.changed = true;
|
||||
refreshSelection();
|
||||
} else if (mouse.motion == Mouse::Released) {
|
||||
selectedRegion.endx = mouse.x;
|
||||
selectedRegion.endy = mouse.y;
|
||||
selectedRegion.changed = true;
|
||||
refreshSelection();
|
||||
} else if (mouse.motion == Mouse::Moved) {
|
||||
selectedRegion.endx = mouse.x;
|
||||
selectedRegion.endy = mouse.y;
|
||||
selectedRegion.changed = true;
|
||||
refreshSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -869,8 +869,18 @@ bool ScreenInteractive::selectableCatchEvent(Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScreenInteractive::refreshSelection(void) {
|
||||
|
||||
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) {
|
||||
PixelAt(x, y).inverted ^= true;
|
||||
//selectedText += PixelAt(x, y).character;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string ScreenInteractive::getSelection(void) {
|
||||
return "Selection";
|
||||
return "Kikoo";
|
||||
}
|
||||
|
||||
// private
|
||||
|
Loading…
Reference in New Issue
Block a user