Show More
@@ -18,7 +18,7 b' class BracketMatcher(QtCore.QObject):' | |||||
18 | # 'QObject' interface |
|
18 | # 'QObject' interface | |
19 | #-------------------------------------------------------------------------- |
|
19 | #-------------------------------------------------------------------------- | |
20 |
|
20 | |||
21 |
def __init__(self, parent |
|
21 | def __init__(self, parent): | |
22 | """ Create a call tip manager that is attached to the specified Qt |
|
22 | """ Create a call tip manager that is attached to the specified Qt | |
23 | text edit widget. |
|
23 | text edit widget. | |
24 | """ |
|
24 | """ |
@@ -334,12 +334,11 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
334 | else: |
|
334 | else: | |
335 | # Do this inside an edit block so continuation prompts are |
|
335 | # Do this inside an edit block so continuation prompts are | |
336 | # removed seamlessly via undo/redo. |
|
336 | # removed seamlessly via undo/redo. | |
337 |
cursor = self._ |
|
337 | cursor = self._get_end_cursor() | |
338 | cursor.beginEditBlock() |
|
338 | cursor.beginEditBlock() | |
339 |
|
339 | cursor.insertText('\n') | ||
340 | self._append_plain_text('\n') |
|
340 | self._insert_continuation_prompt(cursor) | |
341 | self._show_continuation_prompt() |
|
341 | self._control.moveCursor(QtGui.QTextCursor.End) | |
342 |
|
||||
343 | cursor.endEditBlock() |
|
342 | cursor.endEditBlock() | |
344 |
|
343 | |||
345 | return complete |
|
344 | return complete | |
@@ -431,9 +430,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
431 | """ Sets the font to the default fixed-width font for this platform. |
|
430 | """ Sets the font to the default fixed-width font for this platform. | |
432 | """ |
|
431 | """ | |
433 | # FIXME: font family and size should be configurable by the user. |
|
432 | # FIXME: font family and size should be configurable by the user. | |
434 |
|
||||
435 | if sys.platform == 'win32': |
|
433 | if sys.platform == 'win32': | |
436 |
# F |
|
434 | # FIXME: we should test whether Consolas is available and use it | |
437 | # first if it is. Consolas ships by default from Vista onwards, |
|
435 | # first if it is. Consolas ships by default from Vista onwards, | |
438 | # it's *vastly* more readable and prettier than Courier, and is |
|
436 | # it's *vastly* more readable and prettier than Courier, and is | |
439 | # often installed even on XP systems. So we should first check for |
|
437 | # often installed even on XP systems. So we should first check for | |
@@ -685,14 +683,34 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
685 |
|
683 | |||
686 | else: |
|
684 | else: | |
687 | if key in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): |
|
685 | if key in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): | |
688 | if self._reading: |
|
|||
689 | self._append_plain_text('\n') |
|
|||
690 | self._reading = False |
|
|||
691 | if self._reading_callback: |
|
|||
692 | self._reading_callback() |
|
|||
693 | elif not self._executing: |
|
|||
694 | self.execute(interactive=True) |
|
|||
695 | intercepted = True |
|
686 | intercepted = True | |
|
687 | if self._in_buffer(position): | |||
|
688 | if self._reading: | |||
|
689 | self._append_plain_text('\n') | |||
|
690 | self._reading = False | |||
|
691 | if self._reading_callback: | |||
|
692 | self._reading_callback() | |||
|
693 | ||||
|
694 | # If there is only whitespace after the cursor, execute. | |||
|
695 | # Otherwise, split the line with a continuation prompt. | |||
|
696 | elif not self._executing: | |||
|
697 | cursor.movePosition(QtGui.QTextCursor.End, | |||
|
698 | QtGui.QTextCursor.KeepAnchor) | |||
|
699 | if cursor.selectedText().trimmed().isEmpty(): | |||
|
700 | self.execute(interactive=True) | |||
|
701 | else: | |||
|
702 | cursor.beginEditBlock() | |||
|
703 | cursor.setPosition(position) | |||
|
704 | cursor.insertText('\n') | |||
|
705 | self._insert_continuation_prompt(cursor) | |||
|
706 | ||||
|
707 | # Ensure that the whole input buffer is visible. | |||
|
708 | # FIXME: This will not be usable if the input buffer | |||
|
709 | # is taller than the console widget. | |||
|
710 | self._control.moveCursor(QtGui.QTextCursor.End) | |||
|
711 | self._control.setTextCursor(cursor) | |||
|
712 | ||||
|
713 | cursor.endEditBlock() | |||
696 |
|
714 | |||
697 | elif key == QtCore.Qt.Key_Up: |
|
715 | elif key == QtCore.Qt.Key_Up: | |
698 | if self._reading or not self._up_pressed(): |
|
716 | if self._reading or not self._up_pressed(): | |
@@ -981,6 +999,15 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
981 | cursor.setPosition(position) |
|
999 | cursor.setPosition(position) | |
982 | return cursor |
|
1000 | return cursor | |
983 |
|
1001 | |||
|
1002 | def _insert_continuation_prompt(self, cursor): | |||
|
1003 | """ Inserts new continuation prompt using the specified cursor. | |||
|
1004 | """ | |||
|
1005 | if self._continuation_prompt_html is None: | |||
|
1006 | self._insert_plain_text(cursor, self._continuation_prompt) | |||
|
1007 | else: | |||
|
1008 | self._continuation_prompt = self._insert_html_fetching_plain_text( | |||
|
1009 | cursor, self._continuation_prompt_html) | |||
|
1010 | ||||
984 | def _insert_html(self, cursor, html): |
|
1011 | def _insert_html(self, cursor, html): | |
985 | """ Inserts HTML using the specified cursor in such a way that future |
|
1012 | """ Inserts HTML using the specified cursor in such a way that future | |
986 | formatting is unaffected. |
|
1013 | formatting is unaffected. | |
@@ -1264,15 +1291,6 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
1264 | self._prompt_pos = self._get_end_cursor().position() |
|
1291 | self._prompt_pos = self._get_end_cursor().position() | |
1265 | self._prompt_started() |
|
1292 | self._prompt_started() | |
1266 |
|
1293 | |||
1267 | def _show_continuation_prompt(self): |
|
|||
1268 | """ Writes a new continuation prompt at the end of the buffer. |
|
|||
1269 | """ |
|
|||
1270 | if self._continuation_prompt_html is None: |
|
|||
1271 | self._append_plain_text(self._continuation_prompt) |
|
|||
1272 | else: |
|
|||
1273 | self._continuation_prompt = self._append_html_fetching_plain_text( |
|
|||
1274 | self._continuation_prompt_html) |
|
|||
1275 |
|
||||
1276 |
|
1294 | |||
1277 | class HistoryConsoleWidget(ConsoleWidget): |
|
1295 | class HistoryConsoleWidget(ConsoleWidget): | |
1278 | """ A ConsoleWidget that keeps a history of the commands that have been |
|
1296 | """ A ConsoleWidget that keeps a history of the commands that have been |
@@ -180,13 +180,13 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
180 | return True |
|
180 | return True | |
181 | return super(FrontendWidget, self)._event_filter_console_keypress(event) |
|
181 | return super(FrontendWidget, self)._event_filter_console_keypress(event) | |
182 |
|
182 | |||
183 |
def _ |
|
183 | def _insert_continuation_prompt(self, cursor): | |
184 | """ Reimplemented for auto-indentation. |
|
184 | """ Reimplemented for auto-indentation. | |
185 | """ |
|
185 | """ | |
186 |
super(FrontendWidget, self)._ |
|
186 | super(FrontendWidget, self)._insert_continuation_prompt(cursor) | |
187 | spaces = self._input_splitter.indent_spaces |
|
187 | spaces = self._input_splitter.indent_spaces | |
188 |
|
|
188 | cursor.insertText('\t' * (spaces / self.tab_width)) | |
189 |
|
|
189 | cursor.insertText(' ' * (spaces % self.tab_width)) | |
190 |
|
190 | |||
191 | #--------------------------------------------------------------------------- |
|
191 | #--------------------------------------------------------------------------- | |
192 | # 'BaseFrontendMixin' abstract interface |
|
192 | # 'BaseFrontendMixin' abstract interface |
General Comments 0
You need to be logged in to leave comments.
Login now