Show More
@@ -102,7 +102,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
102 | QtCore.Qt.Key_N : QtCore.Qt.Key_Down, |
|
102 | QtCore.Qt.Key_N : QtCore.Qt.Key_Down, | |
103 | QtCore.Qt.Key_D : QtCore.Qt.Key_Delete, } |
|
103 | QtCore.Qt.Key_D : QtCore.Qt.Key_Delete, } | |
104 | _shortcuts = set(_ctrl_down_remap.keys() + |
|
104 | _shortcuts = set(_ctrl_down_remap.keys() + | |
105 |
[ QtCore.Qt.Key_C, QtCore.Qt.Key_ |
|
105 | [ QtCore.Qt.Key_C, QtCore.Qt.Key_G, QtCore.Qt.Key_O, | |
|
106 | QtCore.Qt.Key_V ]) | |||
106 |
|
107 | |||
107 | #--------------------------------------------------------------------------- |
|
108 | #--------------------------------------------------------------------------- | |
108 | # 'QObject' interface |
|
109 | # 'QObject' interface | |
@@ -667,20 +668,17 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
667 | alt_down = event.modifiers() & QtCore.Qt.AltModifier |
|
668 | alt_down = event.modifiers() & QtCore.Qt.AltModifier | |
668 | shift_down = event.modifiers() & QtCore.Qt.ShiftModifier |
|
669 | shift_down = event.modifiers() & QtCore.Qt.ShiftModifier | |
669 |
|
670 | |||
670 | # Special handling when tab completing in text mode: |
|
|||
671 | if self._text_completing_pos: |
|
|||
672 | if key in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return, |
|
|||
673 | QtCore.Qt.Key_Escape): |
|
|||
674 | self._clear_temporary_buffer() |
|
|||
675 | self._text_completing_pos = 0 |
|
|||
676 |
|
||||
677 | if event.matches(QtGui.QKeySequence.Paste): |
|
671 | if event.matches(QtGui.QKeySequence.Paste): | |
678 | # Call our paste instead of the underlying text widget's. |
|
672 | # Call our paste instead of the underlying text widget's. | |
679 | self.paste() |
|
673 | self.paste() | |
680 | intercepted = True |
|
674 | intercepted = True | |
681 |
|
675 | |||
682 | elif ctrl_down: |
|
676 | elif ctrl_down: | |
683 |
if key == QtCore.Qt.Key_ |
|
677 | if key == QtCore.Qt.Key_G: | |
|
678 | self._keyboard_quit() | |||
|
679 | intercepted = True | |||
|
680 | ||||
|
681 | elif key == QtCore.Qt.Key_K: | |||
684 | if self._in_buffer(position): |
|
682 | if self._in_buffer(position): | |
685 | cursor.movePosition(QtGui.QTextCursor.EndOfLine, |
|
683 | cursor.movePosition(QtGui.QTextCursor.EndOfLine, | |
686 | QtGui.QTextCursor.KeepAnchor) |
|
684 | QtGui.QTextCursor.KeepAnchor) | |
@@ -751,6 +749,12 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
751 | else: |
|
749 | else: | |
752 | if key in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): |
|
750 | if key in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): | |
753 | intercepted = True |
|
751 | intercepted = True | |
|
752 | ||||
|
753 | # Special handling when tab completing in text mode. | |||
|
754 | if self._text_completing_pos: | |||
|
755 | self._clear_temporary_buffer() | |||
|
756 | self._text_completing_pos = 0 | |||
|
757 | ||||
754 | if self._in_buffer(position): |
|
758 | if self._in_buffer(position): | |
755 | if self._reading: |
|
759 | if self._reading: | |
756 | self._append_plain_text('\n') |
|
760 | self._append_plain_text('\n') | |
@@ -763,8 +767,9 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
763 | elif not self._executing: |
|
767 | elif not self._executing: | |
764 | cursor.movePosition(QtGui.QTextCursor.End, |
|
768 | cursor.movePosition(QtGui.QTextCursor.End, | |
765 | QtGui.QTextCursor.KeepAnchor) |
|
769 | QtGui.QTextCursor.KeepAnchor) | |
766 |
|
|
770 | at_end = cursor.selectedText().trimmed().isEmpty() | |
767 | self.execute(interactive=True) |
|
771 | if at_end or shift_down: | |
|
772 | self.execute(interactive = not shift_down) | |||
768 | else: |
|
773 | else: | |
769 | # Do this inside an edit block for clean undo/redo. |
|
774 | # Do this inside an edit block for clean undo/redo. | |
770 | cursor.beginEditBlock() |
|
775 | cursor.beginEditBlock() | |
@@ -779,6 +784,10 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
779 | self._control.moveCursor(QtGui.QTextCursor.End) |
|
784 | self._control.moveCursor(QtGui.QTextCursor.End) | |
780 | self._control.setTextCursor(cursor) |
|
785 | self._control.setTextCursor(cursor) | |
781 |
|
786 | |||
|
787 | elif key == QtCore.Qt.Key_Escape: | |||
|
788 | self._keyboard_quit() | |||
|
789 | intercepted = True | |||
|
790 | ||||
782 | elif key == QtCore.Qt.Key_Up: |
|
791 | elif key == QtCore.Qt.Key_Up: | |
783 | if self._reading or not self._up_pressed(): |
|
792 | if self._reading or not self._up_pressed(): | |
784 | intercepted = True |
|
793 | intercepted = True | |
@@ -1204,6 +1213,15 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
1204 | self._control.setTextCursor(cursor) |
|
1213 | self._control.setTextCursor(cursor) | |
1205 | return moved |
|
1214 | return moved | |
1206 |
|
1215 | |||
|
1216 | def _keyboard_quit(self): | |||
|
1217 | """ Cancels the current editing task ala Ctrl-G in Emacs. | |||
|
1218 | """ | |||
|
1219 | if self._text_completing_pos: | |||
|
1220 | self._clear_temporary_buffer() | |||
|
1221 | self._text_completing_pos = 0 | |||
|
1222 | else: | |||
|
1223 | self.input_buffer = '' | |||
|
1224 | ||||
1207 | def _page(self, text): |
|
1225 | def _page(self, text): | |
1208 | """ Displays text using the pager if it exceeds the height of the |
|
1226 | """ Displays text using the pager if it exceeds the height of the | |
1209 | visible area. |
|
1227 | visible area. |
General Comments 0
You need to be logged in to leave comments.
Login now