File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ def post_startup_configuration(ip):
1717 from . import ipyext
1818 ip .run_cell (dedent ("""
1919 %load_ext {ipyext}
20+ %gui julia
2021 """ .format (ipyext = ipyext .__name__ )))
2122
2223
Original file line number Diff line number Diff line change @@ -35,10 +35,31 @@ def _julia_completer(self, event):
3535 return julia_completer (get_cached_api (), self , event )
3636
3737
38+ def julia_inputhook (context ):
39+ """
40+ Hook to be run when IPython is idle.
41+
42+ This is passed to `prompt_toolkit.PromptSession` as `inputhook` argument
43+ via `IPython`.
44+
45+ Parameters
46+ ----------
47+ context : InputHookContext
48+ See: https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/prompt_toolkit/eventloop/inputhook.py
49+ """
50+ julia = get_cached_api ()
51+ jl_sleep = julia .sleep
52+ while not context .input_is_ready ():
53+ jl_sleep (0.05 )
54+
55+
3856def load_ipython_extension (ip ):
3957 global _unregister_key_bindings
4058 _unregister_key_bindings = register_key_bindings (ip )
4159
60+ from IPython .terminal .pt_inputhooks import register
61+ register ("julia" , julia_inputhook )
62+
4263 ip .set_hook ("complete_command" , _julia_completer ,
4364 re_key = r""".*\bMain\.eval\(["']""" )
4465# See:
You can’t perform that action at this time.
0 commit comments