Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WIP: Print autocall rewrite in Qt console.

Closes #1730.
  • Loading branch information...
commit 35b0a9a2229707c58e513219f0c27dfe85817e96 1 parent 83e0ea6
@bfroehle authored
View
19 IPython/frontend/qt/console/ipython_widget.py
@@ -106,6 +106,7 @@ class IPythonWidget(FrontendWidget):
_payload_source_exit = zmq_shell_source + '.ask_exit'
_payload_source_next_input = zmq_shell_source + '.set_next_input'
_payload_source_page = 'IPython.zmq.page.page'
+ _payload_source_rewrite = zmq_shell_source + '.auto_rewrite_input'
_retrying_history_request = False
#---------------------------------------------------------------------------
@@ -120,7 +121,9 @@ def __init__(self, *args, **kw):
self._payload_source_edit : self._handle_payload_edit,
self._payload_source_exit : self._handle_payload_exit,
self._payload_source_page : self._handle_payload_page,
- self._payload_source_next_input : self._handle_payload_next_input }
+ self._payload_source_next_input : self._handle_payload_next_input,
+ self._payload_source_rewrite : self._handle_payload_rewrite,
+ }
self._previous_prompt_obj = None
self._keep_kernel_on_exit = None
@@ -496,6 +499,15 @@ def _make_continuation_prompt(self, prompt):
body = ' ' * space_count + end_chars
return '<span class="in-prompt">%s</span>' % body
+ def _make_rewrite_prompt(self, prompt):
+ """ Given a plain text version of an In promt, retuns an HTML
+ auto rewrite prompt.
+ """
+ end_chars = '> '
+ dash_count = len(prompt.lstrip('\n')) - len(end_chars)
+ body = '-' * dash_count + end_chars
+ return '<span class="in-prompt">%s</span>' % body
+
def _make_out_prompt(self, number):
""" Given a prompt number, returns an HTML Out prompt.
"""
@@ -527,6 +539,11 @@ def _handle_payload_page(self, item):
else:
self._page(item['text'], html=False)
+ def _handle_payload_rewrite(self, item):
+ self._append_html(self._make_rewrite_prompt(self._prompt), True)
+ self._append_plain_text(item['cmd'], True)
+ self._append_plain_text('\n', True)
+
#------ Trait change handlers --------------------------------------------
def _style_sheet_changed(self):
View
7 IPython/zmq/zmqshell.py
@@ -142,13 +142,12 @@ def init_environment(self):
def auto_rewrite_input(self, cmd):
"""Called to show the auto-rewritten input for autocall and friends.
- FIXME: this payload is currently not correctly processed by the
- frontend.
+ FIXME: this payload is currently not correctly processed by all
+ frontends.
"""
- new = self.prompt_manager.render('rewrite') + cmd
payload = dict(
source='IPython.zmq.zmqshell.ZMQInteractiveShell.auto_rewrite_input',
- transformed_input=new,
+ cmd=cmd,
)
self.payload_manager.write_payload(payload)
Please sign in to comment.
Something went wrong with that request. Please try again.