More key refactoring
This commit is contained in:
parent
a6aa95cba8
commit
bf99519046
@ -8,7 +8,7 @@ class Open(Command):
|
|||||||
|
|
||||||
class TabOpen(Command):
|
class TabOpen(Command):
|
||||||
nargs = 1
|
nargs = 1
|
||||||
key = 'Shift+o'
|
key = 'O'
|
||||||
signal = pyqtSignal(str)
|
signal = pyqtSignal(str)
|
||||||
|
|
||||||
class TabClose(Command):
|
class TabClose(Command):
|
||||||
@ -18,12 +18,12 @@ class TabClose(Command):
|
|||||||
|
|
||||||
class TabNext(Command):
|
class TabNext(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'Shift+j'
|
key = 'J'
|
||||||
signal = pyqtSignal()
|
signal = pyqtSignal()
|
||||||
|
|
||||||
class TabPrev(Command):
|
class TabPrev(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'Shift+k'
|
key = 'K'
|
||||||
signal = pyqtSignal()
|
signal = pyqtSignal()
|
||||||
|
|
||||||
class Quit(Command):
|
class Quit(Command):
|
||||||
@ -41,12 +41,12 @@ class Stop(Command):
|
|||||||
|
|
||||||
class Back(Command):
|
class Back(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'Shift+H'
|
key = 'H'
|
||||||
signal = pyqtSignal()
|
signal = pyqtSignal()
|
||||||
|
|
||||||
class Forward(Command):
|
class Forward(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'Shift+L'
|
key = 'L'
|
||||||
signal = pyqtSignal()
|
signal = pyqtSignal()
|
||||||
|
|
||||||
class Print(Command):
|
class Print(Command):
|
||||||
@ -84,10 +84,10 @@ class Undo(Command):
|
|||||||
|
|
||||||
class ScrollStart(Command):
|
class ScrollStart(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'g, g'
|
key = 'gg'
|
||||||
signal = pyqtSignal()
|
signal = pyqtSignal()
|
||||||
|
|
||||||
class ScrollEnd(Command):
|
class ScrollEnd(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'Shift+g'
|
key = 'G'
|
||||||
signal = pyqtSignal()
|
signal = pyqtSignal()
|
||||||
|
@ -15,7 +15,10 @@ class KeyParser(QObject):
|
|||||||
self.key_to_cmd[cmd.key] = cmd
|
self.key_to_cmd[cmd.key] = cmd
|
||||||
|
|
||||||
def handle(self, e):
|
def handle(self, e):
|
||||||
logging.debug('Got key: {} / text: {}'.format(e.key(), e.text()))
|
logging.debug('Got key: {} / text: "{}"'.format(e.key(), e.text()))
|
||||||
|
if not e.text().strip():
|
||||||
|
logging.debug('Ignoring, no text')
|
||||||
|
return
|
||||||
self.keystring += e.text()
|
self.keystring += e.text()
|
||||||
if self.keystring == ':':
|
if self.keystring == ':':
|
||||||
self.set_cmd_text.emit(':')
|
self.set_cmd_text.emit(':')
|
||||||
@ -24,11 +27,17 @@ class KeyParser(QObject):
|
|||||||
try:
|
try:
|
||||||
cmd = self.key_to_cmd[self.keystring]
|
cmd = self.key_to_cmd[self.keystring]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
pos = len(self.keystring)
|
||||||
|
if any([self.keystring[-1] == needle[pos-1]
|
||||||
|
for needle in self.key_to_cmd]):
|
||||||
logging.debug('No match for "{}" (added {})'.format(self.keystring, e.text()))
|
logging.debug('No match for "{}" (added {})'.format(self.keystring, e.text()))
|
||||||
pass
|
else:
|
||||||
|
logging.debug('Giving up with "{}", no matches'.format(self.keystring))
|
||||||
|
self.keystring = ''
|
||||||
else:
|
else:
|
||||||
self.keystring = ''
|
self.keystring = ''
|
||||||
if cmd.nargs and cmd.nargs != 0:
|
if cmd.nargs and cmd.nargs != 0:
|
||||||
|
logging.debug('Filling statusbar with partial command {}'.format(cmd.name))
|
||||||
self.set_cmd_text.emit(':{} '.format(cmd.name))
|
self.set_cmd_text.emit(':{} '.format(cmd.name))
|
||||||
else:
|
else:
|
||||||
cmd.run()
|
cmd.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user