Show More
@@ -1,15 +1,10 b'' | |||
|
1 | # Standard library imports | |
|
2 | from codeop import CommandCompiler | |
|
3 | from threading import Thread | |
|
4 | import time | |
|
5 | import types | |
|
6 | ||
|
7 | 1 |
|
|
8 | 2 | from pygments.lexers import PythonLexer |
|
9 | 3 | from PyQt4 import QtCore, QtGui |
|
10 | 4 | import zmq |
|
11 | 5 | |
|
12 | 6 | # Local imports |
|
7 | from IPython.core.blockbreaker import BlockBreaker | |
|
13 | 8 | from call_tip_widget import CallTipWidget |
|
14 | 9 | from completion_lexer import CompletionLexer |
|
15 | 10 | from console_widget import HistoryConsoleWidget |
@@ -60,8 +55,8 b' class FrontendWidget(HistoryConsoleWidget):' | |||
|
60 | 55 | def __init__(self, kernel_manager, parent=None): |
|
61 | 56 | super(FrontendWidget, self).__init__(parent) |
|
62 | 57 | |
|
58 | self._blockbreaker = BlockBreaker() | |
|
63 | 59 | self._call_tip_widget = CallTipWidget(self) |
|
64 | self._compile = CommandCompiler() | |
|
65 | 60 | self._completion_lexer = CompletionLexer(PythonLexer()) |
|
66 | 61 | self._hidden = True |
|
67 | 62 | self._highlighter = FrontendHighlighter(self) |
@@ -127,36 +122,15 b' class FrontendWidget(HistoryConsoleWidget):' | |||
|
127 | 122 | shown. Returns whether the source executed (i.e., returns True only |
|
128 | 123 | if no more input is necessary). |
|
129 | 124 | """ |
|
130 | # Use CommandCompiler to determine if more input is needed. | |
|
131 | try: | |
|
132 | code = self._compile(source, symbol='single') | |
|
133 | except (OverflowError, SyntaxError, ValueError): | |
|
134 | # Just let IPython deal with the syntax error. | |
|
135 | code = Exception | |
|
136 | ||
|
137 | # Only execute interactive multiline input if it ends with a blank line | |
|
138 | lines = source.splitlines() | |
|
139 | if interactive and len(lines) > 1 and lines[-1].strip() != '': | |
|
140 | code = None | |
|
141 | ||
|
142 | executed = code is not None | |
|
125 | self._blockbreaker.reset() | |
|
126 | self._blockbreaker.push(source) | |
|
127 | executed = self._blockbreaker.interactive_block_ready() | |
|
143 | 128 | if executed: |
|
144 | 129 | self.kernel_manager.xreq_channel.execute(source) |
|
145 | 130 | self._hidden = hidden |
|
146 | 131 | else: |
|
147 | space = 0 | |
|
148 | for char in lines[-1]: | |
|
149 | if char == '\t': | |
|
150 | space += 4 | |
|
151 | elif char == ' ': | |
|
152 | space += 1 | |
|
153 | else: | |
|
154 | break | |
|
155 | if source.endswith(':') or source.endswith(':\n'): | |
|
156 | space += 4 | |
|
157 | 132 | self._show_continuation_prompt() |
|
158 | self.appendPlainText(' ' * space) | |
|
159 | ||
|
133 | self.appendPlainText(' ' * self._blockbreaker.indent_spaces) | |
|
160 | 134 | return executed |
|
161 | 135 | |
|
162 | 136 | def execute_file(self, path, hidden=False): |
General Comments 0
You need to be logged in to leave comments.
Login now