##// END OF EJS Templates
Fixed regressions in the pure Python kernel.
epatters -
Show More
@@ -792,9 +792,10 b' class ConsoleWidget(QtGui.QWidget):'
792 # Note: this code is adapted from columnize 0.3.2.
792 # Note: this code is adapted from columnize 0.3.2.
793 # See http://code.google.com/p/pycolumnize/
793 # See http://code.google.com/p/pycolumnize/
794
794
795 # Calculate the number of characters available.
795 width = self._control.viewport().width()
796 width = self._control.viewport().width()
796 char_width = QtGui.QFontMetrics(self.font).width(' ')
797 char_width = QtGui.QFontMetrics(self.font).width(' ')
797 displaywidth = max(5, width / char_width)
798 displaywidth = max(10, (width / char_width) - 1)
798
799
799 # Some degenerate cases.
800 # Some degenerate cases.
800 size = len(items)
801 size = len(items)
@@ -197,10 +197,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
197 cursor = self._get_cursor()
197 cursor = self._get_cursor()
198 if rep['parent_header']['msg_id'] == self._complete_id and \
198 if rep['parent_header']['msg_id'] == self._complete_id and \
199 cursor.position() == self._complete_pos:
199 cursor.position() == self._complete_pos:
200 # The completer tells us what text was actually used for the
200 text = '.'.join(self._get_context())
201 # matching, so we must move that many characters left to apply the
202 # completions.
203 text = rep['content']['matched_text']
204 cursor.movePosition(QtGui.QTextCursor.Left, n=len(text))
201 cursor.movePosition(QtGui.QTextCursor.Left, n=len(text))
205 self._complete_with_items(cursor, rep['content']['matches'])
202 self._complete_with_items(cursor, rep['content']['matches'])
206
203
@@ -311,14 +308,11 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
311 def _complete(self):
308 def _complete(self):
312 """ Performs completion at the current cursor location.
309 """ Performs completion at the current cursor location.
313 """
310 """
314 # We let the kernel split the input line, so we *always* send an empty
311 context = self._get_context()
315 # text field. Readline-based frontends do get a real text field which
312 if context:
316 # they can use.
317 text = ''
318
319 # Send the completion request to the kernel
313 # Send the completion request to the kernel
320 self._complete_id = self.kernel_manager.xreq_channel.complete(
314 self._complete_id = self.kernel_manager.xreq_channel.complete(
321 text, # text
315 '.'.join(context), # text
322 self._get_input_buffer_cursor_line(), # line
316 self._get_input_buffer_cursor_line(), # line
323 self._get_input_buffer_cursor_column(), # cursor_pos
317 self._get_input_buffer_cursor_column(), # cursor_pos
324 self.input_buffer) # block
318 self.input_buffer) # block
@@ -84,6 +84,19 b' class IPythonWidget(FrontendWidget):'
84 # 'BaseFrontendMixin' abstract interface
84 # 'BaseFrontendMixin' abstract interface
85 #---------------------------------------------------------------------------
85 #---------------------------------------------------------------------------
86
86
87 def _handle_complete_reply(self, rep):
88 """ Reimplemented to support IPython's improved completion machinery.
89 """
90 cursor = self._get_cursor()
91 if rep['parent_header']['msg_id'] == self._complete_id and \
92 cursor.position() == self._complete_pos:
93 # The completer tells us what text was actually used for the
94 # matching, so we must move that many characters left to apply the
95 # completions.
96 text = rep['content']['matched_text']
97 cursor.movePosition(QtGui.QTextCursor.Left, n=len(text))
98 self._complete_with_items(cursor, rep['content']['matches'])
99
87 def _handle_history_reply(self, msg):
100 def _handle_history_reply(self, msg):
88 """ Implemented to handle history replies, which are only supported by
101 """ Implemented to handle history replies, which are only supported by
89 the IPython kernel.
102 the IPython kernel.
@@ -131,6 +144,22 b' class IPythonWidget(FrontendWidget):'
131 # 'FrontendWidget' protected interface
144 # 'FrontendWidget' protected interface
132 #---------------------------------------------------------------------------
145 #---------------------------------------------------------------------------
133
146
147 def _complete(self):
148 """ Reimplemented to support IPython's improved completion machinery.
149 """
150 # We let the kernel split the input line, so we *always* send an empty
151 # text field. Readline-based frontends do get a real text field which
152 # they can use.
153 text = ''
154
155 # Send the completion request to the kernel
156 self._complete_id = self.kernel_manager.xreq_channel.complete(
157 text, # text
158 self._get_input_buffer_cursor_line(), # line
159 self._get_input_buffer_cursor_column(), # cursor_pos
160 self.input_buffer) # block
161 self._complete_pos = self._get_cursor().position()
162
134 def _get_banner(self):
163 def _get_banner(self):
135 """ Reimplemented to return IPython's default banner.
164 """ Reimplemented to return IPython's default banner.
136 """
165 """
@@ -131,7 +131,7 b' class Kernel(HasTraits):'
131 self._abort_queue()
131 self._abort_queue()
132
132
133 def complete_request(self, ident, parent):
133 def complete_request(self, ident, parent):
134 matches = {'matches' : self.complete(parent),
134 matches = {'matches' : self._complete(parent),
135 'status' : 'ok'}
135 'status' : 'ok'}
136 completion_msg = self.session.send(self.reply_socket, 'complete_reply',
136 completion_msg = self.session.send(self.reply_socket, 'complete_reply',
137 matches, parent, ident)
137 matches, parent, ident)
General Comments 0
You need to be logged in to leave comments. Login now