From 9f348c349a94b1efe97ecfa38dd8fe76256781ac Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 24 Jan 2010 15:45:47 +0000 Subject: [PATCH] Fix backspace/delete bindings to actually do what they say they should, per GNOME Terminal behaviour. Closes LP #511875 --- terminatorlib/preferences.glade | 6 ++++++ terminatorlib/prefseditor.py | 34 ++++++++++++++++++++------------- terminatorlib/terminal.py | 22 ++++++++++++++++++--- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 0f0bbb40..e18592ef 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -151,6 +151,9 @@ + + Automatic + Control-H @@ -168,6 +171,9 @@ + + Automatic + Control-H diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index ef7e495c..bdb156c2 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -414,20 +414,24 @@ class PrefsEditor: widget = guiget('backspace-binding-combobox') value = self.config['backspace_binding'] if value == 'control-h': - widget.set_active(0) - elif value == 'escape-sequence': - widget.set_active(2) - else: widget.set_active(1) + elif value == 'ascii-del': + widget.set_active(2) + elif value == 'escape-sequence': + widget.set_active(3) + else: + widget.set_active(0) # Delete key widget = guiget('delete-binding-combobox') value = self.config['delete_binding'] if value == 'control-h': - widget.set_active(0) - elif value == 'ascii-del': widget.set_active(1) - else: + elif value == 'ascii-del': widget.set_active(2) + elif value == 'escape-sequence': + widget.set_active(3) + else: + widget.set_active(0) # FIXME: Why do we have a profile argument that we don't use? def store_profile_values(self, profile): @@ -574,20 +578,24 @@ class PrefsEditor: widget = guiget('backspace-binding-combobox') selected = widget.get_active() if selected == 0: - value = 'control-h' + value = 'automatic' elif selected == 1: - value = 'ascii-del' + value = 'control-h' elif selected == 2: + value = 'ascii-del' + elif selected == 3: value == 'escape-sequence' self.config['backspace_binding'] = value # Delete key widget = guiget('delete-binding-combobox') selected = widget.get_active() if selected == 0: - value = 'control-h' + valud = 'automatic' elif selected == 1: - value = 'ascii-del' + value = 'control-h' elif selected == 2: + value = 'ascii-del' + elif selected == 3: value = 'escape-sequence' self.config['delete_binding'] = value @@ -655,9 +663,9 @@ class PrefsEditor: guiget = self.builder.get_object widget = guiget('backspace-binding-combobox') - widget.set_active(1) - widget = guiget('delete-binding-combobox') widget.set_active(2) + widget = guiget('delete-binding-combobox') + widget.set_active(3) def on_background_type_toggled(self, _widget): """The background type was toggled""" diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 2c6951ce..a0a442fb 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -496,22 +496,38 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) # escape-sequence try: if backspace == 'ascii-del': + backbind = vte.ERASE_ASCII_DELETE + elif backspace == 'control-h': backbind = vte.ERASE_ASCII_BACKSPACE + elif backspace == 'escape-sequence': + backbind = vte.ERASE_DELETE_SEQUENCE else: backbind = vte.ERASE_AUTO except AttributeError: if backspace == 'ascii-del': backbind = 2 - else: + elif backspace == 'control-h': backbind = 1 + elif backspace == 'escape-sequence': + backbind = 3 + else: + backbind = 0 try: - if delete == 'escape-sequence': + if delete == 'ascii-del': + delbind = vte.ERASE_ASCII_DELETE + elif delete == 'control-h': + delbind = vte.ERASE_ASCII_BACKSPACE + elif delete == 'escape-sequence': delbind = vte.ERASE_DELETE_SEQUENCE else: delbind = vte.ERASE_AUTO except AttributeError: - if delete == 'escape-sequence': + if delete == 'ascii-del': + delbind = 2 + elif delete == 'control-h': + delbind = 1 + elif delete == 'escape-sequence': delbind = 3 else: delbind = 0