Show More
@@ -18,7 +18,7 b' class BracketMatcher(QtCore.QObject):' | |||
|
18 | 18 | # 'QObject' interface |
|
19 | 19 | #-------------------------------------------------------------------------- |
|
20 | 20 | |
|
21 |
def __init__(self, parent |
|
|
21 | def __init__(self, parent): | |
|
22 | 22 | """ Create a call tip manager that is attached to the specified Qt |
|
23 | 23 | text edit widget. |
|
24 | 24 | """ |
@@ -334,12 +334,11 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
334 | 334 | else: |
|
335 | 335 | # Do this inside an edit block so continuation prompts are |
|
336 | 336 | # removed seamlessly via undo/redo. |
|
337 |
cursor = self._ |
|
|
337 | cursor = self._get_end_cursor() | |
|
338 | 338 | cursor.beginEditBlock() |
|
339 | ||
|
340 | self._append_plain_text('\n') | |
|
341 | self._show_continuation_prompt() | |
|
342 | ||
|
339 | cursor.insertText('\n') | |
|
340 | self._insert_continuation_prompt(cursor) | |
|
341 | self._control.moveCursor(QtGui.QTextCursor.End) | |
|
343 | 342 | cursor.endEditBlock() |
|
344 | 343 | |
|
345 | 344 | return complete |
@@ -431,9 +430,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
431 | 430 | """ Sets the font to the default fixed-width font for this platform. |
|
432 | 431 | """ |
|
433 | 432 | # FIXME: font family and size should be configurable by the user. |
|
434 | ||
|
435 | 433 | if sys.platform == 'win32': |
|
436 |
# F |
|
|
434 | # FIXME: we should test whether Consolas is available and use it | |
|
437 | 435 | # first if it is. Consolas ships by default from Vista onwards, |
|
438 | 436 | # it's *vastly* more readable and prettier than Courier, and is |
|
439 | 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 | 684 | else: |
|
687 | 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 | 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 | 715 | elif key == QtCore.Qt.Key_Up: |
|
698 | 716 | if self._reading or not self._up_pressed(): |
@@ -981,6 +999,15 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
981 | 999 | cursor.setPosition(position) |
|
982 | 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 | 1011 | def _insert_html(self, cursor, html): |
|
985 | 1012 | """ Inserts HTML using the specified cursor in such a way that future |
|
986 | 1013 | formatting is unaffected. |
@@ -1264,15 +1291,6 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
1264 | 1291 | self._prompt_pos = self._get_end_cursor().position() |
|
1265 | 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 | 1295 | class HistoryConsoleWidget(ConsoleWidget): |
|
1278 | 1296 | """ A ConsoleWidget that keeps a history of the commands that have been |
@@ -180,13 +180,13 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
180 | 180 | return True |
|
181 | 181 | return super(FrontendWidget, self)._event_filter_console_keypress(event) |
|
182 | 182 | |
|
183 |
def _ |
|
|
183 | def _insert_continuation_prompt(self, cursor): | |
|
184 | 184 | """ Reimplemented for auto-indentation. |
|
185 | 185 | """ |
|
186 |
super(FrontendWidget, self)._ |
|
|
186 | super(FrontendWidget, self)._insert_continuation_prompt(cursor) | |
|
187 | 187 | spaces = self._input_splitter.indent_spaces |
|
188 |
|
|
|
189 |
|
|
|
188 | cursor.insertText('\t' * (spaces / self.tab_width)) | |
|
189 | cursor.insertText(' ' * (spaces % self.tab_width)) | |
|
190 | 190 | |
|
191 | 191 | #--------------------------------------------------------------------------- |
|
192 | 192 | # 'BaseFrontendMixin' abstract interface |
General Comments 0
You need to be logged in to leave comments.
Login now