From 156a30ba8d2e4fcbc86bc8da186f5c59cbbc174e Mon Sep 17 00:00:00 2001 From: Douglas Smith Date: Mon, 18 Dec 2023 13:00:44 -0600 Subject: [PATCH 1/3] Call get_text_range in Save Content Works with vte=0.68.0 See #1958 --- guake/dialogs.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/guake/dialogs.py b/guake/dialogs.py index 5f4a30941..ae84a2601 100644 --- a/guake/dialogs.py +++ b/guake/dialogs.py @@ -143,14 +143,24 @@ def __init__(self, terminal, window): self.parent_window = window def run(self): - self.terminal.select_all() - self.terminal.copy_clipboard() - self.terminal.unselect_all() - clipboard = Gtk.Clipboard.get_default(self.parent_window.get_display()) - selection = clipboard.wait_for_text() - if not selection: - return - selection = selection.rstrip() + # row from get_cursor_position takes the scrollback rows into account automatically + row = self.terminal.get_cursor_position()[1] + # Get the max col, not where the cursor is, to avoid losing text at the end + col = self.terminal.get_column_count() + content = self.terminal.get_text_range(0, 0, row, col) + + if content: + selection = content[0].rstrip().lstrip() + else: # Call the original method if get_text_range fails for some reason. (Can it fail?) + self.terminal.select_all() + self.terminal.copy_clipboard() + self.terminal.unselect_all() + clipboard = Gtk.Clipboard.get_default(self.parent_window.get_display()) + selection = clipboard.wait_for_text() + if not selection: + return + selection = selection.rstrip() + filter = Gtk.FileFilter() filter.set_name(_("All files")) filter.add_pattern("*") From dd57c135181bde818d2b74f9f2973c7de1216e02 Mon Sep 17 00:00:00 2001 From: Douglas Smith Date: Mon, 18 Dec 2023 13:24:37 -0600 Subject: [PATCH 2/3] Add releasenotes file --- releasenotes/notes/bugfix-503a9fee8f80e714.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 releasenotes/notes/bugfix-503a9fee8f80e714.yaml diff --git a/releasenotes/notes/bugfix-503a9fee8f80e714.yaml b/releasenotes/notes/bugfix-503a9fee8f80e714.yaml new file mode 100644 index 000000000..af50e8be7 --- /dev/null +++ b/releasenotes/notes/bugfix-503a9fee8f80e714.yaml @@ -0,0 +1,6 @@ +release_summary: > + Fixes Save Content feature for newer versions of Vte + +fixes: + - Save Content works for newer versions of Vte, fixes #1958 + From 290be4210d81b348dd0d3efe4fafd5020ee79c8a Mon Sep 17 00:00:00 2001 From: David Yang Date: Wed, 18 Dec 2024 11:33:59 +0800 Subject: [PATCH 3/3] Ensure content is not None before using it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Phùng Xuân Anh --- guake/dialogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guake/dialogs.py b/guake/dialogs.py index ae84a2601..9605d9bc1 100644 --- a/guake/dialogs.py +++ b/guake/dialogs.py @@ -149,7 +149,7 @@ def run(self): col = self.terminal.get_column_count() content = self.terminal.get_text_range(0, 0, row, col) - if content: + if content and content[0]: selection = content[0].rstrip().lstrip() else: # Call the original method if get_text_range fails for some reason. (Can it fail?) self.terminal.select_all()