Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge branch 'main' into project-panel2

Max Brunsfeld1968becf9424
diff --cc crates/workspace2/src/workspace2.rs
index 8c1c5d9a023,e4fc5d35c60..45c3a089084
--- a/crates/workspace2/src/workspace2.rs
+++ b/crates/workspace2/src/workspace2.rs
@@@ -3255,124 -3448,27 +3260,128 @@@ impl Workspace
})
}
+ fn actions(div: Div<Self>) -> Div<Self> {
+ div
+ // cx.add_async_action(Workspace::open);
+ // cx.add_async_action(Workspace::follow_next_collaborator);
+ // cx.add_async_action(Workspace::close);
+ // cx.add_async_action(Workspace::close_inactive_items_and_panes);
+ // cx.add_async_action(Workspace::close_all_items_and_panes);
+ // cx.add_global_action(Workspace::close_global);
+ // cx.add_global_action(restart);
+ // cx.add_async_action(Workspace::save_all);
+ // cx.add_action(Workspace::add_folder_to_project);
+ // cx.add_action(
+ // |workspace: &mut Workspace, _: &Unfollow, cx: &mut ViewContext<Workspace>| {
+ // let pane = workspace.active_pane().clone();
+ // workspace.unfollow(&pane, cx);
+ // },
+ // );
+ // cx.add_action(
+ // |workspace: &mut Workspace, action: &Save, cx: &mut ViewContext<Workspace>| {
+ // workspace
+ // .save_active_item(action.save_intent.unwrap_or(SaveIntent::Save), cx)
+ // .detach_and_log_err(cx);
+ // },
+ // );
+ // cx.add_action(
+ // |workspace: &mut Workspace, _: &SaveAs, cx: &mut ViewContext<Workspace>| {
+ // workspace
+ // .save_active_item(SaveIntent::SaveAs, cx)
+ // .detach_and_log_err(cx);
+ // },
+ // );
+ // cx.add_action(|workspace: &mut Workspace, _: &ActivatePreviousPane, cx| {
+ // workspace.activate_previous_pane(cx)
+ // });
+ // cx.add_action(|workspace: &mut Workspace, _: &ActivateNextPane, cx| {
+ // workspace.activate_next_pane(cx)
+ // });
+ // cx.add_action(
+ // |workspace: &mut Workspace, action: &ActivatePaneInDirection, cx| {
+ // workspace.activate_pane_in_direction(action.0, cx)
+ // },
+ // );
+ // cx.add_action(
+ // |workspace: &mut Workspace, action: &SwapPaneInDirection, cx| {
+ // workspace.swap_pane_in_direction(action.0, cx)
+ // },
+ // );
+ .on_action(|this, e: &ToggleLeftDock, cx| {
+ println!("TOGGLING DOCK");
+ this.toggle_dock(DockPosition::Left, cx);
+ })
+ // cx.add_action(|workspace: &mut Workspace, _: &ToggleRightDock, cx| {
+ // workspace.toggle_dock(DockPosition::Right, cx);
+ // });
+ // cx.add_action(|workspace: &mut Workspace, _: &ToggleBottomDock, cx| {
+ // workspace.toggle_dock(DockPosition::Bottom, cx);
+ // });
+ // cx.add_action(|workspace: &mut Workspace, _: &CloseAllDocks, cx| {
+ // workspace.close_all_docks(cx);
+ // });
+ // cx.add_action(Workspace::activate_pane_at_index);
+ // cx.add_action(|workspace: &mut Workspace, _: &ReopenClosedItem, cx| {
+ // workspace.reopen_closed_item(cx).detach();
+ // });
+ // cx.add_action(|workspace: &mut Workspace, _: &GoBack, cx| {
+ // workspace
+ // .go_back(workspace.active_pane().downgrade(), cx)
+ // .detach();
+ // });
+ // cx.add_action(|workspace: &mut Workspace, _: &GoForward, cx| {
+ // workspace
+ // .go_forward(workspace.active_pane().downgrade(), cx)
+ // .detach();
+ // });
+
+ // cx.add_action(|_: &mut Workspace, _: &install_cli::Install, cx| {
+ // cx.spawn(|workspace, mut cx| async move {
+ // let err = install_cli::install_cli(&cx)
+ // .await
+ // .context("Failed to create CLI symlink");
+
+ // workspace.update(&mut cx, |workspace, cx| {
+ // if matches!(err, Err(_)) {
+ // err.notify_err(workspace, cx);
+ // } else {
+ // workspace.show_notification(1, cx, |cx| {
+ // cx.build_view(|_| {
+ // MessageNotification::new("Successfully installed the `zed` binary")
+ // })
+ // });
+ // }
+ // })
+ // })
+ // .detach();
+ // });
+ }
+
+ // todo!()
+ // #[cfg(any(test, feature = "test-support"))]
+ // pub fn test_new(project: ModelHandle<Project>, cx: &mut ViewContext<Self>) -> Self {
+ // use node_runtime::FakeNodeRuntime;
+ #[cfg(any(test, feature = "test-support"))]
+ pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
+ use gpui::Context;
+ use node_runtime::FakeNodeRuntime;
- // let client = project.read(cx).client();
- // let user_store = project.read(cx).user_store();
-
- // let workspace_store = cx.add_model(|cx| WorkspaceStore::new(client.clone(), cx));
- // let app_state = Arc::new(AppState {
- // languages: project.read(cx).languages().clone(),
- // workspace_store,
- // client,
- // user_store,
- // fs: project.read(cx).fs().clone(),
- // build_window_options: |_, _, _| Default::default(),
- // initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
- // node_runtime: FakeNodeRuntime::new(),
- // });
- // Self::new(0, project, app_state, cx)
- // }
+ let client = project.read(cx).client();
+ let user_store = project.read(cx).user_store();
+
+ let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
+ let app_state = Arc::new(AppState {
+ languages: project.read(cx).languages().clone(),
+ workspace_store,
+ client,
+ user_store,
+ fs: project.read(cx).fs().clone(),
+ build_window_options: |_, _, _| Default::default(),
+ initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
+ node_runtime: FakeNodeRuntime::new(),
+ });
+ Self::new(0, project, app_state, cx)
+ }
// fn render_dock(&self, position: DockPosition, cx: &WindowContext) -> Option<AnyElement<Self>> {
// let dock = match position {
@@@ -3618,142 -3743,160 +3656,110 @@@ impl Render for Workspace
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
- div()
- .relative()
- .size_full()
- .flex()
- .flex_col()
- .font("Zed Sans")
- .gap_0()
- .justify_start()
- .items_start()
- .text_color(cx.theme().colors().text)
- .bg(cx.theme().colors().background)
- .child(self.render_titlebar(cx))
- .child(Workspace::actions(
- // todo! should this be a component a view?
- self.modal_layer
- .wrapper_element(cx)
- .relative()
- .flex_1()
- .w_full()
- .flex()
- .overflow_hidden()
- .border_t()
- .border_b()
- .border_color(cx.theme().colors().border)
- .child(
- div()
- .flex()
- .flex_row()
- .flex_1()
- .h_full()
- .child(div().flex().flex_1().child(self.left_dock.clone()))
- .child(
- div()
- .flex()
- .flex_col()
- .flex_1()
- .child(self.center.render(
- &self.project,
- &self.follower_states,
- self.active_call(),
- &self.active_pane,
- self.zoomed.as_ref(),
- &self.app_state,
- cx,
- ))
- .child(div().flex().flex_1().child(self.bottom_dock.clone())),
- )
- .child(div().flex().flex_1().child(self.right_dock.clone())),
- ), // .children(
- // Some(
- // Panel::new("chat-panel-outer", cx)
- // .side(PanelSide::Right)
- // .child(ChatPanel::new("chat-panel-inner").messages(vec![
- // ChatMessage::new(
- // "osiewicz".to_string(),
- // "is this thing on?".to_string(),
- // DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z")
- // .unwrap()
- // .naive_local(),
- // ),
- // ChatMessage::new(
- // "maxdeviant".to_string(),
- // "Reading you loud and clear!".to_string(),
- // DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z")
- // .unwrap()
- // .naive_local(),
- // ),
- // ])),
- // )
- // .filter(|_| self.is_chat_panel_open()),
- // )
- // .children(
- // Some(
- // Panel::new("notifications-panel-outer", cx)
- // .side(PanelSide::Right)
- // .child(NotificationsPanel::new("notifications-panel-inner")),
- // )
- // .filter(|_| self.is_notifications_panel_open()),
- // )
- // .children(
- // Some(
- // Panel::new("assistant-panel-outer", cx)
- // .child(AssistantPanel::new("assistant-panel-inner")),
- // )
- // .filter(|_| self.is_assistant_panel_open()),
- // ),
- ))
- .child(self.status_bar.clone())
- // .when(self.debug.show_toast, |this| {
- // this.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast")))
- // })
- // .children(
- // Some(
- // div()
- // .absolute()
- // .top(px(50.))
- // .left(px(640.))
- // .z_index(8)
- // .child(LanguageSelector::new("language-selector")),
- // )
- // .filter(|_| self.is_language_selector_open()),
- // )
- .z_index(8)
- // Debug
- .child(
- div()
- .flex()
- .flex_col()
- .z_index(9)
- .absolute()
- .top_20()
- .left_1_4()
- .w_40()
- .gap_2(), // .when(self.show_debug, |this| {
- // this.child(Button::<Workspace>::new("Toggle User Settings").on_click(
- // Arc::new(|workspace, cx| workspace.debug_toggle_user_settings(cx)),
- // ))
- // .child(
- // Button::<Workspace>::new("Toggle Toasts").on_click(Arc::new(
- // |workspace, cx| workspace.debug_toggle_toast(cx),
- // )),
- // )
- // .child(
- // Button::<Workspace>::new("Toggle Livestream").on_click(Arc::new(
- // |workspace, cx| workspace.debug_toggle_livestream(cx),
- // )),
- // )
- // })
- // .child(
- // Button::<Workspace>::new("Toggle Debug")
- // .on_click(Arc::new(|workspace, cx| workspace.toggle_debug(cx))),
- // ),
- )
+ let mut context = DispatchContext::default();
+ context.insert("Workspace");
+ cx.with_key_dispatch_context(context, |cx| {
+ div()
+ .relative()
+ .size_full()
+ .flex()
+ .flex_col()
+ .font("Zed Sans")
+ .gap_0()
+ .justify_start()
+ .items_start()
+ .text_color(cx.theme().colors().text)
+ .bg(cx.theme().colors().background)
+ .child(self.render_titlebar(cx))
+ .child(
+ // todo! should this be a component a view?
+ self.add_workspace_actions_listeners(div().id("workspace"))
+ .relative()
+ .flex_1()
+ .w_full()
+ .flex()
+ .overflow_hidden()
+ .border_t()
+ .border_b()
+ .border_color(cx.theme().colors().border)
+ .child(self.modal_layer.clone())
- // .children(
- // Some(
- // Panel::new("project-panel-outer", cx)
- // .side(PanelSide::Left)
- // .child(ProjectPanel::new("project-panel-inner")),
- // )
- // .filter(|_| self.is_project_panel_open()),
- // )
- // .children(
- // Some(
- // Panel::new("collab-panel-outer", cx)
- // .child(CollabPanel::new("collab-panel-inner"))
- // .side(PanelSide::Left),
- // )
- // .filter(|_| self.is_collab_panel_open()),
- // )
- // .child(NotificationToast::new(
- // "maxbrunsfeld has requested to add you as a contact.".into(),
- // ))
+ .child(
- div().flex().flex_col().flex_1().h_full().child(
- div().flex().flex_1().child(self.center.render(
- &self.project,
- &self.follower_states,
- self.active_call(),
- &self.active_pane,
- self.zoomed.as_ref(),
- &self.app_state,
- cx,
- )),
- ), // .children(
- // Some(
- // Panel::new("terminal-panel", cx)
- // .child(Terminal::new())
- // .allowed_sides(PanelAllowedSides::BottomOnly)
- // .side(PanelSide::Bottom),
- // )
- // .filter(|_| self.is_terminal_open()),
- // ),
- ), // .children(
- // Some(
- // Panel::new("chat-panel-outer", cx)
- // .side(PanelSide::Right)
- // .child(ChatPanel::new("chat-panel-inner").messages(vec![
- // ChatMessage::new(
- // "osiewicz".to_string(),
- // "is this thing on?".to_string(),
- // DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z")
- // .unwrap()
- // .naive_local(),
- // ),
- // ChatMessage::new(
- // "maxdeviant".to_string(),
- // "Reading you loud and clear!".to_string(),
- // DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z")
- // .unwrap()
- // .naive_local(),
- // ),
- // ])),
- // )
- // .filter(|_| self.is_chat_panel_open()),
- // )
- // .children(
- // Some(
- // Panel::new("notifications-panel-outer", cx)
- // .side(PanelSide::Right)
- // .child(NotificationsPanel::new("notifications-panel-inner")),
- // )
- // .filter(|_| self.is_notifications_panel_open()),
- // )
- // .children(
- // Some(
- // Panel::new("assistant-panel-outer", cx)
- // .child(AssistantPanel::new("assistant-panel-inner")),
- // )
- // .filter(|_| self.is_assistant_panel_open()),
- // ),
++ div()
++ .flex()
++ .flex_row()
++ .flex_1()
++ .h_full()
++ .child(div().flex().flex_1().child(self.left_dock.clone()))
++ .child(
++ div()
++ .flex()
++ .flex_col()
++ .flex_1()
++ .child(self.center.render(
++ &self.project,
++ &self.follower_states,
++ self.active_call(),
++ &self.active_pane,
++ self.zoomed.as_ref(),
++ &self.app_state,
++ cx,
++ ))
++ .child(
++ div().flex().flex_1().child(self.bottom_dock.clone()),
++ ),
++ )
++ .child(div().flex().flex_1().child(self.right_dock.clone())),
++ ),
+ )
+ .child(self.status_bar.clone())
+ // .when(self.debug.show_toast, |this| {
+ // this.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast")))
+ // })
+ // .children(
+ // Some(
+ // div()
+ // .absolute()
+ // .top(px(50.))
+ // .left(px(640.))
+ // .z_index(8)
+ // .child(LanguageSelector::new("language-selector")),
+ // )
+ // .filter(|_| self.is_language_selector_open()),
+ // )
+ .z_index(8)
+ // Debug
+ .child(
+ div()
+ .flex()
+ .flex_col()
+ .z_index(9)
+ .absolute()
+ .top_20()
+ .left_1_4()
+ .w_40()
+ .gap_2(), // .when(self.show_debug, |this| {
+ // this.child(Button::<Workspace>::new("Toggle User Settings").on_click(
+ // Arc::new(|workspace, cx| workspace.debug_toggle_user_settings(cx)),
+ // ))
+ // .child(
+ // Button::<Workspace>::new("Toggle Toasts").on_click(Arc::new(
+ // |workspace, cx| workspace.debug_toggle_toast(cx),
+ // )),
+ // )
+ // .child(
+ // Button::<Workspace>::new("Toggle Livestream").on_click(Arc::new(
+ // |workspace, cx| workspace.debug_toggle_livestream(cx),
+ // )),
+ // )
+ // })
+ // .child(
+ // Button::<Workspace>::new("Toggle Debug")
+ // .on_click(Arc::new(|workspace, cx| workspace.toggle_debug(cx))),
+ // ),
+ )
+ })
}
}
-
// todo!()
// impl Entity for Workspace {
// type Event = Event;