From 5fe10b7f563ae32e669df178c7e029772123268d 2006-06-15 19:45:50 From: vivainio Date: 2006-06-15 19:45:50 Subject: [PATCH] generate_output_prompt hook --- diff --git a/IPython/Prompts.py b/IPython/Prompts.py index 621a285..c033f65 100644 --- a/IPython/Prompts.py +++ b/IPython/Prompts.py @@ -2,7 +2,7 @@ """ Classes for handling input/output prompts. -$Id: Prompts.py 1303 2006-05-17 03:39:29Z fperez $""" +$Id: Prompts.py 1366 2006-06-15 19:45:50Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez @@ -379,6 +379,7 @@ class Prompt2(BasePrompt): self.col_p = Colors.out_prompt self.col_num = Colors.out_number + #----------------------------------------------------------------------------- class CachedOutput: """Class for printing output from calculations while keeping a cache of @@ -500,8 +501,9 @@ class CachedOutput: return # don't use print, puts an extra space cout_write(self.output_sep) + outprompt = self.shell.hooks.generate_output_prompt() if self.do_full_cache: - cout_write(str(self.prompt_out)) + cout_write(outprompt) if isinstance(arg,Macro): print 'Executing Macro...' @@ -583,3 +585,4 @@ class CachedOutput: self.user_ns.update({'_':None,'__':None, '___':None}) import gc gc.collect() # xxx needed? + diff --git a/IPython/hooks.py b/IPython/hooks.py index a4ad5df..f980c5e 100644 --- a/IPython/hooks.py +++ b/IPython/hooks.py @@ -32,7 +32,7 @@ ip.set_hook('editor', calljed) You can then enable the functionality by doing 'import myiphooks' somewhere in your configuration files or ipython command line. -$Id: hooks.py 1365 2006-06-15 19:11:26Z vivainio $""" +$Id: hooks.py 1366 2006-06-15 19:45:50Z vivainio $""" #***************************************************************************** # Copyright (C) 2005 Fernando Perez. @@ -55,7 +55,7 @@ from pprint import PrettyPrinter # but over time we'll move here all the public API for user-accessible things. __all__ = ['editor', 'fix_error_editor', 'result_display', 'input_prefilter', 'shutdown_hook', 'late_startup_hook', - 'generate_prompt' ] + 'generate_prompt', 'generate_output_prompt' ] pformat = PrettyPrinter().pformat @@ -203,4 +203,8 @@ def generate_prompt(self, is_continuation): return str(ip.IP.outputcache.prompt2) return str(ip.IP.outputcache.prompt1) - \ No newline at end of file +def generate_output_prompt(self): + ip = self.api + return str(ip.IP.outputcache.prompt_out) + + \ No newline at end of file diff --git a/doc/ChangeLog b/doc/ChangeLog index 8de0c00..2da0bac 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -4,6 +4,9 @@ used to create prompts dynamically, instead of the "old" way of assigning "magic" strings to prompt_in1 and prompt_in2. The old way still works (it's invoked by the default hook), of course. + + * Prompts.py: added generate_output_prompt hook for altering output + prompt * Release.py: Changed version string to 0.7.3.svn.