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