##// END OF EJS Templates
Fixed bug with ConsoleWidget smart paste.
epatters -
Show More
@@ -361,7 +361,7 b' class ConsoleWidget(QtGui.QWidget):'
361 except UnicodeEncodeError:
361 except UnicodeEncodeError:
362 pass
362 pass
363 else:
363 else:
364 self._insert_into_buffer(dedent(text))
364 self._insert_plain_text_into_buffer(dedent(text))
365
365
366 def print_(self, printer):
366 def print_(self, printer):
367 """ Print the contents of the ConsoleWidget to the specified QPrinter.
367 """ Print the contents of the ConsoleWidget to the specified QPrinter.
@@ -477,11 +477,8 b' class ConsoleWidget(QtGui.QWidget):'
477 def _append_html_fetching_plain_text(self, html):
477 def _append_html_fetching_plain_text(self, html):
478 """ Appends 'html', then returns the plain text version of it.
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 cursor = self._get_end_cursor()
480 cursor = self._get_end_cursor()
483 cursor.setPosition(anchor, QtGui.QTextCursor.KeepAnchor)
481 return self._insert_html_fetching_plain_text(cursor, html)
484 return str(cursor.selection().toPlainText())
485
482
486 def _append_plain_text(self, text):
483 def _append_plain_text(self, text):
487 """ Appends plain text at the end of the console buffer, processing
484 """ Appends plain text at the end of the console buffer, processing
@@ -872,7 +869,7 b' class ConsoleWidget(QtGui.QWidget):'
872 return cursor
869 return cursor
873
870
874 def _insert_html(self, cursor, html):
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 formatting is unaffected.
873 formatting is unaffected.
877 """
874 """
878 cursor.beginEditBlock()
875 cursor.beginEditBlock()
@@ -890,6 +887,18 b' class ConsoleWidget(QtGui.QWidget):'
890 cursor.insertText(' ', QtGui.QTextCharFormat())
887 cursor.insertText(' ', QtGui.QTextCharFormat())
891 cursor.endEditBlock()
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 def _insert_plain_text(self, cursor, text):
902 def _insert_plain_text(self, cursor, text):
894 """ Inserts plain text using the specified cursor, processing ANSI codes
903 """ Inserts plain text using the specified cursor, processing ANSI codes
895 if enabled.
904 if enabled.
@@ -907,7 +916,7 b' class ConsoleWidget(QtGui.QWidget):'
907 cursor.insertText(text)
916 cursor.insertText(text)
908 cursor.endEditBlock()
917 cursor.endEditBlock()
909
918
910 def _insert_into_buffer(self, text):
919 def _insert_plain_text_into_buffer(self, text):
911 """ Inserts text into the input buffer at the current cursor position,
920 """ Inserts text into the input buffer at the current cursor position,
912 ensuring that continuation prompts are inserted as necessary.
921 ensuring that continuation prompts are inserted as necessary.
913 """
922 """
@@ -921,7 +930,9 b' class ConsoleWidget(QtGui.QWidget):'
921 if self._continuation_prompt_html is None:
930 if self._continuation_prompt_html is None:
922 cursor.insertText(self._continuation_prompt)
931 cursor.insertText(self._continuation_prompt)
923 else:
932 else:
924 self._insert_html(cursor, self._continuation_prompt_html)
933 self._continuation_prompt = \
934 self._insert_html_fetching_plain_text(
935 cursor, self._continuation_prompt_html)
925 cursor.insertText(line)
936 cursor.insertText(line)
926 cursor.endEditBlock()
937 cursor.endEditBlock()
927 self._control.setTextCursor(cursor)
938 self._control.setTextCursor(cursor)
@@ -125,13 +125,6 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
125 if not self._reading:
125 if not self._reading:
126 self._highlighter.highlighting_on = True
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 def _prompt_finished_hook(self):
128 def _prompt_finished_hook(self):
136 """ Called immediately after a prompt is finished, i.e. when some input
129 """ Called immediately after a prompt is finished, i.e. when some input
137 will be processed and a new prompt displayed.
130 will be processed and a new prompt displayed.
@@ -148,6 +141,18 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
148 return not self._complete()
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 # 'BaseFrontendMixin' abstract interface
156 # 'BaseFrontendMixin' abstract interface
152 #---------------------------------------------------------------------------
157 #---------------------------------------------------------------------------
153
158
General Comments 0
You need to be logged in to leave comments. Login now