1use async_dispatcher::{set_dispatcher, Dispatcher, Runnable};
2use gpui::{AppContext, PlatformDispatcher};
3use project::Fs;
4use settings::Settings as _;
5use std::{sync::Arc, time::Duration};
6
7mod jupyter_settings;
8mod kernels;
9mod outputs;
10mod repl_store;
11mod runtime_panel;
12mod session;
13mod stdio;
14
15pub use jupyter_settings::JupyterSettings;
16pub use kernels::{Kernel, KernelSpecification, KernelStatus};
17pub use runtime_panel::{ClearOutputs, Interrupt, Run, Shutdown};
18pub use runtime_panel::{RuntimePanel, SessionSupport};
19pub use runtimelib::ExecutionState;
20pub use session::Session;
21
22use crate::repl_store::ReplStore;
23
24fn zed_dispatcher(cx: &mut AppContext) -> impl Dispatcher {
25 struct ZedDispatcher {
26 dispatcher: Arc<dyn PlatformDispatcher>,
27 }
28
29 // PlatformDispatcher is _super_ close to the same interface we put in
30 // async-dispatcher, except for the task label in dispatch. Later we should
31 // just make that consistent so we have this dispatcher ready to go for
32 // other crates in Zed.
33 impl Dispatcher for ZedDispatcher {
34 fn dispatch(&self, runnable: Runnable) {
35 self.dispatcher.dispatch(runnable, None)
36 }
37
38 fn dispatch_after(&self, duration: Duration, runnable: Runnable) {
39 self.dispatcher.dispatch_after(duration, runnable);
40 }
41 }
42
43 ZedDispatcher {
44 dispatcher: cx.background_executor().dispatcher.clone(),
45 }
46}
47
48pub fn init(fs: Arc<dyn Fs>, cx: &mut AppContext) {
49 set_dispatcher(zed_dispatcher(cx));
50 JupyterSettings::register(cx);
51 editor::init_settings(cx);
52 runtime_panel::init(cx);
53 ReplStore::init(fs, cx);
54}