We can retrieve the content of the selection

This commit is contained in:
Clement Roblot
2024-12-02 16:47:13 +07:00
committed by ArthurSonzogni
parent dc70091203
commit 307d8b51bf
6 changed files with 83 additions and 9 deletions

View File

@@ -27,18 +27,16 @@ Element LoremIpsum() {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
int counter = 0;
screen.onSelectionModified([&]{
counter++;
});
int selectionChangeCounter = 0;
std::string selection = "";
auto quit = Button("Quit", screen.ExitLoopClosure());
// The components:
auto renderer = Renderer(quit, [&] {
return vbox({
text("Select: " + std::to_string(counter)),
text("Select changed: " + std::to_string(selectionChangeCounter) + " times"),
text("Currently selected: " + selection),
window(text("Horizontal split"), hbox({
LoremIpsum(),
separator(),
@@ -75,5 +73,10 @@ int main() {
});
});
screen.onSelectionModified([&] {
selectionChangeCounter++;
selection = screen.GetSelectedContent(renderer);
});
screen.Loop(renderer);
}