Show More
@@ -504,19 +504,22 b' class IPythonInputSplitter(InputSplitter):' | |||
|
504 | 504 | # List with lines of raw input accumulated so far. |
|
505 | 505 | _buffer_raw = None |
|
506 | 506 | |
|
507 | def __init__(self, input_mode=None): | |
|
507 | def __init__(self, input_mode=None, transforms=None): | |
|
508 | 508 | super(IPythonInputSplitter, self).__init__(input_mode) |
|
509 | 509 | self._buffer_raw = [] |
|
510 | 510 | self._validate = True |
|
511 | self.transforms = [leading_indent(), | |
|
512 | classic_prompt(), | |
|
513 | ipy_prompt(), | |
|
514 | cellmagic(), | |
|
515 |
|
|
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
|
511 | if transforms is not None: | |
|
512 | self.transforms = transforms | |
|
513 | else: | |
|
514 | self.transforms = [leading_indent(), | |
|
515 | classic_prompt(), | |
|
516 | ipy_prompt(), | |
|
517 | cellmagic(), | |
|
518 | help_end(), | |
|
519 | escaped_transformer(), | |
|
520 | assign_from_magic(), | |
|
521 | assign_from_system(), | |
|
522 | ] | |
|
520 | 523 | |
|
521 | 524 | def reset(self): |
|
522 | 525 | """Reset the input buffer and associated state.""" |
@@ -12,7 +12,8 b' from IPython.external import qt' | |||
|
12 | 12 | from IPython.external.qt import QtCore, QtGui |
|
13 | 13 | |
|
14 | 14 | # Local imports |
|
15 |
from IPython.core.inputsplitter import InputSplitter, |
|
|
15 | from IPython.core.inputsplitter import InputSplitter, IPythonInputSplitter | |
|
16 | from IPython.core.inputtransformer import classic_prompt | |
|
16 | 17 | from IPython.core.oinspect import call_tip |
|
17 | 18 | from IPython.frontend.qt.base_frontend_mixin import BaseFrontendMixin |
|
18 | 19 | from IPython.utils.traitlets import Bool, Instance, Unicode |
@@ -113,7 +114,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
113 | 114 | exit_requested = QtCore.Signal(object) |
|
114 | 115 | |
|
115 | 116 | # Protected class variables. |
|
116 |
_transform |
|
|
117 | _prompt_transformer = IPythonInputSplitter(transforms=[classic_prompt()]) | |
|
117 | 118 | _CallTipRequest = namedtuple('_CallTipRequest', ['id', 'pos']) |
|
118 | 119 | _CompletionRequest = namedtuple('_CompletionRequest', ['id', 'pos']) |
|
119 | 120 | _ExecutionRequest = namedtuple('_ExecutionRequest', ['id', 'kind']) |
@@ -186,8 +187,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
186 | 187 | elif self._control.hasFocus(): |
|
187 | 188 | text = self._control.textCursor().selection().toPlainText() |
|
188 | 189 | if text: |
|
189 | lines = map(self._transform_prompt, text.splitlines()) | |
|
190 | text = '\n'.join(lines) | |
|
190 | text = self._prompt_transformer.transform_cell(text) | |
|
191 | 191 | QtGui.QApplication.clipboard().setText(text) |
|
192 | 192 | else: |
|
193 | 193 | self.log.debug("frontend widget : unknown copy target") |
@@ -19,8 +19,8 b' from textwrap import dedent' | |||
|
19 | 19 | from IPython.external.qt import QtCore, QtGui |
|
20 | 20 | |
|
21 | 21 | # Local imports |
|
22 |
from IPython.core.inputsplitter import IPythonInputSplitter |
|
|
23 | transform_ipy_prompt | |
|
22 | from IPython.core.inputsplitter import IPythonInputSplitter | |
|
23 | from IPython.core.inputtransformer import ipy_prompt | |
|
24 | 24 | from IPython.utils.traitlets import Bool, Unicode |
|
25 | 25 | from frontend_widget import FrontendWidget |
|
26 | 26 | import styles |
@@ -98,7 +98,7 b' class IPythonWidget(FrontendWidget):' | |||
|
98 | 98 | |
|
99 | 99 | # FrontendWidget protected class variables. |
|
100 | 100 | _input_splitter_class = IPythonInputSplitter |
|
101 |
_transform |
|
|
101 | _prompt_transformer = IPythonInputSplitter(transforms=[ipy_prompt()]) | |
|
102 | 102 | |
|
103 | 103 | # IPythonWidget protected class variables. |
|
104 | 104 | _PromptBlock = namedtuple('_PromptBlock', ['block', 'length', 'number']) |
General Comments 0
You need to be logged in to leave comments.
Login now