##// END OF EJS Templates
* Tab completion now uses the correct cursor position....
epatters -
Show More
@@ -802,19 +802,41 b' class ConsoleWidget(QtGui.QWidget):'
802 802 cursor.movePosition(QtGui.QTextCursor.End)
803 803 return cursor
804 804
805 def _get_input_buffer_cursor_column(self):
806 """ Returns the column of the cursor in the input buffer, excluding the
807 contribution by the prompt, or -1 if there is no such column.
808 """
809 prompt = self._get_input_buffer_cursor_prompt()
810 if prompt is None:
811 return -1
812 else:
813 cursor = self._control.textCursor()
814 return cursor.columnNumber() - len(prompt)
815
805 816 def _get_input_buffer_cursor_line(self):
806 """ The text in the line of the input buffer in which the user's cursor
807 rests. Returns a string if there is such a line; otherwise, None.
817 """ Returns line of the input buffer that contains the cursor, or None
818 if there is no such line.
819 """
820 prompt = self._get_input_buffer_cursor_prompt()
821 if prompt is None:
822 return None
823 else:
824 cursor = self._control.textCursor()
825 text = self._get_block_plain_text(cursor.block())
826 return text[len(prompt):]
827
828 def _get_input_buffer_cursor_prompt(self):
829 """ Returns the (plain text) prompt for line of the input buffer that
830 contains the cursor, or None if there is no such line.
808 831 """
809 832 if self._executing:
810 833 return None
811 834 cursor = self._control.textCursor()
812 835 if cursor.position() >= self._prompt_pos:
813 text = self._get_block_plain_text(cursor.block())
814 836 if cursor.blockNumber() == self._get_prompt_cursor().blockNumber():
815 return text[len(self._prompt):]
837 return self._prompt
816 838 else:
817 return text[len(self._continuation_prompt):]
839 return self._continuation_prompt
818 840 else:
819 841 return None
820 842
@@ -292,16 +292,11 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
292 292 return False
293 293
294 294 # Send the completion request to the kernel
295 text = '.'.join(context)
296
297 # FIXME - Evan: we need the position of the cursor in the current input
298 # buffer. I tried this line below but the numbers I get are bogus. -
299 # Not sure what to do. fperez.
300 cursor_pos = self._get_cursor().position()
301
302 295 self._complete_id = self.kernel_manager.xreq_channel.complete(
303 text, self._get_input_buffer_cursor_line(), cursor_pos,
304 self.input_buffer)
296 '.'.join(context), # text
297 self._get_input_buffer_cursor_line(), # line
298 self._get_input_buffer_cursor_column(), # cursor_pos
299 self.input_buffer) # block
305 300 self._complete_pos = self._get_cursor().position()
306 301 return True
307 302
@@ -109,11 +109,9 b' class IPythonWidget(FrontendWidget):'
109 109 """ Reimplemented for IPython-style traceback formatting.
110 110 """
111 111 content = msg['content']
112
113 traceback = '\n'.join(content['traceback'])
114
115 if 0:
116 # FIXME: for now, tracebacks come as plain text, so we can't use
112 traceback = '\n'.join(content['traceback']) + '\n'
113 if False:
114 # FIXME: For now, tracebacks come as plain text, so we can't use
117 115 # the html renderer yet. Once we refactor ultratb to produce
118 116 # properly styled tracebacks, this branch should be the default
119 117 traceback = traceback.replace(' ', ' ')
@@ -61,11 +61,7 b' def main():'
61 61 kernel_manager.start_kernel()
62 62 kernel_manager.start_channels()
63 63
64 # FIXME: this is a hack, set colors to lightbg by default in qt terminal
65 # unconditionally, regardless of user settings in config files.
66 kernel_manager.xreq_channel.execute("%colors lightbg")
67
68 # Launch the application.
64 # Create the widget.
69 65 app = QtGui.QApplication([])
70 66 if args.pure:
71 67 kind = 'rich' if args.rich else 'plain'
@@ -77,6 +73,12 b' def main():'
77 73 widget.kernel_manager = kernel_manager
78 74 widget.setWindowTitle('Python' if args.pure else 'IPython')
79 75 widget.show()
76
77 # FIXME: This is a hack: set colors to lightbg by default in qt terminal
78 # unconditionally, regardless of user settings in config files.
79 widget.execute("%colors lightbg", hidden=True)
80
81 # Start the application main loop.
80 82 app.exec_()
81 83
82 84
@@ -183,7 +183,7 b' class XReqSocketChannel(ZmqSocketChannel):'
183 183 return msg['header']['msg_id']
184 184
185 185 def complete(self, text, line, cursor_pos, block=None):
186 """Tab complete text, line, block in the kernel's namespace.
186 """Tab complete text in the kernel's namespace.
187 187
188 188 Parameters
189 189 ----------
@@ -192,7 +192,10 b' class XReqSocketChannel(ZmqSocketChannel):'
192 192 line : str
193 193 The full line of text that is the surrounding context for the
194 194 text to complete.
195 block : str
195 cursor_pos : int
196 The position of the cursor in the line where the completion was
197 requested.
198 block : str, optional
196 199 The full block of code in which the completion is being requested.
197 200
198 201 Returns
General Comments 0
You need to be logged in to leave comments. Login now