Also handle Return via config
This commit is contained in:
parent
74374df5fd
commit
aeb4980f7e
@ -464,6 +464,7 @@ DATA = OrderedDict([
|
|||||||
('<Down>', 'command_history_next'),
|
('<Down>', 'command_history_next'),
|
||||||
('<Shift-Tab>', 'command_item_prev'),
|
('<Shift-Tab>', 'command_item_prev'),
|
||||||
('<Tab>', 'command_item_next'),
|
('<Tab>', 'command_item_next'),
|
||||||
|
('<Return>', 'command_accept'),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
('aliases', sect.ValueList(
|
('aliases', sect.ValueList(
|
||||||
|
@ -256,30 +256,9 @@ class _Command(QLineEdit):
|
|||||||
self.history = History()
|
self.history = History()
|
||||||
self._validator = _CommandValidator(self)
|
self._validator = _CommandValidator(self)
|
||||||
self.setValidator(self._validator)
|
self.setValidator(self._validator)
|
||||||
self.returnPressed.connect(self._on_return_pressed)
|
|
||||||
self.textEdited.connect(self.history.stop)
|
self.textEdited.connect(self.history.stop)
|
||||||
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
|
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
|
||||||
|
|
||||||
@pyqtSlot()
|
|
||||||
def _on_return_pressed(self):
|
|
||||||
"""Handle the command in the status bar.
|
|
||||||
|
|
||||||
Emit:
|
|
||||||
got_cmd: If a new cmd was entered.
|
|
||||||
got_search: If a new search was entered.
|
|
||||||
got_search_rev: If a new reverse search was entered.
|
|
||||||
"""
|
|
||||||
signals = {
|
|
||||||
':': self.got_cmd,
|
|
||||||
'/': self.got_search,
|
|
||||||
'?': self.got_search_rev,
|
|
||||||
}
|
|
||||||
text = self.text()
|
|
||||||
self.history.append(text)
|
|
||||||
modes.leave("command")
|
|
||||||
if text[0] in signals:
|
|
||||||
signals[text[0]].emit(text.lstrip(text[0]))
|
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def set_cmd_text(self, text):
|
def set_cmd_text(self, text):
|
||||||
"""Preset the statusbar to some text.
|
"""Preset the statusbar to some text.
|
||||||
@ -336,6 +315,26 @@ class _Command(QLineEdit):
|
|||||||
if item:
|
if item:
|
||||||
self.set_cmd_text(item)
|
self.set_cmd_text(item)
|
||||||
|
|
||||||
|
@cmdutils.register(instance='mainwindow.status.cmd', hide=True)
|
||||||
|
def command_accept(self):
|
||||||
|
"""Handle the command in the status bar.
|
||||||
|
|
||||||
|
Emit:
|
||||||
|
got_cmd: If a new cmd was entered.
|
||||||
|
got_search: If a new search was entered.
|
||||||
|
got_search_rev: If a new reverse search was entered.
|
||||||
|
"""
|
||||||
|
signals = {
|
||||||
|
':': self.got_cmd,
|
||||||
|
'/': self.got_search,
|
||||||
|
'?': self.got_search_rev,
|
||||||
|
}
|
||||||
|
text = self.text()
|
||||||
|
self.history.append(text)
|
||||||
|
modes.leave("command")
|
||||||
|
if text[0] in signals:
|
||||||
|
signals[text[0]].emit(text.lstrip(text[0]))
|
||||||
|
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
"""Clear up when ommand mode was left.
|
"""Clear up when ommand mode was left.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user