mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 08:45:15 +02:00
Also call .shutdown() in ipython
This commit is contained in:
parent
b0495d028f
commit
bb63722fb1
@ -2,6 +2,7 @@
|
|||||||
from powerline.ipython import IpythonPowerline
|
from powerline.ipython import IpythonPowerline
|
||||||
|
|
||||||
from IPython.core.prompts import PromptManager
|
from IPython.core.prompts import PromptManager
|
||||||
|
from IPython.core.hooks import TryNext
|
||||||
|
|
||||||
|
|
||||||
class PowerlinePromptManager(PromptManager):
|
class PowerlinePromptManager(PromptManager):
|
||||||
@ -41,6 +42,12 @@ def load_ipython_extension(ip):
|
|||||||
ip.prompt_manager = PowerlinePromptManager(powerline=powerline,
|
ip.prompt_manager = PowerlinePromptManager(powerline=powerline,
|
||||||
shell=ip.prompt_manager.shell, config=ip.prompt_manager.config)
|
shell=ip.prompt_manager.shell, config=ip.prompt_manager.config)
|
||||||
|
|
||||||
|
def shutdown_hook():
|
||||||
|
powerline.renderer.shutdown()
|
||||||
|
raise TryNext()
|
||||||
|
|
||||||
|
ip.hooks.shutdown_hook.add(shutdown_hook)
|
||||||
|
|
||||||
|
|
||||||
def unload_ipython_extension(ip):
|
def unload_ipython_extension(ip):
|
||||||
ip.prompt_manager = old_prompt_manager
|
ip.prompt_manager = old_prompt_manager
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
from powerline.ipython import IpythonPowerline
|
from powerline.ipython import IpythonPowerline
|
||||||
from IPython.Prompts import BasePrompt
|
from IPython.Prompts import BasePrompt
|
||||||
from IPython.ipapi import get as get_ipython
|
from IPython.ipapi import get as get_ipython
|
||||||
|
from IPython.ipapi import TryNext
|
||||||
|
|
||||||
|
|
||||||
class PowerlinePrompt(BasePrompt):
|
class PowerlinePrompt(BasePrompt):
|
||||||
@ -38,4 +39,11 @@ def setup(prompt='1', **kwargs):
|
|||||||
old_prompt = getattr(ip.IP.outputcache, attr)
|
old_prompt = getattr(ip.IP.outputcache, attr)
|
||||||
setattr(ip.IP.outputcache, attr, PowerlinePrompt(powerline,
|
setattr(ip.IP.outputcache, attr, PowerlinePrompt(powerline,
|
||||||
old_prompt.cache, old_prompt.sep, '', old_prompt.pad_left))
|
old_prompt.cache, old_prompt.sep, '', old_prompt.pad_left))
|
||||||
|
raise TryNext()
|
||||||
|
|
||||||
|
def shutdown_hook():
|
||||||
|
powerline.renderer.shutdown()
|
||||||
|
raise TryNext()
|
||||||
|
|
||||||
ip.IP.hooks.late_startup_hook.add(late_startup_hook)
|
ip.IP.hooks.late_startup_hook.add(late_startup_hook)
|
||||||
|
ip.IP.hooks.shutdown_hook.add(shutdown_hook)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user