Fix backspace/delete bindings to actually do what they say they should, per GNOME Terminal behaviour. Closes LP #511875

This commit is contained in:
Chris Jones 2010-01-24 15:45:47 +00:00
parent 05a61f802d
commit 9f348c349a
3 changed files with 46 additions and 16 deletions

View File

@ -151,6 +151,9 @@
<column type="gchararray"/> <column type="gchararray"/>
</columns> </columns>
<data> <data>
<row>
<col id="0" translatable="yes">Automatic</col>
</row>
<row> <row>
<col id="0" translatable="yes">Control-H</col> <col id="0" translatable="yes">Control-H</col>
</row> </row>
@ -168,6 +171,9 @@
<column type="gchararray"/> <column type="gchararray"/>
</columns> </columns>
<data> <data>
<row>
<col id="0" translatable="yes">Automatic</col>
</row>
<row> <row>
<col id="0" translatable="yes">Control-H</col> <col id="0" translatable="yes">Control-H</col>
</row> </row>

View File

@ -414,20 +414,24 @@ class PrefsEditor:
widget = guiget('backspace-binding-combobox') widget = guiget('backspace-binding-combobox')
value = self.config['backspace_binding'] value = self.config['backspace_binding']
if value == 'control-h': if value == 'control-h':
widget.set_active(0)
elif value == 'escape-sequence':
widget.set_active(2)
else:
widget.set_active(1) 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 # Delete key
widget = guiget('delete-binding-combobox') widget = guiget('delete-binding-combobox')
value = self.config['delete_binding'] value = self.config['delete_binding']
if value == 'control-h': if value == 'control-h':
widget.set_active(0)
elif value == 'ascii-del':
widget.set_active(1) widget.set_active(1)
else: elif value == 'ascii-del':
widget.set_active(2) 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? # FIXME: Why do we have a profile argument that we don't use?
def store_profile_values(self, profile): def store_profile_values(self, profile):
@ -574,20 +578,24 @@ class PrefsEditor:
widget = guiget('backspace-binding-combobox') widget = guiget('backspace-binding-combobox')
selected = widget.get_active() selected = widget.get_active()
if selected == 0: if selected == 0:
value = 'control-h' value = 'automatic'
elif selected == 1: elif selected == 1:
value = 'ascii-del' value = 'control-h'
elif selected == 2: elif selected == 2:
value = 'ascii-del'
elif selected == 3:
value == 'escape-sequence' value == 'escape-sequence'
self.config['backspace_binding'] = value self.config['backspace_binding'] = value
# Delete key # Delete key
widget = guiget('delete-binding-combobox') widget = guiget('delete-binding-combobox')
selected = widget.get_active() selected = widget.get_active()
if selected == 0: if selected == 0:
value = 'control-h' valud = 'automatic'
elif selected == 1: elif selected == 1:
value = 'ascii-del' value = 'control-h'
elif selected == 2: elif selected == 2:
value = 'ascii-del'
elif selected == 3:
value = 'escape-sequence' value = 'escape-sequence'
self.config['delete_binding'] = value self.config['delete_binding'] = value
@ -655,9 +663,9 @@ class PrefsEditor:
guiget = self.builder.get_object guiget = self.builder.get_object
widget = guiget('backspace-binding-combobox') widget = guiget('backspace-binding-combobox')
widget.set_active(1)
widget = guiget('delete-binding-combobox')
widget.set_active(2) widget.set_active(2)
widget = guiget('delete-binding-combobox')
widget.set_active(3)
def on_background_type_toggled(self, _widget): def on_background_type_toggled(self, _widget):
"""The background type was toggled""" """The background type was toggled"""

View File

@ -496,22 +496,38 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
# escape-sequence # escape-sequence
try: try:
if backspace == 'ascii-del': if backspace == 'ascii-del':
backbind = vte.ERASE_ASCII_DELETE
elif backspace == 'control-h':
backbind = vte.ERASE_ASCII_BACKSPACE backbind = vte.ERASE_ASCII_BACKSPACE
elif backspace == 'escape-sequence':
backbind = vte.ERASE_DELETE_SEQUENCE
else: else:
backbind = vte.ERASE_AUTO backbind = vte.ERASE_AUTO
except AttributeError: except AttributeError:
if backspace == 'ascii-del': if backspace == 'ascii-del':
backbind = 2 backbind = 2
else: elif backspace == 'control-h':
backbind = 1 backbind = 1
elif backspace == 'escape-sequence':
backbind = 3
else:
backbind = 0
try: 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 delbind = vte.ERASE_DELETE_SEQUENCE
else: else:
delbind = vte.ERASE_AUTO delbind = vte.ERASE_AUTO
except AttributeError: except AttributeError:
if delete == 'escape-sequence': if delete == 'ascii-del':
delbind = 2
elif delete == 'control-h':
delbind = 1
elif delete == 'escape-sequence':
delbind = 3 delbind = 3
else: else:
delbind = 0 delbind = 0