1#![allow(unused_variables, dead_code, unused_mut)]
2// todo!() this is to make transition easier.
3
4mod assets;
5pub mod languages;
6mod only_instance;
7mod open_listener;
8
9pub use assets::*;
10use gpui::{
11 point, px, AppContext, AsyncWindowContext, Task, TitlebarOptions, WeakView, WindowBounds,
12 WindowKind, WindowOptions,
13};
14pub use only_instance::*;
15pub use open_listener::*;
16
17use anyhow::Result;
18use std::sync::Arc;
19use uuid::Uuid;
20use workspace::{AppState, Workspace};
21
22pub fn build_window_options(
23 bounds: Option<WindowBounds>,
24 display_uuid: Option<Uuid>,
25 cx: &mut AppContext,
26) -> WindowOptions {
27 let bounds = bounds.unwrap_or(WindowBounds::Maximized);
28 let display = display_uuid.and_then(|uuid| {
29 cx.displays()
30 .into_iter()
31 .find(|display| display.uuid().ok() == Some(uuid))
32 });
33
34 WindowOptions {
35 bounds,
36 titlebar: Some(TitlebarOptions {
37 title: None,
38 appears_transparent: true,
39 traffic_light_position: Some(point(px(8.), px(8.))),
40 }),
41 center: false,
42 focus: false,
43 show: false,
44 kind: WindowKind::Normal,
45 is_movable: true,
46 display_id: display.map(|display| display.id()),
47 }
48}
49
50pub fn initialize_workspace(
51 workspace_handle: WeakView<Workspace>,
52 was_deserialized: bool,
53 app_state: Arc<AppState>,
54 cx: AsyncWindowContext,
55) -> Task<Result<()>> {
56 cx.spawn(|mut cx| async move {
57 workspace_handle.update(&mut cx, |workspace, cx| {
58 let workspace_handle = cx.view();
59 cx.subscribe(&workspace_handle, {
60 move |workspace, _, event, cx| {
61 if let workspace::Event::PaneAdded(pane) = event {
62 pane.update(cx, |pane, cx| {
63 pane.toolbar().update(cx, |toolbar, cx| {
64 // todo!()
65 // let breadcrumbs = cx.add_view(|_| Breadcrumbs::new(workspace));
66 // toolbar.add_item(breadcrumbs, cx);
67 // let buffer_search_bar = cx.add_view(BufferSearchBar::new);
68 // toolbar.add_item(buffer_search_bar.clone(), cx);
69 // let quick_action_bar = cx.add_view(|_| {
70 // QuickActionBar::new(buffer_search_bar, workspace)
71 // });
72 // toolbar.add_item(quick_action_bar, cx);
73 // let diagnostic_editor_controls =
74 // cx.add_view(|_| diagnostics2::ToolbarControls::new());
75 // toolbar.add_item(diagnostic_editor_controls, cx);
76 // let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
77 // toolbar.add_item(project_search_bar, cx);
78 // let submit_feedback_button =
79 // cx.add_view(|_| SubmitFeedbackButton::new());
80 // toolbar.add_item(submit_feedback_button, cx);
81 // let feedback_info_text = cx.add_view(|_| FeedbackInfoText::new());
82 // toolbar.add_item(feedback_info_text, cx);
83 // let lsp_log_item =
84 // cx.add_view(|_| language_tools::LspLogToolbarItemView::new());
85 // toolbar.add_item(lsp_log_item, cx);
86 // let syntax_tree_item = cx
87 // .add_view(|_| language_tools::SyntaxTreeToolbarItemView::new());
88 // toolbar.add_item(syntax_tree_item, cx);
89 })
90 });
91 }
92 }
93 })
94 .detach();
95
96 // cx.emit(workspace2::Event::PaneAdded(
97 // workspace.active_pane().clone(),
98 // ));
99
100 // let collab_titlebar_item =
101 // cx.add_view(|cx| CollabTitlebarItem::new(workspace, &workspace_handle, cx));
102 // workspace.set_titlebar_item(collab_titlebar_item.into_any(), cx);
103
104 // let copilot =
105 // cx.add_view(|cx| copilot_button::CopilotButton::new(app_state.fs.clone(), cx));
106 // let diagnostic_summary =
107 // cx.add_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace, cx));
108 // let activity_indicator = activity_indicator::ActivityIndicator::new(
109 // workspace,
110 // app_state.languages.clone(),
111 // cx,
112 // );
113 // let active_buffer_language =
114 // cx.add_view(|_| language_selector::ActiveBufferLanguage::new(workspace));
115 // let vim_mode_indicator = cx.add_view(|cx| vim::ModeIndicator::new(cx));
116 // let feedback_button = cx.add_view(|_| {
117 // feedback::deploy_feedback_button::DeployFeedbackButton::new(workspace)
118 // });
119 // let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
120 workspace.status_bar().update(cx, |status_bar, cx| {
121 // status_bar.add_left_item(diagnostic_summary, cx);
122 // status_bar.add_left_item(activity_indicator, cx);
123
124 // status_bar.add_right_item(feedback_button, cx);
125 // status_bar.add_right_item(copilot, cx);
126 // status_bar.add_right_item(active_buffer_language, cx);
127 // status_bar.add_right_item(vim_mode_indicator, cx);
128 // status_bar.add_right_item(cursor_position, cx);
129 });
130
131 // auto_update::notify_of_any_new_update(cx.weak_handle(), cx);
132
133 // vim::observe_keystrokes(cx);
134
135 // cx.on_window_should_close(|workspace, cx| {
136 // if let Some(task) = workspace.close(&Default::default(), cx) {
137 // task.detach_and_log_err(cx);
138 // }
139 // false
140 // });
141 // })?;
142
143 // let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
144 // let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
145 // let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
146 // let channels_panel =
147 // collab_ui::collab_panel::CollabPanel::load(workspace_handle.clone(), cx.clone());
148 // let chat_panel =
149 // collab_ui::chat_panel::ChatPanel::load(workspace_handle.clone(), cx.clone());
150 // let notification_panel = collab_ui::notification_panel::NotificationPanel::load(
151 // workspace_handle.clone(),
152 // cx.clone(),
153 // );
154 // let (
155 // project_panel,
156 // terminal_panel,
157 // assistant_panel,
158 // channels_panel,
159 // chat_panel,
160 // notification_panel,
161 // ) = futures::try_join!(
162 // project_panel,
163 // terminal_panel,
164 // assistant_panel,
165 // channels_panel,
166 // chat_panel,
167 // notification_panel,
168 // )?;
169 // workspace_handle.update(&mut cx, |workspace, cx| {
170 // let project_panel_position = project_panel.position(cx);
171 // workspace.add_panel_with_extra_event_handler(
172 // project_panel,
173 // cx,
174 // |workspace, _, event, cx| match event {
175 // project_panel::Event::NewSearchInDirectory { dir_entry } => {
176 // search::ProjectSearchView::new_search_in_directory(workspace, dir_entry, cx)
177 // }
178 // project_panel::Event::ActivatePanel => {
179 // workspace.focus_panel::<ProjectPanel>(cx);
180 // }
181 // _ => {}
182 // },
183 // );
184 // workspace.add_panel(terminal_panel, cx);
185 // workspace.add_panel(assistant_panel, cx);
186 // workspace.add_panel(channels_panel, cx);
187 // workspace.add_panel(chat_panel, cx);
188 // workspace.add_panel(notification_panel, cx);
189
190 // if !was_deserialized
191 // && workspace
192 // .project()
193 // .read(cx)
194 // .visible_worktrees(cx)
195 // .any(|tree| {
196 // tree.read(cx)
197 // .root_entry()
198 // .map_or(false, |entry| entry.is_dir())
199 // })
200 // {
201 // workspace.toggle_dock(project_panel_position, cx);
202 // }
203 // cx.focus_self();
204 })?;
205 Ok(())
206 })
207}