##// END OF EJS Templates
Form feeds are now properly supported by ConsoleWidget.
epatters -
Show More
@@ -363,11 +363,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
363 # disable the undo/redo history, but just to be safe:
363 # disable the undo/redo history, but just to be safe:
364 self._control.setUndoRedoEnabled(False)
364 self._control.setUndoRedoEnabled(False)
365
365
366 # Flush all state from the input splitter so the next round of
366 # Perform actual execution.
367 # reading input starts with a clean buffer.
368 self._input_splitter.reset()
369
370 # Call actual execution
371 self._execute(source, hidden)
367 self._execute(source, hidden)
372
368
373 else:
369 else:
@@ -477,13 +473,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
477 """ Moves the prompt to the top of the viewport.
473 """ Moves the prompt to the top of the viewport.
478 """
474 """
479 if not self._executing:
475 if not self._executing:
480 scrollbar = self._control.verticalScrollBar()
476 self._set_top_cursor(self._get_prompt_cursor())
481 scrollbar.setValue(scrollbar.maximum())
482 cursor = self._control.textCursor()
483 self._control.setTextCursor(self._get_prompt_cursor())
484 self._control.ensureCursorVisible()
485 QtGui.qApp.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)
486 self._control.setTextCursor(cursor)
487
477
488 def redo(self):
478 def redo(self):
489 """ Redo the last operation. If there is no operation to redo, nothing
479 """ Redo the last operation. If there is no operation to redo, nothing
@@ -1277,10 +1267,22 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
1277 if self.ansi_codes:
1267 if self.ansi_codes:
1278 for substring in self._ansi_processor.split_string(text):
1268 for substring in self._ansi_processor.split_string(text):
1279 for act in self._ansi_processor.actions:
1269 for act in self._ansi_processor.actions:
1280 if ((act.action == 'erase' and act.area == 'screen') or
1270
1281 (act.action == 'scroll' and act.unit == 'page')):
1271 # Unlike real terminal emulators, we don't distinguish
1272 # between the screen and the scrollback buffer. A screen
1273 # erase request clears everything.
1274 if act.action == 'erase' and act.area == 'screen':
1282 cursor.select(QtGui.QTextCursor.Document)
1275 cursor.select(QtGui.QTextCursor.Document)
1283 cursor.removeSelectedText()
1276 cursor.removeSelectedText()
1277
1278 # Simulate a form feed by scrolling just past the last line.
1279 elif act.action == 'scroll' and act.unit == 'page':
1280 cursor.insertText('\n')
1281 cursor.endEditBlock()
1282 self._set_top_cursor(cursor)
1283 cursor.joinPreviousEditBlock()
1284 cursor.deletePreviousChar()
1285
1284 format = self._ansi_processor.get_format()
1286 format = self._ansi_processor.get_format()
1285 cursor.insertText(substring, format)
1287 cursor.insertText(substring, format)
1286 else:
1288 else:
@@ -1377,6 +1379,10 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
1377 """ Called immediately after a prompt is finished, i.e. when some input
1379 """ Called immediately after a prompt is finished, i.e. when some input
1378 will be processed and a new prompt displayed.
1380 will be processed and a new prompt displayed.
1379 """
1381 """
1382 # Flush all state from the input splitter so the next round of
1383 # reading input starts with a clean buffer.
1384 self._input_splitter.reset()
1385
1380 self._control.setReadOnly(True)
1386 self._control.setReadOnly(True)
1381 self._prompt_finished_hook()
1387 self._prompt_finished_hook()
1382
1388
@@ -1385,15 +1391,11 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
1385 """
1391 """
1386 # Temporarily disable the maximum block count to permit undo/redo and
1392 # Temporarily disable the maximum block count to permit undo/redo and
1387 # to ensure that the prompt position does not change due to truncation.
1393 # to ensure that the prompt position does not change due to truncation.
1388 # Because setting this property clears the undo/redo history, we only
1394 self._control.document().setMaximumBlockCount(0)
1389 # set it if we have to.
1390 if self._control.document().maximumBlockCount() > 0:
1391 self._control.document().setMaximumBlockCount(0)
1392 self._control.setUndoRedoEnabled(True)
1395 self._control.setUndoRedoEnabled(True)
1393
1396
1394 self._control.setReadOnly(False)
1397 self._control.setReadOnly(False)
1395 self._control.moveCursor(QtGui.QTextCursor.End)
1398 self._control.moveCursor(QtGui.QTextCursor.End)
1396
1397 self._executing = False
1399 self._executing = False
1398 self._prompt_started_hook()
1400 self._prompt_started_hook()
1399
1401
@@ -1460,6 +1462,16 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
1460 """
1462 """
1461 self._control.setTextCursor(cursor)
1463 self._control.setTextCursor(cursor)
1462
1464
1465 def _set_top_cursor(self, cursor):
1466 """ Scrolls the viewport so that the specified cursor is at the top.
1467 """
1468 scrollbar = self._control.verticalScrollBar()
1469 scrollbar.setValue(scrollbar.maximum())
1470 original_cursor = self._control.textCursor()
1471 self._control.setTextCursor(cursor)
1472 self._control.ensureCursorVisible()
1473 self._control.setTextCursor(original_cursor)
1474
1463 def _show_prompt(self, prompt=None, html=False, newline=True):
1475 def _show_prompt(self, prompt=None, html=False, newline=True):
1464 """ Writes a new prompt at the end of the buffer.
1476 """ Writes a new prompt at the end of the buffer.
1465
1477
@@ -12,7 +12,6 b' from PyQt4 import QtCore, QtGui'
12 # Local imports
12 # Local imports
13 from IPython.core.inputsplitter import InputSplitter, transform_classic_prompt
13 from IPython.core.inputsplitter import InputSplitter, transform_classic_prompt
14 from IPython.frontend.qt.base_frontend_mixin import BaseFrontendMixin
14 from IPython.frontend.qt.base_frontend_mixin import BaseFrontendMixin
15 from IPython.utils.io import raw_print
16 from IPython.utils.traitlets import Bool
15 from IPython.utils.traitlets import Bool
17 from bracket_matcher import BracketMatcher
16 from bracket_matcher import BracketMatcher
18 from call_tip_widget import CallTipWidget
17 from call_tip_widget import CallTipWidget
@@ -238,7 +237,6 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
238 """ Reimplemented for auto-indentation.
237 """ Reimplemented for auto-indentation.
239 """
238 """
240 super(FrontendWidget, self)._insert_continuation_prompt(cursor)
239 super(FrontendWidget, self)._insert_continuation_prompt(cursor)
241 #print('SPACES:', self._input_splitter.indent_spaces) # dbg
242 spaces = self._input_splitter.indent_spaces
240 spaces = self._input_splitter.indent_spaces
243 cursor.insertText('\t' * (spaces / self.tab_width))
241 cursor.insertText('\t' * (spaces / self.tab_width))
244 cursor.insertText(' ' * (spaces % self.tab_width))
242 cursor.insertText(' ' * (spaces % self.tab_width))
@@ -499,7 +497,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
499 for item in payload:
497 for item in payload:
500 if not self._process_execute_payload(item):
498 if not self._process_execute_payload(item):
501 warning = 'Warning: received unknown payload of type %s'
499 warning = 'Warning: received unknown payload of type %s'
502 raw_print(warning % repr(item['source']))
500 print(warning % repr(item['source']))
503
501
504 def _process_execute_payload(self, item):
502 def _process_execute_payload(self, item):
505 """ Process a single payload item from the list of payload items in an
503 """ Process a single payload item from the list of payload items in an
General Comments 0
You need to be logged in to leave comments. Login now