From f6da74beecb9658bea2975782a37b4005ab2958a 2008-02-26 19:08:17 From: Ville M. Vainio Date: 2008-02-26 19:08:17 Subject: [PATCH] add pre_prompt_hook; run just before displaying the prompt (safe place to display stuff asynchronously without messing up text entry) --- diff --git a/IPython/hooks.py b/IPython/hooks.py index 517e4b1..f80562d 100644 --- a/IPython/hooks.py +++ b/IPython/hooks.py @@ -56,7 +56,7 @@ from pprint import PrettyPrinter __all__ = ['editor', 'fix_error_editor', 'result_display', 'input_prefilter', 'shutdown_hook', 'late_startup_hook', 'generate_prompt', 'generate_output_prompt','shell_hook', - 'show_in_pager'] + 'show_in_pager','pre_prompt_hook'] pformat = PrettyPrinter().pformat @@ -227,8 +227,13 @@ def show_in_pager(self,s): # raising TryNext here will use the default paging functionality raise ipapi.TryNext -def pre_command_hook(self,cmd): - """" Executed before starting to execute a command """ +def pre_prompt_hook(self): + """ Run before displaying the next prompt + + Use this e.g. to display output from asynchronous operations (in order + to not mess up text entry) + """ + return None def post_command_hook(self,cmd): diff --git a/IPython/iplib.py b/IPython/iplib.py index 1df2fda..ef8db6b 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -1746,6 +1746,7 @@ want to merge them back into the new files.""" % locals() # exit_now is set by a call to %Exit or %Quit while not self.exit_now: + self.hooks.pre_prompt_hook() if more: try: prompt = self.hooks.generate_prompt(True)