Switch keyboard modes when opening new files

This commit is contained in:
Kovid Goyal 2013-11-03 10:50:46 +05:30
parent be20dde56e
commit 6a14af6f99
2 changed files with 11 additions and 5 deletions

View File

@ -221,6 +221,7 @@ class Boss(QObject):
c = current_container()
editor.load_text(c.decode(c.open(name).read()))
self.gui.central.show_editor(editor)
self.gui.keyboard.set_mode(syntax)
def edit_file_requested(self, name, syntax, mime):
if name in self.editors:

View File

@ -31,7 +31,12 @@ class KeyboardManager(object):
km.finalize()
def set_mode(self, name):
try:
km = self.modes[name]
except KeyError:
name = 'other'
km = self.modes[name]
if name != self.current_mode:
for un, action in self.actions.iteritems():
keys = km.keys_map[un]
action.setShortcuts(list(keys))