Show More
@@ -1849,6 +1849,28 b' class InteractiveShell(Configurable, Magic):' | |||
|
1849 | 1849 | # code out there that may rely on this). |
|
1850 | 1850 | self.prefilter = self.prefilter_manager.prefilter_lines |
|
1851 | 1851 | |
|
1852 | ||
|
1853 | def auto_rewrite_input(self, cmd): | |
|
1854 | """Print to the screen the rewritten form of the user's command. | |
|
1855 | ||
|
1856 | This shows visual feedback for things like:: | |
|
1857 | ||
|
1858 | In [1]: /f x | |
|
1859 | ------> f(x) | |
|
1860 | ||
|
1861 | Which helps the user understand that the input line was transformed | |
|
1862 | automatically. | |
|
1863 | """ | |
|
1864 | rw = self.displayhook.prompt1.auto_rewrite() + cmd | |
|
1865 | ||
|
1866 | try: | |
|
1867 | # plain ascii works better w/ pyreadline, on some machines, so | |
|
1868 | # we use it and only print uncolored rewrite if we have unicode | |
|
1869 | rw = str(rw) | |
|
1870 | print >> IPython.utils.io.Term.cout, rw | |
|
1871 | except UnicodeEncodeError: | |
|
1872 | print "------> " + cmd | |
|
1873 | ||
|
1852 | 1874 | #------------------------------------------------------------------------- |
|
1853 | 1875 | # Things related to extracting values/expressions from kernel and user_ns |
|
1854 | 1876 | #------------------------------------------------------------------------- |
@@ -916,15 +916,7 b' class AutoHandler(PrefilterHandler):' | |||
|
916 | 916 | newcmd = '%s(%s)' % (ifun.rstrip(), the_rest) |
|
917 | 917 | |
|
918 | 918 | if auto_rewrite: |
|
919 |
|
|
|
920 | ||
|
921 | try: | |
|
922 | # plain ascii works better w/ pyreadline, on some machines, so | |
|
923 | # we use it and only print uncolored rewrite if we have unicode | |
|
924 | rw = str(rw) | |
|
925 | print >>IPython.utils.io.Term.cout, rw | |
|
926 | except UnicodeEncodeError: | |
|
927 | print "-------------->" + newcmd | |
|
919 | self.shell.auto_rewrite_input(newcmd) | |
|
928 | 920 | |
|
929 | 921 | # log what is now valid Python, not the actual user input (without the |
|
930 | 922 | # final newline) |
@@ -385,7 +385,7 b' class Prompt1(BasePrompt):' | |||
|
385 | 385 | return str_safe(self.p_str) |
|
386 | 386 | |
|
387 | 387 | def auto_rewrite(self): |
|
388 |
""" |
|
|
388 | """Return a string of the form '--->' which lines up with the previous | |
|
389 | 389 | input string. Useful for systems which re-write the user input when |
|
390 | 390 | handling automatically special syntaxes.""" |
|
391 | 391 |
@@ -377,7 +377,19 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
377 | 377 | def magic_pylab(self, *args, **kwargs): |
|
378 | 378 | raise NotImplementedError('pylab support must be enabled in commandl in options.') |
|
379 | 379 | |
|
380 | def auto_rewrite_input(self, cmd): | |
|
381 | """Called to show the auto-rewritten input for autocall and friends. | |
|
380 | 382 |
|
|
383 | FIXME: this payload is currently not correctly processed by the | |
|
384 | frontend. | |
|
385 | """ | |
|
386 | new = self.displayhook.prompt1.auto_rewrite() + cmd | |
|
387 | payload = dict( | |
|
388 | source='IPython.zmq.zmqshell.ZMQInteractiveShell.auto_rewrite_input', | |
|
389 | transformed_input=new, | |
|
390 | ) | |
|
391 | self.payload_manager.write_payload(payload) | |
|
392 | ||
|
381 | 393 | def ask_exit(self): |
|
382 | 394 | """Engage the exit actions.""" |
|
383 | 395 | payload = dict( |
General Comments 0
You need to be logged in to leave comments.
Login now