Show More
@@ -792,9 +792,10 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
792 | 792 | # Note: this code is adapted from columnize 0.3.2. |
|
793 | 793 | # See http://code.google.com/p/pycolumnize/ |
|
794 | 794 | |
|
795 | # Calculate the number of characters available. | |
|
795 | 796 | width = self._control.viewport().width() |
|
796 | 797 | char_width = QtGui.QFontMetrics(self.font).width(' ') |
|
797 |
displaywidth = max( |
|
|
798 | displaywidth = max(10, (width / char_width) - 1) | |
|
798 | 799 | |
|
799 | 800 | # Some degenerate cases. |
|
800 | 801 | size = len(items) |
@@ -197,10 +197,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
197 | 197 | cursor = self._get_cursor() |
|
198 | 198 | if rep['parent_header']['msg_id'] == self._complete_id and \ |
|
199 | 199 | cursor.position() == self._complete_pos: |
|
200 | # The completer tells us what text was actually used for the | |
|
201 | # matching, so we must move that many characters left to apply the | |
|
202 | # completions. | |
|
203 | text = rep['content']['matched_text'] | |
|
200 | text = '.'.join(self._get_context()) | |
|
204 | 201 | cursor.movePosition(QtGui.QTextCursor.Left, n=len(text)) |
|
205 | 202 | self._complete_with_items(cursor, rep['content']['matches']) |
|
206 | 203 | |
@@ -311,18 +308,15 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
311 | 308 | def _complete(self): |
|
312 | 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 | |
|
315 | # text field. Readline-based frontends do get a real text field which | |
|
316 | # they can use. | |
|
317 | text = '' | |
|
318 | ||
|
319 | # Send the completion request to the kernel | |
|
320 | self._complete_id = self.kernel_manager.xreq_channel.complete( | |
|
321 |
|
|
|
322 | self._get_input_buffer_cursor_line(), # line | |
|
323 | self._get_input_buffer_cursor_column(), # cursor_pos | |
|
324 | self.input_buffer) # block | |
|
325 | self._complete_pos = self._get_cursor().position() | |
|
311 | context = self._get_context() | |
|
312 | if context: | |
|
313 | # Send the completion request to the kernel | |
|
314 | self._complete_id = self.kernel_manager.xreq_channel.complete( | |
|
315 | '.'.join(context), # text | |
|
316 | self._get_input_buffer_cursor_line(), # line | |
|
317 | self._get_input_buffer_cursor_column(), # cursor_pos | |
|
318 | self.input_buffer) # block | |
|
319 | self._complete_pos = self._get_cursor().position() | |
|
326 | 320 | |
|
327 | 321 | def _get_banner(self): |
|
328 | 322 | """ Gets a banner to display at the beginning of a session. |
@@ -84,6 +84,19 b' class IPythonWidget(FrontendWidget):' | |||
|
84 | 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 | 100 | def _handle_history_reply(self, msg): |
|
88 | 101 | """ Implemented to handle history replies, which are only supported by |
|
89 | 102 | the IPython kernel. |
@@ -131,6 +144,22 b' class IPythonWidget(FrontendWidget):' | |||
|
131 | 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 | 163 | def _get_banner(self): |
|
135 | 164 | """ Reimplemented to return IPython's default banner. |
|
136 | 165 | """ |
@@ -131,7 +131,7 b' class Kernel(HasTraits):' | |||
|
131 | 131 | self._abort_queue() |
|
132 | 132 | |
|
133 | 133 | def complete_request(self, ident, parent): |
|
134 | matches = {'matches' : self.complete(parent), | |
|
134 | matches = {'matches' : self._complete(parent), | |
|
135 | 135 | 'status' : 'ok'} |
|
136 | 136 | completion_msg = self.session.send(self.reply_socket, 'complete_reply', |
|
137 | 137 | matches, parent, ident) |
General Comments 0
You need to be logged in to leave comments.
Login now