Show More
@@ -11,7 +11,7 b' class CallTipWidget(QtGui.QLabel):' | |||
|
11 | 11 | """ |
|
12 | 12 | |
|
13 | 13 | #-------------------------------------------------------------------------- |
|
14 |
# 'Q |
|
|
14 | # 'QObject' interface | |
|
15 | 15 | #-------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | 17 | def __init__(self, parent): |
@@ -34,12 +34,23 b' class CallTipWidget(QtGui.QLabel):' | |||
|
34 | 34 | self.setWindowOpacity(self.style().styleHint( |
|
35 | 35 | QtGui.QStyle.SH_ToolTipLabel_Opacity, None, self) / 255.0) |
|
36 | 36 | |
|
37 | #-------------------------------------------------------------------------- | |
|
38 | # 'QWidget' interface | |
|
39 | #-------------------------------------------------------------------------- | |
|
40 | ||
|
37 | 41 | def hideEvent(self, event): |
|
38 | 42 | """ Reimplemented to disconnect the cursor movement handler. |
|
39 | 43 | """ |
|
40 | 44 | QtGui.QLabel.hideEvent(self, event) |
|
41 | 45 | self.parent().cursorPositionChanged.disconnect(self._update_tip) |
|
42 | 46 | |
|
47 | def keyPressEvent(self, event): | |
|
48 | """ Reimplemented to hide on certain key presses. | |
|
49 | """ | |
|
50 | if event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return, | |
|
51 | QtCore.Qt.Key_Escape): | |
|
52 | self.hide() | |
|
53 | ||
|
43 | 54 | def paintEvent(self, event): |
|
44 | 55 | """ Reimplemented to paint the background panel. |
|
45 | 56 | """ |
@@ -123,6 +123,8 b' class ConsoleWidget(QtGui.QPlainTextEdit):' | |||
|
123 | 123 | QtCore.Qt.Key_P : QtCore.Qt.Key_Up, |
|
124 | 124 | QtCore.Qt.Key_N : QtCore.Qt.Key_Down, |
|
125 | 125 | QtCore.Qt.Key_D : QtCore.Qt.Key_Delete, } |
|
126 | _shortcuts = set(_ctrl_down_remap.keys() + | |
|
127 | [ QtCore.Qt.Key_C, QtCore.Qt.Key_V ]) | |
|
126 | 128 | |
|
127 | 129 | #--------------------------------------------------------------------------- |
|
128 | 130 | # 'QObject' interface |
@@ -170,7 +172,7 b' class ConsoleWidget(QtGui.QPlainTextEdit):' | |||
|
170 | 172 | sys.platform != 'darwin' and \ |
|
171 | 173 | event.type() == QtCore.QEvent.ShortcutOverride and \ |
|
172 | 174 | self._control_down(event.modifiers()) and \ |
|
173 |
event.key() in self._ |
|
|
175 | event.key() in self._shortcuts: | |
|
174 | 176 | event.accept() |
|
175 | 177 | return True |
|
176 | 178 | else: |
@@ -220,6 +222,9 b' class ConsoleWidget(QtGui.QPlainTextEdit):' | |||
|
220 | 222 | cursor.removeSelectedText() |
|
221 | 223 | intercepted = True |
|
222 | 224 | |
|
225 | elif key == QtCore.Qt.Key_X: | |
|
226 | intercepted = True | |
|
227 | ||
|
223 | 228 | elif key == QtCore.Qt.Key_Y: |
|
224 | 229 | self.paste() |
|
225 | 230 | intercepted = True |
@@ -1,3 +1,6 b'' | |||
|
1 | # Standard library imports | |
|
2 | import signal | |
|
3 | ||
|
1 | 4 | # System library imports |
|
2 | 5 | from pygments.lexers import PythonLexer |
|
3 | 6 | from PyQt4 import QtCore, QtGui |
@@ -77,14 +80,18 b' class FrontendWidget(HistoryConsoleWidget):' | |||
|
77 | 80 | """ Reimplemented to hide calltips. |
|
78 | 81 | """ |
|
79 | 82 | self._call_tip_widget.hide() |
|
80 |
|
|
|
83 | super(FrontendWidget, self).focusOutEvent(event) | |
|
81 | 84 | |
|
82 | 85 | def keyPressEvent(self, event): |
|
83 |
""" Reimplemented to |
|
|
86 | """ Reimplemented to allow calltips to process events and to send | |
|
87 | signals to the kernel. | |
|
84 | 88 | """ |
|
85 |
if event.key() == QtCore.Qt.Key_ |
|
|
86 |
self._c |
|
|
87 | return super(FrontendWidget, self).keyPressEvent(event) | |
|
89 | if self._executing and event.key() == QtCore.Qt.Key_C and \ | |
|
90 | self._control_down(event.modifiers()): | |
|
91 | self._interrupt_kernel() | |
|
92 | else: | |
|
93 | self._call_tip_widget.keyPressEvent(event) | |
|
94 | super(FrontendWidget, self).keyPressEvent(event) | |
|
88 | 95 | |
|
89 | 96 | #--------------------------------------------------------------------------- |
|
90 | 97 | # 'ConsoleWidget' abstract interface |
@@ -168,6 +175,10 b' class FrontendWidget(HistoryConsoleWidget):' | |||
|
168 | 175 | xreq.complete_reply.disconnect(self._handle_complete_reply) |
|
169 | 176 | xreq.object_info_reply.disconnect(self._handle_object_info_reply) |
|
170 | 177 | |
|
178 | # Handle the case where the old kernel manager is still listening. | |
|
179 | if self._kernel_manager.is_listening: | |
|
180 | self._stopped_listening() | |
|
181 | ||
|
171 | 182 | # Set the new kernel manager. |
|
172 | 183 | self._kernel_manager = kernel_manager |
|
173 | 184 | if kernel_manager is None: |
@@ -240,6 +251,15 b' class FrontendWidget(HistoryConsoleWidget):' | |||
|
240 | 251 | text = unicode(cursor.selectedText()) |
|
241 | 252 | return self._completion_lexer.get_context(text) |
|
242 | 253 | |
|
254 | def _interrupt_kernel(self): | |
|
255 | """ Attempts to the interrupt the kernel. | |
|
256 | """ | |
|
257 | if self.kernel_manager.has_kernel: | |
|
258 | self.kernel_manager.signal_kernel(signal.SIGINT) | |
|
259 | else: | |
|
260 | self.appendPlainText('Kernel process is either remote or ' | |
|
261 | 'unspecified. Cannot interrupt.\n') | |
|
262 | ||
|
243 | 263 | #------ Signal handlers ---------------------------------------------------- |
|
244 | 264 | |
|
245 | 265 | def _document_contents_change(self, position, removed, added): |
General Comments 0
You need to be logged in to leave comments.
Login now