Merge pull request #777 from mattrose/776-fix-logger

Alter get_text_range call based on VTE version
This commit is contained in:
Matt Rose 2023-06-20 19:57:16 -04:00 committed by GitHub
commit b7e91b1ede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,7 @@ terminals """
import os import os
import sys import sys
from gi.repository import Gtk from gi.repository import Gtk,Vte
import terminatorlib.plugin as plugin import terminatorlib.plugin as plugin
from terminatorlib.translation import _ from terminatorlib.translation import _
@ -19,6 +19,7 @@ class Logger(plugin.MenuItem):
dialog_action = Gtk.FileChooserAction.SAVE dialog_action = Gtk.FileChooserAction.SAVE
dialog_buttons = (_("_Cancel"), Gtk.ResponseType.CANCEL, dialog_buttons = (_("_Cancel"), Gtk.ResponseType.CANCEL,
_("_Save"), Gtk.ResponseType.OK) _("_Save"), Gtk.ResponseType.OK)
vte_version = Vte.get_minor_version()
def __init__(self): def __init__(self):
plugin.MenuItem.__init__(self) plugin.MenuItem.__init__(self)
@ -40,8 +41,11 @@ class Logger(plugin.MenuItem):
def write_content(self, terminal, row_start, col_start, row_end, col_end): def write_content(self, terminal, row_start, col_start, row_end, col_end):
""" Final function to write a file """ """ Final function to write a file """
content = terminal.get_text_range(row_start, col_start, row_end, col_end, if self.vte_version < 72:
content = terminal.get_text_range(row_start, col_start, row_end, col_end,
lambda *a: True) lambda *a: True)
else:
content = terminal.get_text_range_format(Vte.Format.TEXT,row_start, col_start, row_end, col_end)
content = content[0] content = content[0]
fd = self.loggers[terminal]["fd"] fd = self.loggers[terminal]["fd"]
# Don't write the last char which is always '\n' # Don't write the last char which is always '\n'