Show More
@@ -361,7 +361,7 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
361 | 361 | except UnicodeEncodeError: |
|
362 | 362 | pass |
|
363 | 363 | else: |
|
364 | self._insert_into_buffer(dedent(text)) | |
|
364 | self._insert_plain_text_into_buffer(dedent(text)) | |
|
365 | 365 | |
|
366 | 366 | def print_(self, printer): |
|
367 | 367 | """ Print the contents of the ConsoleWidget to the specified QPrinter. |
@@ -477,11 +477,8 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
477 | 477 | def _append_html_fetching_plain_text(self, html): |
|
478 | 478 | """ Appends 'html', then returns the plain text version of it. |
|
479 | 479 | """ |
|
480 | anchor = self._get_end_cursor().position() | |
|
481 | self._append_html(html) | |
|
482 | 480 | cursor = self._get_end_cursor() |
|
483 | cursor.setPosition(anchor, QtGui.QTextCursor.KeepAnchor) | |
|
484 | return str(cursor.selection().toPlainText()) | |
|
481 | return self._insert_html_fetching_plain_text(cursor, html) | |
|
485 | 482 | |
|
486 | 483 | def _append_plain_text(self, text): |
|
487 | 484 | """ Appends plain text at the end of the console buffer, processing |
@@ -872,7 +869,7 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
872 | 869 | return cursor |
|
873 | 870 | |
|
874 | 871 | def _insert_html(self, cursor, html): |
|
875 | """ Insert HTML using the specified cursor in such a way that future | |
|
872 | """ Inserts HTML using the specified cursor in such a way that future | |
|
876 | 873 | formatting is unaffected. |
|
877 | 874 | """ |
|
878 | 875 | cursor.beginEditBlock() |
@@ -890,6 +887,18 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
890 | 887 | cursor.insertText(' ', QtGui.QTextCharFormat()) |
|
891 | 888 | cursor.endEditBlock() |
|
892 | 889 | |
|
890 | def _insert_html_fetching_plain_text(self, cursor, html): | |
|
891 | """ Inserts HTML using the specified cursor, then returns its plain text | |
|
892 | version. | |
|
893 | """ | |
|
894 | start = cursor.position() | |
|
895 | self._insert_html(cursor, html) | |
|
896 | end = cursor.position() | |
|
897 | cursor.setPosition(start, QtGui.QTextCursor.KeepAnchor) | |
|
898 | text = str(cursor.selection().toPlainText()) | |
|
899 | cursor.setPosition(end) | |
|
900 | return text | |
|
901 | ||
|
893 | 902 | def _insert_plain_text(self, cursor, text): |
|
894 | 903 | """ Inserts plain text using the specified cursor, processing ANSI codes |
|
895 | 904 | if enabled. |
@@ -907,7 +916,7 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
907 | 916 | cursor.insertText(text) |
|
908 | 917 | cursor.endEditBlock() |
|
909 | 918 | |
|
910 | def _insert_into_buffer(self, text): | |
|
919 | def _insert_plain_text_into_buffer(self, text): | |
|
911 | 920 | """ Inserts text into the input buffer at the current cursor position, |
|
912 | 921 | ensuring that continuation prompts are inserted as necessary. |
|
913 | 922 | """ |
@@ -921,7 +930,9 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
921 | 930 | if self._continuation_prompt_html is None: |
|
922 | 931 | cursor.insertText(self._continuation_prompt) |
|
923 | 932 | else: |
|
924 |
self._ |
|
|
933 | self._continuation_prompt = \ | |
|
934 | self._insert_html_fetching_plain_text( | |
|
935 | cursor, self._continuation_prompt_html) | |
|
925 | 936 | cursor.insertText(line) |
|
926 | 937 | cursor.endEditBlock() |
|
927 | 938 | self._control.setTextCursor(cursor) |
@@ -125,13 +125,6 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
125 | 125 | if not self._reading: |
|
126 | 126 | self._highlighter.highlighting_on = True |
|
127 | 127 | |
|
128 | # Auto-indent if this is a continuation prompt. | |
|
129 | if self._get_prompt_cursor().blockNumber() != \ | |
|
130 | self._get_end_cursor().blockNumber(): | |
|
131 | spaces = self._input_splitter.indent_spaces | |
|
132 | self._append_plain_text('\t' * (spaces / self.tab_width)) | |
|
133 | self._append_plain_text(' ' * (spaces % self.tab_width)) | |
|
134 | ||
|
135 | 128 | def _prompt_finished_hook(self): |
|
136 | 129 | """ Called immediately after a prompt is finished, i.e. when some input |
|
137 | 130 | will be processed and a new prompt displayed. |
@@ -148,6 +141,18 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
148 | 141 | return not self._complete() |
|
149 | 142 | |
|
150 | 143 | #--------------------------------------------------------------------------- |
|
144 | # 'ConsoleWidget' protected interface | |
|
145 | #--------------------------------------------------------------------------- | |
|
146 | ||
|
147 | def _show_continuation_prompt(self): | |
|
148 | """ Reimplemented for auto-indentation. | |
|
149 | """ | |
|
150 | super(FrontendWidget, self)._show_continuation_prompt() | |
|
151 | spaces = self._input_splitter.indent_spaces | |
|
152 | self._append_plain_text('\t' * (spaces / self.tab_width)) | |
|
153 | self._append_plain_text(' ' * (spaces % self.tab_width)) | |
|
154 | ||
|
155 | #--------------------------------------------------------------------------- | |
|
151 | 156 | # 'BaseFrontendMixin' abstract interface |
|
152 | 157 | #--------------------------------------------------------------------------- |
|
153 | 158 |
General Comments 0
You need to be logged in to leave comments.
Login now