mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 17:01:34 +00:00
Handle KeyboardInterrupt in Python Console (#6643)
Use Ctrl+C to raise a KeyboardInterrupt. This is especially useful to escape constructs. Example: >>> for i in range(0, 3): ... KeyboardInterrupt >>>
This commit is contained in:
parent
653a24a49b
commit
15de954d6a
1 changed files with 7 additions and 0 deletions
|
@ -95,6 +95,11 @@ class Console(QtWidgets.QPlainTextEdit):
|
|||
self.setPlainText('')
|
||||
self.newPrompt(curr_line)
|
||||
|
||||
def keyboard_interrupt(self):
|
||||
self.construct = []
|
||||
self.appendPlainText('KeyboardInterrupt')
|
||||
self.newPrompt('')
|
||||
|
||||
def newPrompt(self, curr_line):
|
||||
if self.construct:
|
||||
prompt = '... ' + curr_line
|
||||
|
@ -286,6 +291,8 @@ class Console(QtWidgets.QPlainTextEdit):
|
|||
return
|
||||
elif event.key() == QtCore.Qt.Key_L and event.modifiers() == QtCore.Qt.ControlModifier:
|
||||
self.clear()
|
||||
elif event.key() == QtCore.Qt.Key_C and event.modifiers() == QtCore.Qt.ControlModifier:
|
||||
self.keyboard_interrupt()
|
||||
|
||||
super(Console, self).keyPressEvent(event)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue