repl.rs

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