mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 10:29:35 +03:00
Start work on creating gpui2 version of project panel (#3299)
I'm gonna land what I have, even though some features aren't ported yet, since we're working on all of this code so actively. * [x] get the basic structure compiling * [x] get the panel laying out correctly * [ ] rename / new file editor * [ ] enable the tests * [ ] drag and drop * [ ] context menu
This commit is contained in:
commit
c7d80c7aac
31
Cargo.lock
generated
31
Cargo.lock
generated
@ -6608,6 +6608,36 @@ dependencies = [
|
|||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "project_panel2"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"client2",
|
||||||
|
"collections",
|
||||||
|
"context_menu",
|
||||||
|
"db2",
|
||||||
|
"editor2",
|
||||||
|
"futures 0.3.28",
|
||||||
|
"gpui2",
|
||||||
|
"language2",
|
||||||
|
"menu2",
|
||||||
|
"postage",
|
||||||
|
"pretty_assertions",
|
||||||
|
"project2",
|
||||||
|
"schemars",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"settings2",
|
||||||
|
"smallvec",
|
||||||
|
"theme2",
|
||||||
|
"ui2",
|
||||||
|
"unicase",
|
||||||
|
"util",
|
||||||
|
"workspace2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "project_symbols"
|
name = "project_symbols"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -11417,6 +11447,7 @@ dependencies = [
|
|||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
"postage",
|
"postage",
|
||||||
"project2",
|
"project2",
|
||||||
|
"project_panel2",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"regex",
|
"regex",
|
||||||
"rope2",
|
"rope2",
|
||||||
|
@ -80,6 +80,7 @@ members = [
|
|||||||
"crates/project",
|
"crates/project",
|
||||||
"crates/project2",
|
"crates/project2",
|
||||||
"crates/project_panel",
|
"crates/project_panel",
|
||||||
|
"crates/project_panel2",
|
||||||
"crates/project_symbols",
|
"crates/project_symbols",
|
||||||
"crates/recent_projects",
|
"crates/recent_projects",
|
||||||
"crates/rope",
|
"crates/rope",
|
||||||
|
@ -293,7 +293,16 @@ pub fn blue() -> Hsla {
|
|||||||
|
|
||||||
pub fn green() -> Hsla {
|
pub fn green() -> Hsla {
|
||||||
Hsla {
|
Hsla {
|
||||||
h: 0.3,
|
h: 0.33,
|
||||||
|
s: 1.,
|
||||||
|
l: 0.5,
|
||||||
|
a: 1.,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn yellow() -> Hsla {
|
||||||
|
Hsla {
|
||||||
|
h: 0.16,
|
||||||
s: 1.,
|
s: 1.,
|
||||||
l: 0.5,
|
l: 0.5,
|
||||||
a: 1.,
|
a: 1.,
|
||||||
|
41
crates/project_panel2/Cargo.toml
Normal file
41
crates/project_panel2/Cargo.toml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
[package]
|
||||||
|
name = "project_panel2"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/project_panel.rs"
|
||||||
|
doctest = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
context_menu = { path = "../context_menu" }
|
||||||
|
collections = { path = "../collections" }
|
||||||
|
db = { path = "../db2", package = "db2" }
|
||||||
|
editor = { path = "../editor2", package = "editor2" }
|
||||||
|
gpui = { path = "../gpui2", package = "gpui2" }
|
||||||
|
menu = { path = "../menu2", package = "menu2" }
|
||||||
|
project = { path = "../project2", package = "project2" }
|
||||||
|
settings = { path = "../settings2", package = "settings2" }
|
||||||
|
theme = { path = "../theme2", package = "theme2" }
|
||||||
|
ui = { path = "../ui2", package = "ui2" }
|
||||||
|
util = { path = "../util" }
|
||||||
|
workspace = { path = "../workspace2", package = "workspace2" }
|
||||||
|
anyhow.workspace = true
|
||||||
|
postage.workspace = true
|
||||||
|
futures.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
serde_derive.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
schemars.workspace = true
|
||||||
|
smallvec.workspace = true
|
||||||
|
pretty_assertions.workspace = true
|
||||||
|
unicase = "2.6"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
client = { path = "../client2", package = "client2", features = ["test-support"] }
|
||||||
|
language = { path = "../language2", package = "language2", features = ["test-support"] }
|
||||||
|
editor = { path = "../editor2", package = "editor2", features = ["test-support"] }
|
||||||
|
gpui = { path = "../gpui2", package = "gpui2", features = ["test-support"] }
|
||||||
|
workspace = { path = "../workspace2", package = "workspace2", features = ["test-support"] }
|
||||||
|
serde_json.workspace = true
|
96
crates/project_panel2/src/file_associations.rs
Normal file
96
crates/project_panel2/src/file_associations.rs
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
use std::{path::Path, str, sync::Arc};
|
||||||
|
|
||||||
|
use collections::HashMap;
|
||||||
|
|
||||||
|
use gpui::{AppContext, AssetSource};
|
||||||
|
use serde_derive::Deserialize;
|
||||||
|
use util::{maybe, paths::PathExt};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
struct TypeConfig {
|
||||||
|
icon: Arc<str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct FileAssociations {
|
||||||
|
suffixes: HashMap<String, String>,
|
||||||
|
types: HashMap<String, TypeConfig>,
|
||||||
|
}
|
||||||
|
|
||||||
|
const COLLAPSED_DIRECTORY_TYPE: &'static str = "collapsed_folder";
|
||||||
|
const EXPANDED_DIRECTORY_TYPE: &'static str = "expanded_folder";
|
||||||
|
const COLLAPSED_CHEVRON_TYPE: &'static str = "collapsed_chevron";
|
||||||
|
const EXPANDED_CHEVRON_TYPE: &'static str = "expanded_chevron";
|
||||||
|
pub const FILE_TYPES_ASSET: &'static str = "icons/file_icons/file_types.json";
|
||||||
|
|
||||||
|
pub fn init(assets: impl AssetSource, cx: &mut AppContext) {
|
||||||
|
cx.set_global(FileAssociations::new(assets))
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FileAssociations {
|
||||||
|
pub fn new(assets: impl AssetSource) -> Self {
|
||||||
|
assets
|
||||||
|
.load("icons/file_icons/file_types.json")
|
||||||
|
.and_then(|file| {
|
||||||
|
serde_json::from_str::<FileAssociations>(str::from_utf8(&file).unwrap())
|
||||||
|
.map_err(Into::into)
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|_| FileAssociations {
|
||||||
|
suffixes: HashMap::default(),
|
||||||
|
types: HashMap::default(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_icon(path: &Path, cx: &AppContext) -> Arc<str> {
|
||||||
|
maybe!({
|
||||||
|
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
||||||
|
|
||||||
|
// FIXME: Associate a type with the languages and have the file's langauge
|
||||||
|
// override these associations
|
||||||
|
maybe!({
|
||||||
|
let suffix = path.icon_suffix()?;
|
||||||
|
|
||||||
|
this.suffixes
|
||||||
|
.get(suffix)
|
||||||
|
.and_then(|type_str| this.types.get(type_str))
|
||||||
|
.map(|type_config| type_config.icon.clone())
|
||||||
|
})
|
||||||
|
.or_else(|| this.types.get("default").map(|config| config.icon.clone()))
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| Arc::from("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
|
||||||
|
maybe!({
|
||||||
|
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
||||||
|
|
||||||
|
let key = if expanded {
|
||||||
|
EXPANDED_DIRECTORY_TYPE
|
||||||
|
} else {
|
||||||
|
COLLAPSED_DIRECTORY_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
this.types
|
||||||
|
.get(key)
|
||||||
|
.map(|type_config| type_config.icon.clone())
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| Arc::from("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
|
||||||
|
maybe!({
|
||||||
|
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
||||||
|
|
||||||
|
let key = if expanded {
|
||||||
|
EXPANDED_CHEVRON_TYPE
|
||||||
|
} else {
|
||||||
|
COLLAPSED_CHEVRON_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
this.types
|
||||||
|
.get(key)
|
||||||
|
.map(|type_config| type_config.icon.clone())
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| Arc::from("".to_string()))
|
||||||
|
}
|
||||||
|
}
|
@ -8,10 +8,10 @@ use file_associations::FileAssociations;
|
|||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, px, svg, uniform_list, Action, AppContext, AssetSource, AsyncAppContext,
|
actions, div, px, rems, svg, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
|
||||||
AsyncWindowContext, ClipboardItem, Div, Element, Entity, EventEmitter, FocusEnabled,
|
ClipboardItem, Component, Div, EventEmitter, FocusHandle, FocusableKeyDispatch, Model,
|
||||||
FocusHandle, Model, ParentElement as _, Pixels, Point, PromptLevel, Render,
|
MouseButton, ParentElement as _, Pixels, Point, PromptLevel, Render, StatefulInteractive,
|
||||||
StatefulInteractive, StatefulInteractivity, Styled, Task, UniformListScrollHandle, View,
|
StatefulInteractivity, StatelessInteractive, Styled, Task, UniformListScrollHandle, View,
|
||||||
ViewContext, VisualContext as _, WeakView, WindowContext,
|
ViewContext, VisualContext as _, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use menu::{Confirm, SelectNext, SelectPrev};
|
use menu::{Confirm, SelectNext, SelectPrev};
|
||||||
@ -31,9 +31,9 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use theme::ActiveTheme as _;
|
use theme::ActiveTheme as _;
|
||||||
use ui::{h_stack, v_stack};
|
use ui::{h_stack, v_stack, Label};
|
||||||
use unicase::UniCase;
|
use unicase::UniCase;
|
||||||
use util::TryFutureExt;
|
use util::{maybe, TryFutureExt};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
dock::{DockPosition, PanelEvent},
|
dock::{DockPosition, PanelEvent},
|
||||||
Workspace,
|
Workspace,
|
||||||
@ -54,8 +54,8 @@ pub struct ProjectPanel {
|
|||||||
edit_state: Option<EditState>,
|
edit_state: Option<EditState>,
|
||||||
filename_editor: View<Editor>,
|
filename_editor: View<Editor>,
|
||||||
clipboard_entry: Option<ClipboardEntry>,
|
clipboard_entry: Option<ClipboardEntry>,
|
||||||
dragged_entry_destination: Option<Arc<Path>>,
|
_dragged_entry_destination: Option<Arc<Path>>,
|
||||||
workspace: WeakView<Workspace>,
|
_workspace: WeakView<Workspace>,
|
||||||
has_focus: bool,
|
has_focus: bool,
|
||||||
width: Option<f32>,
|
width: Option<f32>,
|
||||||
pending_serialization: Task<Option<()>>,
|
pending_serialization: Task<Option<()>>,
|
||||||
@ -131,31 +131,6 @@ pub fn init_settings(cx: &mut AppContext) {
|
|||||||
pub fn init(assets: impl AssetSource, cx: &mut AppContext) {
|
pub fn init(assets: impl AssetSource, cx: &mut AppContext) {
|
||||||
init_settings(cx);
|
init_settings(cx);
|
||||||
file_associations::init(assets, cx);
|
file_associations::init(assets, cx);
|
||||||
|
|
||||||
// cx.add_action(ProjectPanel::expand_selected_entry);
|
|
||||||
// cx.add_action(ProjectPanel::collapse_selected_entry);
|
|
||||||
// cx.add_action(ProjectPanel::collapse_all_entries);
|
|
||||||
// cx.add_action(ProjectPanel::select_prev);
|
|
||||||
// cx.add_action(ProjectPanel::select_next);
|
|
||||||
// cx.add_action(ProjectPanel::new_file);
|
|
||||||
// cx.add_action(ProjectPanel::new_directory);
|
|
||||||
// cx.add_action(ProjectPanel::rename);
|
|
||||||
// cx.add_async_action(ProjectPanel::delete);
|
|
||||||
// cx.add_async_action(ProjectPanel::confirm);
|
|
||||||
// cx.add_async_action(ProjectPanel::open_file);
|
|
||||||
// cx.add_action(ProjectPanel::cancel);
|
|
||||||
// cx.add_action(ProjectPanel::cut);
|
|
||||||
// cx.add_action(ProjectPanel::copy);
|
|
||||||
// cx.add_action(ProjectPanel::copy_path);
|
|
||||||
// cx.add_action(ProjectPanel::copy_relative_path);
|
|
||||||
// cx.add_action(ProjectPanel::reveal_in_finder);
|
|
||||||
// cx.add_action(ProjectPanel::open_in_terminal);
|
|
||||||
// cx.add_action(ProjectPanel::new_search_in_directory);
|
|
||||||
// cx.add_action(
|
|
||||||
// |this: &mut ProjectPanel, action: &Paste, cx: &mut ViewContext<ProjectPanel>| {
|
|
||||||
// this.paste(action, cx);
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -244,7 +219,6 @@ impl ProjectPanel {
|
|||||||
// })
|
// })
|
||||||
// .detach();
|
// .detach();
|
||||||
|
|
||||||
let view_id = cx.view().entity_id();
|
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
project: project.clone(),
|
project: project.clone(),
|
||||||
fs: workspace.app_state().fs.clone(),
|
fs: workspace.app_state().fs.clone(),
|
||||||
@ -258,8 +232,8 @@ impl ProjectPanel {
|
|||||||
filename_editor,
|
filename_editor,
|
||||||
clipboard_entry: None,
|
clipboard_entry: None,
|
||||||
// context_menu: cx.add_view(|cx| ContextMenu::new(view_id, cx)),
|
// context_menu: cx.add_view(|cx| ContextMenu::new(view_id, cx)),
|
||||||
dragged_entry_destination: None,
|
_dragged_entry_destination: None,
|
||||||
workspace: workspace.weak_handle(),
|
_workspace: workspace.weak_handle(),
|
||||||
has_focus: false,
|
has_focus: false,
|
||||||
width: None,
|
width: None,
|
||||||
pending_serialization: Task::ready(None),
|
pending_serialization: Task::ready(None),
|
||||||
@ -311,8 +285,8 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Event::SplitEntry { entry_id } => {
|
&Event::SplitEntry { entry_id } => {
|
||||||
// if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
|
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
|
||||||
// if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
|
if let Some(_entry) = worktree.read(cx).entry_for_id(entry_id) {
|
||||||
// workspace
|
// workspace
|
||||||
// .split_path(
|
// .split_path(
|
||||||
// ProjectPath {
|
// ProjectPath {
|
||||||
@ -322,8 +296,8 @@ impl ProjectPanel {
|
|||||||
// cx,
|
// cx,
|
||||||
// )
|
// )
|
||||||
// .detach_and_log_err(cx);
|
// .detach_and_log_err(cx);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -391,10 +365,11 @@ impl ProjectPanel {
|
|||||||
|
|
||||||
fn deploy_context_menu(
|
fn deploy_context_menu(
|
||||||
&mut self,
|
&mut self,
|
||||||
position: Point<Pixels>,
|
_position: Point<Pixels>,
|
||||||
entry_id: ProjectEntryId,
|
_entry_id: ProjectEntryId,
|
||||||
cx: &mut ViewContext<Self>,
|
_cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
|
todo!()
|
||||||
// let project = self.project.read(cx);
|
// let project = self.project.read(cx);
|
||||||
|
|
||||||
// let worktree_id = if let Some(id) = project.worktree_id_for_entry(entry_id, cx) {
|
// let worktree_id = if let Some(id) = project.worktree_id_for_entry(entry_id, cx) {
|
||||||
@ -579,22 +554,18 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(task) = self.confirm_edit(cx) {
|
if let Some(task) = self.confirm_edit(cx) {
|
||||||
return Some(task);
|
task.detach_and_log_err(cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
fn open_file(&mut self, _: &Open, cx: &mut ViewContext<Self>) {
|
||||||
}
|
|
||||||
|
|
||||||
fn open_file(&mut self, _: &Open, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
|
||||||
if let Some((_, entry)) = self.selected_entry(cx) {
|
if let Some((_, entry)) = self.selected_entry(cx) {
|
||||||
if entry.is_file() {
|
if entry.is_file() {
|
||||||
self.open_entry(entry.id, true, cx);
|
self.open_entry(entry.id, true, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn confirm_edit(&mut self, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
fn confirm_edit(&mut self, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
||||||
@ -800,17 +771,19 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete(&mut self, _: &Delete, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
fn delete(&mut self, _: &Delete, cx: &mut ViewContext<Self>) {
|
||||||
|
maybe!({
|
||||||
let Selection { entry_id, .. } = self.selection?;
|
let Selection { entry_id, .. } = self.selection?;
|
||||||
let path = self.project.read(cx).path_for_entry(entry_id, cx)?.path;
|
let path = self.project.read(cx).path_for_entry(entry_id, cx)?.path;
|
||||||
let file_name = path.file_name()?;
|
let file_name = path.file_name()?;
|
||||||
|
|
||||||
let mut answer = cx.prompt(
|
let answer = cx.prompt(
|
||||||
PromptLevel::Info,
|
PromptLevel::Info,
|
||||||
&format!("Delete {file_name:?}?"),
|
&format!("Delete {file_name:?}?"),
|
||||||
&["Delete", "Cancel"],
|
&["Delete", "Cancel"],
|
||||||
);
|
);
|
||||||
Some(cx.spawn(|this, mut cx| async move {
|
|
||||||
|
cx.spawn(|this, mut cx| async move {
|
||||||
if answer.await != Ok(0) {
|
if answer.await != Ok(0) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@ -820,7 +793,10 @@ impl ProjectPanel {
|
|||||||
.ok_or_else(|| anyhow!("no such entry"))
|
.ok_or_else(|| anyhow!("no such entry"))
|
||||||
})??
|
})??
|
||||||
.await
|
.await
|
||||||
}))
|
})
|
||||||
|
.detach_and_log_err(cx);
|
||||||
|
Some(())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_next(&mut self, _: &SelectNext, cx: &mut ViewContext<Self>) {
|
fn select_next(&mut self, _: &SelectNext, cx: &mut ViewContext<Self>) {
|
||||||
@ -897,8 +873,9 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paste(&mut self, _: &Paste, cx: &mut ViewContext<Self>) -> Option<()> {
|
fn paste(&mut self, _: &Paste, cx: &mut ViewContext<Self>) {
|
||||||
if let Some((worktree, entry)) = self.selected_entry(cx) {
|
maybe!({
|
||||||
|
let (worktree, entry) = self.selected_entry(cx)?;
|
||||||
let clipboard_entry = self.clipboard_entry?;
|
let clipboard_entry = self.clipboard_entry?;
|
||||||
if clipboard_entry.worktree_id() != worktree.id() {
|
if clipboard_entry.worktree_id() != worktree.id() {
|
||||||
return None;
|
return None;
|
||||||
@ -942,15 +919,16 @@ impl ProjectPanel {
|
|||||||
if let Some(task) = self.project.update(cx, |project, cx| {
|
if let Some(task) = self.project.update(cx, |project, cx| {
|
||||||
project.rename_entry(clipboard_entry.entry_id(), new_path, cx)
|
project.rename_entry(clipboard_entry.entry_id(), new_path, cx)
|
||||||
}) {
|
}) {
|
||||||
task.detach_and_log_err(cx)
|
task.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
} else if let Some(task) = self.project.update(cx, |project, cx| {
|
} else if let Some(task) = self.project.update(cx, |project, cx| {
|
||||||
project.copy_entry(clipboard_entry.entry_id(), new_path, cx)
|
project.copy_entry(clipboard_entry.entry_id(), new_path, cx)
|
||||||
}) {
|
}) {
|
||||||
task.detach_and_log_err(cx)
|
task.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None
|
Some(())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_path(&mut self, _: &CopyPath, cx: &mut ViewContext<Self>) {
|
fn copy_path(&mut self, _: &CopyPath, cx: &mut ViewContext<Self>) {
|
||||||
@ -977,7 +955,7 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_in_terminal(&mut self, _: &OpenInTerminal, cx: &mut ViewContext<Self>) {
|
fn open_in_terminal(&mut self, _: &OpenInTerminal, _cx: &mut ViewContext<Self>) {
|
||||||
todo!()
|
todo!()
|
||||||
// if let Some((worktree, entry)) = self.selected_entry(cx) {
|
// if let Some((worktree, entry)) = self.selected_entry(cx) {
|
||||||
// let window = cx.window();
|
// let window = cx.window();
|
||||||
@ -1012,36 +990,37 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_entry(
|
// todo!()
|
||||||
&mut self,
|
// fn move_entry(
|
||||||
entry_to_move: ProjectEntryId,
|
// &mut self,
|
||||||
destination: ProjectEntryId,
|
// entry_to_move: ProjectEntryId,
|
||||||
destination_is_file: bool,
|
// destination: ProjectEntryId,
|
||||||
cx: &mut ViewContext<Self>,
|
// destination_is_file: bool,
|
||||||
) {
|
// cx: &mut ViewContext<Self>,
|
||||||
let destination_worktree = self.project.update(cx, |project, cx| {
|
// ) {
|
||||||
let entry_path = project.path_for_entry(entry_to_move, cx)?;
|
// let destination_worktree = self.project.update(cx, |project, cx| {
|
||||||
let destination_entry_path = project.path_for_entry(destination, cx)?.path.clone();
|
// let entry_path = project.path_for_entry(entry_to_move, cx)?;
|
||||||
|
// let destination_entry_path = project.path_for_entry(destination, cx)?.path.clone();
|
||||||
|
|
||||||
let mut destination_path = destination_entry_path.as_ref();
|
// let mut destination_path = destination_entry_path.as_ref();
|
||||||
if destination_is_file {
|
// if destination_is_file {
|
||||||
destination_path = destination_path.parent()?;
|
// destination_path = destination_path.parent()?;
|
||||||
}
|
// }
|
||||||
|
|
||||||
let mut new_path = destination_path.to_path_buf();
|
// let mut new_path = destination_path.to_path_buf();
|
||||||
new_path.push(entry_path.path.file_name()?);
|
// new_path.push(entry_path.path.file_name()?);
|
||||||
if new_path != entry_path.path.as_ref() {
|
// if new_path != entry_path.path.as_ref() {
|
||||||
let task = project.rename_entry(entry_to_move, new_path, cx)?;
|
// let task = project.rename_entry(entry_to_move, new_path, cx)?;
|
||||||
cx.foreground_executor().spawn(task).detach_and_log_err(cx);
|
// cx.foreground_executor().spawn(task).detach_and_log_err(cx);
|
||||||
}
|
// }
|
||||||
|
|
||||||
Some(project.worktree_id_for_entry(destination, cx)?)
|
// Some(project.worktree_id_for_entry(destination, cx)?)
|
||||||
});
|
// });
|
||||||
|
|
||||||
if let Some(destination_worktree) = destination_worktree {
|
// if let Some(destination_worktree) = destination_worktree {
|
||||||
self.expand_entry(destination_worktree, destination, cx);
|
// self.expand_entry(destination_worktree, destination, cx);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn index_for_selection(&self, selection: Selection) -> Option<(usize, usize, usize)> {
|
fn index_for_selection(&self, selection: Selection) -> Option<(usize, usize, usize)> {
|
||||||
let mut entry_index = 0;
|
let mut entry_index = 0;
|
||||||
@ -1366,23 +1345,32 @@ impl ProjectPanel {
|
|||||||
.git_status
|
.git_status
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|status| match status {
|
.map(|status| match status {
|
||||||
GitFileStatus::Added => theme.styles.status.created,
|
GitFileStatus::Added => theme.status().created,
|
||||||
GitFileStatus::Modified => theme.styles.status.modified,
|
GitFileStatus::Modified => theme.status().modified,
|
||||||
GitFileStatus::Conflict => theme.styles.status.conflict,
|
GitFileStatus::Conflict => theme.status().conflict,
|
||||||
})
|
})
|
||||||
.unwrap_or(theme.styles.status.info);
|
.unwrap_or(theme.status().info);
|
||||||
|
|
||||||
h_stack()
|
h_stack()
|
||||||
.child(if let Some(icon) = &details.icon {
|
.child(if let Some(icon) = &details.icon {
|
||||||
div().child(svg().path(icon.to_string()))
|
div().child(
|
||||||
|
// todo!() Marshall: Can we use our `IconElement` component here?
|
||||||
|
svg()
|
||||||
|
.size(rems(0.9375))
|
||||||
|
.flex_none()
|
||||||
|
.path(icon.to_string())
|
||||||
|
.text_color(cx.theme().colors().icon),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
div()
|
div()
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
if let (Some(editor), true) = (editor, show_editor) {
|
if let (Some(editor), true) = (editor, show_editor) {
|
||||||
div().child(editor.clone())
|
div().w_full().child(editor.clone())
|
||||||
} else {
|
} else {
|
||||||
div().child(details.filename.clone())
|
div()
|
||||||
|
.text_color(filename_text_color)
|
||||||
|
.child(Label::new(details.filename.clone()))
|
||||||
}
|
}
|
||||||
.ml_1(),
|
.ml_1(),
|
||||||
)
|
)
|
||||||
@ -1390,11 +1378,10 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_entry(
|
fn render_entry(
|
||||||
|
&self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
details: EntryDetails,
|
details: EntryDetails,
|
||||||
editor: &View<Editor>,
|
|
||||||
// dragged_entry_destination: &mut Option<Arc<Path>>,
|
// dragged_entry_destination: &mut Option<Arc<Path>>,
|
||||||
// theme: &theme::ProjectPanel,
|
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Div<Self, StatefulInteractivity<Self>> {
|
) -> Div<Self, StatefulInteractivity<Self>> {
|
||||||
let kind = details.kind;
|
let kind = details.kind;
|
||||||
@ -1402,9 +1389,18 @@ impl ProjectPanel {
|
|||||||
const INDENT_SIZE: Pixels = px(16.0);
|
const INDENT_SIZE: Pixels = px(16.0);
|
||||||
let padding = INDENT_SIZE + details.depth as f32 * px(settings.indent_size);
|
let padding = INDENT_SIZE + details.depth as f32 * px(settings.indent_size);
|
||||||
let show_editor = details.is_editing && !details.is_processing;
|
let show_editor = details.is_editing && !details.is_processing;
|
||||||
|
let is_selected = self
|
||||||
|
.selection
|
||||||
|
.map_or(false, |selection| selection.entry_id == entry_id);
|
||||||
|
|
||||||
Self::render_entry_visual_element(&details, Some(editor), padding, cx)
|
Self::render_entry_visual_element(&details, Some(&self.filename_editor), padding, cx)
|
||||||
.id(entry_id.to_proto() as usize)
|
.id(entry_id.to_proto() as usize)
|
||||||
|
.w_full()
|
||||||
|
.cursor_pointer()
|
||||||
|
.when(is_selected, |this| {
|
||||||
|
this.bg(cx.theme().colors().element_selected)
|
||||||
|
})
|
||||||
|
.hover(|style| style.bg(cx.theme().colors().element_hover))
|
||||||
.on_click(move |this, event, cx| {
|
.on_click(move |this, event, cx| {
|
||||||
if !show_editor {
|
if !show_editor {
|
||||||
if kind.is_dir() {
|
if kind.is_dir() {
|
||||||
@ -1418,38 +1414,51 @@ impl ProjectPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// .on_down(MouseButton::Right, move |event, this, cx| {
|
.on_mouse_down(MouseButton::Right, move |this, event, cx| {
|
||||||
// this.deploy_context_menu(event.position, entry_id, cx);
|
this.deploy_context_menu(event.position, entry_id, cx);
|
||||||
// })
|
})
|
||||||
// .on_up(MouseButton::Left, move |_, this, cx| {
|
// .on_drop::<ProjectEntryId>(|this, event, cx| {
|
||||||
// if let Some((_, dragged_entry)) = cx
|
|
||||||
// .global::<DragAndDrop<Workspace>>()
|
|
||||||
// .currently_dragged::<ProjectEntryId>(cx.window())
|
|
||||||
// {
|
|
||||||
// this.move_entry(
|
// this.move_entry(
|
||||||
// *dragged_entry,
|
// *dragged_entry,
|
||||||
// entry_id,
|
// entry_id,
|
||||||
// matches!(details.kind, EntryKind::File(_)),
|
// matches!(details.kind, EntryKind::File(_)),
|
||||||
// cx,
|
// cx,
|
||||||
// );
|
// );
|
||||||
// }
|
|
||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ProjectPanel {
|
impl Render for ProjectPanel {
|
||||||
type Element = Div<Self, StatefulInteractivity<Self>, FocusEnabled<Self>>;
|
type Element = Div<Self, StatefulInteractivity<Self>, FocusableKeyDispatch<Self>>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
|
||||||
enum ProjectPanel {}
|
|
||||||
let theme = cx.theme();
|
|
||||||
let last_worktree_root_id = self.last_worktree_root_id;
|
|
||||||
|
|
||||||
|
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
||||||
let has_worktree = self.visible_entries.len() != 0;
|
let has_worktree = self.visible_entries.len() != 0;
|
||||||
|
|
||||||
if has_worktree {
|
if has_worktree {
|
||||||
div()
|
div()
|
||||||
.id("project-panel")
|
.id("project-panel")
|
||||||
|
.size_full()
|
||||||
|
.context("ProjectPanel")
|
||||||
|
.on_action(Self::select_next)
|
||||||
|
.on_action(Self::select_prev)
|
||||||
|
.on_action(Self::expand_selected_entry)
|
||||||
|
.on_action(Self::collapse_selected_entry)
|
||||||
|
.on_action(Self::collapse_all_entries)
|
||||||
|
.on_action(Self::new_file)
|
||||||
|
.on_action(Self::new_directory)
|
||||||
|
.on_action(Self::rename)
|
||||||
|
.on_action(Self::delete)
|
||||||
|
.on_action(Self::confirm)
|
||||||
|
.on_action(Self::open_file)
|
||||||
|
.on_action(Self::cancel)
|
||||||
|
.on_action(Self::cut)
|
||||||
|
.on_action(Self::copy)
|
||||||
|
.on_action(Self::copy_path)
|
||||||
|
.on_action(Self::copy_relative_path)
|
||||||
|
.on_action(Self::paste)
|
||||||
|
.on_action(Self::reveal_in_finder)
|
||||||
|
.on_action(Self::open_in_terminal)
|
||||||
|
.on_action(Self::new_search_in_directory)
|
||||||
.track_focus(&self.focus_handle)
|
.track_focus(&self.focus_handle)
|
||||||
.child(
|
.child(
|
||||||
uniform_list(
|
uniform_list(
|
||||||
@ -1461,17 +1470,12 @@ impl Render for ProjectPanel {
|
|||||||
|this: &mut Self, range, cx| {
|
|this: &mut Self, range, cx| {
|
||||||
let mut items = SmallVec::new();
|
let mut items = SmallVec::new();
|
||||||
this.for_each_visible_entry(range, cx, |id, details, cx| {
|
this.for_each_visible_entry(range, cx, |id, details, cx| {
|
||||||
items.push(Self::render_entry(
|
items.push(this.render_entry(id, details, cx));
|
||||||
id,
|
|
||||||
details,
|
|
||||||
&this.filename_editor,
|
|
||||||
// &mut dragged_entry_destination,
|
|
||||||
cx,
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
items
|
items
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.size_full()
|
||||||
.track_scroll(self.list.clone()),
|
.track_scroll(self.list.clone()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
45
crates/project_panel2/src/project_panel_settings.rs
Normal file
45
crates/project_panel2/src/project_panel_settings.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
use anyhow;
|
||||||
|
use schemars::JsonSchema;
|
||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use settings::Settings;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum ProjectPanelDockPosition {
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct ProjectPanelSettings {
|
||||||
|
pub default_width: f32,
|
||||||
|
pub dock: ProjectPanelDockPosition,
|
||||||
|
pub file_icons: bool,
|
||||||
|
pub folder_icons: bool,
|
||||||
|
pub git_status: bool,
|
||||||
|
pub indent_size: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
||||||
|
pub struct ProjectPanelSettingsContent {
|
||||||
|
pub default_width: Option<f32>,
|
||||||
|
pub dock: Option<ProjectPanelDockPosition>,
|
||||||
|
pub file_icons: Option<bool>,
|
||||||
|
pub folder_icons: Option<bool>,
|
||||||
|
pub git_status: Option<bool>,
|
||||||
|
pub indent_size: Option<f32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Settings for ProjectPanelSettings {
|
||||||
|
const KEY: Option<&'static str> = Some("project_panel");
|
||||||
|
|
||||||
|
type FileContent = ProjectPanelSettingsContent;
|
||||||
|
|
||||||
|
fn load(
|
||||||
|
default_value: &Self::FileContent,
|
||||||
|
user_values: &[&Self::FileContent],
|
||||||
|
_: &mut gpui::AppContext,
|
||||||
|
) -> anyhow::Result<Self> {
|
||||||
|
Self::load_via_json_merge(default_value, user_values)
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ use schemars::{
|
|||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use util::{asset_str, ResultExt};
|
use util::asset_str;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Default, Clone, JsonSchema)]
|
#[derive(Debug, Deserialize, Default, Clone, JsonSchema)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
@ -86,7 +86,9 @@ impl KeymapFile {
|
|||||||
"invalid binding value for keystroke {keystroke}, context {context:?}"
|
"invalid binding value for keystroke {keystroke}, context {context:?}"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.log_err()
|
// todo!()
|
||||||
|
.ok()
|
||||||
|
// .log_err()
|
||||||
.map(|action| KeyBinding::load(&keystroke, action, context.as_deref()))
|
.map(|action| KeyBinding::load(&keystroke, action, context.as_deref()))
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>>>()?;
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, Action, AnyView, AppContext, Div, Entity, EntityId, EventEmitter, ParentElement, Render,
|
div, Action, AnyView, AppContext, Div, Entity, EntityId, EventEmitter, FocusHandle,
|
||||||
Subscription, View, ViewContext, WeakView, WindowContext,
|
ParentElement, Render, Styled, Subscription, View, ViewContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -34,6 +34,7 @@ pub trait Panel: Render + EventEmitter<PanelEvent> {
|
|||||||
fn set_zoomed(&mut self, _zoomed: bool, _cx: &mut ViewContext<Self>) {}
|
fn set_zoomed(&mut self, _zoomed: bool, _cx: &mut ViewContext<Self>) {}
|
||||||
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
||||||
fn has_focus(&self, cx: &WindowContext) -> bool;
|
fn has_focus(&self, cx: &WindowContext) -> bool;
|
||||||
|
fn focus_handle(&self, cx: &WindowContext) -> FocusHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PanelHandle: Send + Sync {
|
pub trait PanelHandle: Send + Sync {
|
||||||
@ -51,6 +52,7 @@ pub trait PanelHandle: Send + Sync {
|
|||||||
fn icon_tooltip(&self, cx: &WindowContext) -> (String, Option<Box<dyn Action>>);
|
fn icon_tooltip(&self, cx: &WindowContext) -> (String, Option<Box<dyn Action>>);
|
||||||
fn icon_label(&self, cx: &WindowContext) -> Option<String>;
|
fn icon_label(&self, cx: &WindowContext) -> Option<String>;
|
||||||
fn has_focus(&self, cx: &WindowContext) -> bool;
|
fn has_focus(&self, cx: &WindowContext) -> bool;
|
||||||
|
fn focus_handle(&self, cx: &WindowContext) -> FocusHandle;
|
||||||
fn to_any(&self) -> AnyView;
|
fn to_any(&self) -> AnyView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +119,10 @@ where
|
|||||||
fn to_any(&self) -> AnyView {
|
fn to_any(&self) -> AnyView {
|
||||||
self.clone().into()
|
self.clone().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn focus_handle(&self, cx: &WindowContext) -> FocusHandle {
|
||||||
|
self.read(cx).focus_handle(cx).clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&dyn PanelHandle> for AnyView {
|
impl From<&dyn PanelHandle> for AnyView {
|
||||||
@ -422,7 +428,11 @@ impl Render for Dock {
|
|||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
todo!()
|
if let Some(entry) = self.visible_entry() {
|
||||||
|
div().size_full().child(entry.panel.to_any())
|
||||||
|
} else {
|
||||||
|
div()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,5 +738,9 @@ pub mod test {
|
|||||||
fn has_focus(&self, _cx: &WindowContext) -> bool {
|
fn has_focus(&self, _cx: &WindowContext) -> bool {
|
||||||
self.has_focus
|
self.has_focus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn focus_handle(&self, cx: &WindowContext) -> FocusHandle {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ use client2::{
|
|||||||
Client, TypedEnvelope, UserStore,
|
Client, TypedEnvelope, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{hash_map, HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
use dock::{Dock, DockPosition, PanelButtons};
|
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle as _};
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{mpsc, oneshot},
|
channel::{mpsc, oneshot},
|
||||||
future::try_join_all,
|
future::try_join_all,
|
||||||
@ -248,102 +248,6 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
// 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)
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
|
|
||||||
// cx.add_action(|workspace: &mut Workspace, _: &ToggleLeftDock, cx| {
|
|
||||||
// workspace.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();
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProjectItemBuilders =
|
type ProjectItemBuilders =
|
||||||
@ -942,108 +846,15 @@ impl Workspace {
|
|||||||
&self.right_dock
|
&self.right_dock
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn add_panel<T: Panel>(&mut self, panel: View<T>, cx: &mut ViewContext<Self>)
|
pub fn add_panel<T: Panel>(&mut self, panel: View<T>, cx: &mut ViewContext<Self>) {
|
||||||
// where
|
let dock = match panel.position(cx) {
|
||||||
// T::Event: std::fmt::Debug,
|
DockPosition::Left => &self.left_dock,
|
||||||
// {
|
DockPosition::Bottom => &self.bottom_dock,
|
||||||
// self.add_panel_with_extra_event_handler(panel, cx, |_, _, _, _| {})
|
DockPosition::Right => &self.right_dock,
|
||||||
// }
|
};
|
||||||
|
|
||||||
// pub fn add_panel_with_extra_event_handler<T: Panel, F>(
|
dock.update(cx, |dock, cx| dock.add_panel(panel, cx));
|
||||||
// &mut self,
|
}
|
||||||
// panel: View<T>,
|
|
||||||
// cx: &mut ViewContext<Self>,
|
|
||||||
// handler: F,
|
|
||||||
// ) where
|
|
||||||
// T::Event: std::fmt::Debug,
|
|
||||||
// F: Fn(&mut Self, &View<T>, &T::Event, &mut ViewContext<Self>) + 'static,
|
|
||||||
// {
|
|
||||||
// let dock = match panel.position(cx) {
|
|
||||||
// DockPosition::Left => &self.left_dock,
|
|
||||||
// DockPosition::Bottom => &self.bottom_dock,
|
|
||||||
// DockPosition::Right => &self.right_dock,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// self.subscriptions.push(cx.subscribe(&panel, {
|
|
||||||
// let mut dock = dock.clone();
|
|
||||||
// let mut prev_position = panel.position(cx);
|
|
||||||
// move |this, panel, event, cx| {
|
|
||||||
// if T::should_change_position_on_event(event) {
|
|
||||||
// THIS HAS BEEN MOVED TO NORMAL EVENT EMISSION
|
|
||||||
// See: Dock::add_panel
|
|
||||||
//
|
|
||||||
// let new_position = panel.read(cx).position(cx);
|
|
||||||
// let mut was_visible = false;
|
|
||||||
// dock.update(cx, |dock, cx| {
|
|
||||||
// prev_position = new_position;
|
|
||||||
|
|
||||||
// was_visible = dock.is_open()
|
|
||||||
// && dock
|
|
||||||
// .visible_panel()
|
|
||||||
// .map_or(false, |active_panel| active_panel.id() == panel.id());
|
|
||||||
// dock.remove_panel(&panel, cx);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if panel.is_zoomed(cx) {
|
|
||||||
// this.zoomed_position = Some(new_position);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// dock = match panel.read(cx).position(cx) {
|
|
||||||
// DockPosition::Left => &this.left_dock,
|
|
||||||
// DockPosition::Bottom => &this.bottom_dock,
|
|
||||||
// DockPosition::Right => &this.right_dock,
|
|
||||||
// }
|
|
||||||
// .clone();
|
|
||||||
// dock.update(cx, |dock, cx| {
|
|
||||||
// dock.add_panel(panel.clone(), cx);
|
|
||||||
// if was_visible {
|
|
||||||
// dock.set_open(true, cx);
|
|
||||||
// dock.activate_panel(dock.panels_len() - 1, cx);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } else if T::should_zoom_in_on_event(event) {
|
|
||||||
// THIS HAS BEEN MOVED TO NORMAL EVENT EMISSION
|
|
||||||
// See: Dock::add_panel
|
|
||||||
//
|
|
||||||
// dock.update(cx, |dock, cx| dock.set_panel_zoomed(&panel, true, cx));
|
|
||||||
// if !panel.has_focus(cx) {
|
|
||||||
// cx.focus(&panel);
|
|
||||||
// }
|
|
||||||
// this.zoomed = Some(panel.downgrade().into_any());
|
|
||||||
// this.zoomed_position = Some(panel.read(cx).position(cx));
|
|
||||||
// } else if T::should_zoom_out_on_event(event) {
|
|
||||||
// THIS HAS BEEN MOVED TO NORMAL EVENT EMISSION
|
|
||||||
// See: Dock::add_panel
|
|
||||||
//
|
|
||||||
// dock.update(cx, |dock, cx| dock.set_panel_zoomed(&panel, false, cx));
|
|
||||||
// if this.zoomed_position == Some(prev_position) {
|
|
||||||
// this.zoomed = None;
|
|
||||||
// this.zoomed_position = None;
|
|
||||||
// }
|
|
||||||
// cx.notify();
|
|
||||||
// } else if T::is_focus_event(event) {
|
|
||||||
// THIS HAS BEEN MOVED TO NORMAL EVENT EMISSION
|
|
||||||
// See: Dock::add_panel
|
|
||||||
//
|
|
||||||
// let position = panel.read(cx).position(cx);
|
|
||||||
// this.dismiss_zoomed_items_to_reveal(Some(position), cx);
|
|
||||||
// if panel.is_zoomed(cx) {
|
|
||||||
// this.zoomed = Some(panel.downgrade().into_any());
|
|
||||||
// this.zoomed_position = Some(position);
|
|
||||||
// } else {
|
|
||||||
// this.zoomed = None;
|
|
||||||
// this.zoomed_position = None;
|
|
||||||
// }
|
|
||||||
// this.update_active_view_for_followers(cx);
|
|
||||||
// cx.notify();
|
|
||||||
// } else {
|
|
||||||
// handler(this, &panel, event, cx)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }));
|
|
||||||
|
|
||||||
// dock.update(cx, |dock, cx| dock.add_panel(panel, cx));
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn status_bar(&self) -> &View<StatusBar> {
|
pub fn status_bar(&self) -> &View<StatusBar> {
|
||||||
&self.status_bar
|
&self.status_bar
|
||||||
@ -1735,42 +1546,43 @@ impl Workspace {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn toggle_dock(&mut self, dock_side: DockPosition, cx: &mut ViewContext<Self>) {
|
pub fn toggle_dock(&mut self, dock_side: DockPosition, cx: &mut ViewContext<Self>) {
|
||||||
// let dock = match dock_side {
|
let dock = match dock_side {
|
||||||
// DockPosition::Left => &self.left_dock,
|
DockPosition::Left => &self.left_dock,
|
||||||
// DockPosition::Bottom => &self.bottom_dock,
|
DockPosition::Bottom => &self.bottom_dock,
|
||||||
// DockPosition::Right => &self.right_dock,
|
DockPosition::Right => &self.right_dock,
|
||||||
// };
|
};
|
||||||
// let mut focus_center = false;
|
let mut focus_center = false;
|
||||||
// let mut reveal_dock = false;
|
let mut reveal_dock = false;
|
||||||
// dock.update(cx, |dock, cx| {
|
dock.update(cx, |dock, cx| {
|
||||||
// let other_is_zoomed = self.zoomed.is_some() && self.zoomed_position != Some(dock_side);
|
let other_is_zoomed = self.zoomed.is_some() && self.zoomed_position != Some(dock_side);
|
||||||
// let was_visible = dock.is_open() && !other_is_zoomed;
|
let was_visible = dock.is_open() && !other_is_zoomed;
|
||||||
// dock.set_open(!was_visible, cx);
|
dock.set_open(!was_visible, cx);
|
||||||
|
|
||||||
// if let Some(active_panel) = dock.active_panel() {
|
if let Some(active_panel) = dock.active_panel() {
|
||||||
// if was_visible {
|
if was_visible {
|
||||||
// if active_panel.has_focus(cx) {
|
if active_panel.has_focus(cx) {
|
||||||
// focus_center = true;
|
focus_center = true;
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// cx.focus(active_panel.as_any());
|
let focus_handle = &active_panel.focus_handle(cx);
|
||||||
// reveal_dock = true;
|
cx.focus(focus_handle);
|
||||||
// }
|
reveal_dock = true;
|
||||||
// }
|
}
|
||||||
// });
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// if reveal_dock {
|
if reveal_dock {
|
||||||
// self.dismiss_zoomed_items_to_reveal(Some(dock_side), cx);
|
self.dismiss_zoomed_items_to_reveal(Some(dock_side), cx);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if focus_center {
|
if focus_center {
|
||||||
// cx.focus_self();
|
cx.focus(&self.focus_handle);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// self.serialize_workspace(cx);
|
self.serialize_workspace(cx);
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn close_all_docks(&mut self, cx: &mut ViewContext<Self>) {
|
pub fn close_all_docks(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
let docks = [&self.left_dock, &self.bottom_dock, &self.right_dock];
|
let docks = [&self.left_dock, &self.bottom_dock, &self.right_dock];
|
||||||
@ -3467,6 +3279,107 @@ 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"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
|
pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
|
||||||
use gpui::Context;
|
use gpui::Context;
|
||||||
@ -3791,28 +3704,19 @@ impl Render for Workspace {
|
|||||||
.border_b()
|
.border_b()
|
||||||
.border_color(cx.theme().colors().border)
|
.border_color(cx.theme().colors().border)
|
||||||
.child(self.modal_layer.clone())
|
.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(
|
.child(
|
||||||
div().flex().flex_col().flex_1().h_full().child(
|
div()
|
||||||
div().flex().flex_1().child(self.center.render(
|
.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.project,
|
||||||
&self.follower_states,
|
&self.follower_states,
|
||||||
self.active_call(),
|
self.active_call(),
|
||||||
@ -3820,54 +3724,11 @@ impl Render for Workspace {
|
|||||||
self.zoomed.as_ref(),
|
self.zoomed.as_ref(),
|
||||||
&self.app_state,
|
&self.app_state,
|
||||||
cx,
|
cx,
|
||||||
)),
|
))
|
||||||
), // .children(
|
.child(div().flex().flex_1().child(self.bottom_dock.clone())),
|
||||||
// Some(
|
)
|
||||||
// Panel::new("terminal-panel", cx)
|
.child(div().flex().flex_1().child(self.right_dock.clone())),
|
||||||
// .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()),
|
|
||||||
// ),
|
|
||||||
)
|
)
|
||||||
.child(self.status_bar.clone())
|
.child(self.status_bar.clone())
|
||||||
// .when(self.debug.show_toast, |this| {
|
// .when(self.debug.show_toast, |this| {
|
||||||
|
@ -55,7 +55,7 @@ node_runtime = { path = "../node_runtime" }
|
|||||||
# outline = { path = "../outline" }
|
# outline = { path = "../outline" }
|
||||||
# plugin_runtime = { path = "../plugin_runtime",optional = true }
|
# plugin_runtime = { path = "../plugin_runtime",optional = true }
|
||||||
project = { package = "project2", path = "../project2" }
|
project = { package = "project2", path = "../project2" }
|
||||||
# project_panel = { path = "../project_panel" }
|
project_panel = { package = "project_panel2", path = "../project_panel2" }
|
||||||
# project_symbols = { path = "../project_symbols" }
|
# project_symbols = { path = "../project_symbols" }
|
||||||
# quick_action_bar = { path = "../quick_action_bar" }
|
# quick_action_bar = { path = "../quick_action_bar" }
|
||||||
# recent_projects = { path = "../recent_projects" }
|
# recent_projects = { path = "../recent_projects" }
|
||||||
|
@ -189,7 +189,7 @@ fn main() {
|
|||||||
// file_finder::init(cx);
|
// file_finder::init(cx);
|
||||||
// outline::init(cx);
|
// outline::init(cx);
|
||||||
// project_symbols::init(cx);
|
// project_symbols::init(cx);
|
||||||
// project_panel::init(Assets, cx);
|
project_panel::init(Assets, cx);
|
||||||
// channel::init(&client, user_store.clone(), cx);
|
// channel::init(&client, user_store.clone(), cx);
|
||||||
// diagnostics::init(cx);
|
// diagnostics::init(cx);
|
||||||
// search::init(cx);
|
// search::init(cx);
|
||||||
|
@ -15,9 +15,10 @@ pub use only_instance::*;
|
|||||||
pub use open_listener::*;
|
pub use open_listener::*;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use project_panel::ProjectPanel;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use workspace::{AppState, Workspace};
|
use workspace::{dock::PanelHandle as _, AppState, Workspace};
|
||||||
|
|
||||||
pub fn build_window_options(
|
pub fn build_window_options(
|
||||||
bounds: Option<WindowBounds>,
|
bounds: Option<WindowBounds>,
|
||||||
@ -138,9 +139,9 @@ pub fn initialize_workspace(
|
|||||||
// }
|
// }
|
||||||
// false
|
// false
|
||||||
// });
|
// });
|
||||||
// })?;
|
})?;
|
||||||
|
|
||||||
// let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
|
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
|
// let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
|
// let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let channels_panel =
|
// let channels_panel =
|
||||||
@ -151,36 +152,25 @@ pub fn initialize_workspace(
|
|||||||
// workspace_handle.clone(),
|
// workspace_handle.clone(),
|
||||||
// cx.clone(),
|
// cx.clone(),
|
||||||
// );
|
// );
|
||||||
// let (
|
let (
|
||||||
// project_panel,
|
project_panel,
|
||||||
// terminal_panel,
|
// terminal_panel,
|
||||||
// assistant_panel,
|
// assistant_panel,
|
||||||
// channels_panel,
|
// channels_panel,
|
||||||
// chat_panel,
|
// chat_panel,
|
||||||
// notification_panel,
|
// notification_panel,
|
||||||
// ) = futures::try_join!(
|
) = futures::try_join!(
|
||||||
// project_panel,
|
project_panel,
|
||||||
// terminal_panel,
|
// terminal_panel,
|
||||||
// assistant_panel,
|
// assistant_panel,
|
||||||
// channels_panel,
|
// channels_panel,
|
||||||
// chat_panel,
|
// chat_panel,
|
||||||
// notification_panel,
|
// notification_panel,
|
||||||
// )?;
|
)?;
|
||||||
// workspace_handle.update(&mut cx, |workspace, cx| {
|
|
||||||
// let project_panel_position = project_panel.position(cx);
|
workspace_handle.update(&mut cx, |workspace, cx| {
|
||||||
// workspace.add_panel_with_extra_event_handler(
|
let project_panel_position = project_panel.position(cx);
|
||||||
// project_panel,
|
workspace.add_panel(project_panel, cx);
|
||||||
// cx,
|
|
||||||
// |workspace, _, event, cx| match event {
|
|
||||||
// project_panel::Event::NewSearchInDirectory { dir_entry } => {
|
|
||||||
// search::ProjectSearchView::new_search_in_directory(workspace, dir_entry, cx)
|
|
||||||
// }
|
|
||||||
// project_panel::Event::ActivatePanel => {
|
|
||||||
// workspace.focus_panel::<ProjectPanel>(cx);
|
|
||||||
// }
|
|
||||||
// _ => {}
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// workspace.add_panel(terminal_panel, cx);
|
// workspace.add_panel(terminal_panel, cx);
|
||||||
// workspace.add_panel(assistant_panel, cx);
|
// workspace.add_panel(assistant_panel, cx);
|
||||||
// workspace.add_panel(channels_panel, cx);
|
// workspace.add_panel(channels_panel, cx);
|
||||||
@ -198,7 +188,7 @@ pub fn initialize_workspace(
|
|||||||
// .map_or(false, |entry| entry.is_dir())
|
// .map_or(false, |entry| entry.is_dir())
|
||||||
// })
|
// })
|
||||||
// {
|
// {
|
||||||
// workspace.toggle_dock(project_panel_position, cx);
|
workspace.toggle_dock(project_panel_position, cx);
|
||||||
// }
|
// }
|
||||||
// cx.focus_self();
|
// cx.focus_self();
|
||||||
})?;
|
})?;
|
||||||
|
Loading…
Reference in New Issue
Block a user