From 892ed45159f7c282bb970675335ff8a63b3f4ebd Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Sun, 5 May 2024 17:02:18 +1200 Subject: [PATCH] fix(term): select() fixes - Ensure selection is drawn. - Allow deselection by mouse click. - Respect copy_on_selection attribute. --- addons/godot_xterm/native/src/terminal.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/godot_xterm/native/src/terminal.cpp b/addons/godot_xterm/native/src/terminal.cpp index 91a28e1..3796240 100644 --- a/addons/godot_xterm/native/src/terminal.cpp +++ b/addons/godot_xterm/native/src/terminal.cpp @@ -739,6 +739,18 @@ void Terminal::select(const int p_from_line, const int p_from_column, const int tsm_screen_selection_reset(screen); tsm_screen_selection_start(screen, from_column, from_line); tsm_screen_selection_target(screen, to_column, to_line); + + String selection = copy_selection(); + + #if defined(__linux__) + if (copy_on_selection) + DisplayServer::get_singleton()->clipboard_set_primary(selection); + #endif + + if (selection.length() > 0) { + selecting = true; + queue_redraw(); + } } String Terminal::copy_all() {