1use gpui::{ModelHandle, ViewContext};
2use workspace::Workspace;
3
4use crate::{terminal_container_view::DeployModal, Event, Terminal};
5
6pub fn deploy_modal(_workspace: &mut Workspace, _: &DeployModal, _cx: &mut ViewContext<Workspace>) {
7 // let window = cx.window_id();
8
9 // // Pull the terminal connection out of the global if it has been stored
10 // let possible_terminal = Dock::remove::<Terminal, _>(window, cx);
11
12 // if let Some(terminal_handle) = possible_terminal {
13 // workspace.toggle_modal(cx, |_, cx| {
14 // // Create a view from the stored connection if the terminal modal is not already shown
15 // cx.add_view(|cx| TerminalContainer::from_terminal(terminal_handle.clone(), true, cx))
16 // });
17 // // Toggle Modal will dismiss the terminal modal if it is currently shown, so we must
18 // // store the terminal back in the global
19 // Dock::insert_or_replace::<Terminal, _>(window, terminal_handle, cx);
20 // } else {
21 // // No connection was stored, create a new terminal
22 // if let Some(closed_terminal_handle) = workspace.toggle_modal(cx, |workspace, cx| {
23 // // No terminal modal visible, construct a new one.
24 // let wd_strategy = cx
25 // .global::<Settings>()
26 // .terminal_overrides
27 // .working_directory
28 // .clone()
29 // .unwrap_or(WorkingDirectory::CurrentProjectDirectory);
30
31 // let working_directory = get_working_directory(workspace, cx, wd_strategy);
32
33 // let this = cx.add_view(|cx| TerminalContainer::new(working_directory, true, cx));
34
35 // if let TerminalContainerContent::Connected(connected) = &this.read(cx).content {
36 // let terminal_handle = connected.read(cx).handle();
37 // cx.subscribe(&terminal_handle, on_event).detach();
38 // // Set the global immediately if terminal construction was successful,
39 // // in case the user opens the command palette
40 // Dock::insert_or_replace::<Terminal, _>(window, terminal_handle, cx);
41 // }
42
43 // this
44 // }) {
45 // // Terminal modal was dismissed and the terminal view is connected, store the terminal
46 // if let TerminalContainerContent::Connected(connected) =
47 // &closed_terminal_handle.read(cx).content
48 // {
49 // let terminal_handle = connected.read(cx).handle();
50 // // Set the global immediately if terminal construction was successful,
51 // // in case the user opens the command palette
52 // Dock::insert_or_replace::<Terminal, _>(window, terminal_handle, cx);
53 // }
54 // }
55 // }
56}
57
58pub fn on_event(
59 _workspace: &mut Workspace,
60 _: ModelHandle<Terminal>,
61 _event: &Event,
62 _cx: &mut ViewContext<Workspace>,
63) {
64 // Dismiss the modal if the terminal quit
65 // if let Event::CloseTerminal = event {
66 // Dock::remove::<Terminal, _>(cx.window_id(), cx);
67
68 // if workspace.modal::<TerminalContainer>().is_some() {
69 // workspace.dismiss_modal(cx)
70 // }
71 // }
72}