fmt
This commit is contained in:
parent
685e8d7007
commit
0122cd61c5
6 changed files with 25 additions and 24 deletions
|
@ -220,15 +220,16 @@ impl TerminalPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn new_terminal(
|
||||||
fn new_terminal(workspace: &mut Workspace, _: &workspace::NewTerminal, cx: &mut ViewContext<Workspace>) {
|
workspace: &mut Workspace,
|
||||||
|
_: &workspace::NewTerminal,
|
||||||
|
cx: &mut ViewContext<Workspace>,
|
||||||
|
) {
|
||||||
let Some(this) = workspace.focus_panel::<Self>(cx) else {
|
let Some(this) = workspace.focus_panel::<Self>(cx) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| this.add_terminal(cx))
|
||||||
this.add_terminal(cx)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_terminal(&mut self, cx: &mut ViewContext<Self>) {
|
fn add_terminal(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ use workspace::{
|
||||||
notifications::NotifyResultExt,
|
notifications::NotifyResultExt,
|
||||||
pane, register_deserializable_item,
|
pane, register_deserializable_item,
|
||||||
searchable::{SearchEvent, SearchOptions, SearchableItem, SearchableItemHandle},
|
searchable::{SearchEvent, SearchOptions, SearchableItem, SearchableItemHandle},
|
||||||
Pane, ToolbarItemLocation, Workspace, WorkspaceId, NewCenterTerminal,
|
NewCenterTerminal, Pane, ToolbarItemLocation, Workspace, WorkspaceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use terminal::TerminalSettings;
|
pub use terminal::TerminalSettings;
|
||||||
|
|
|
@ -517,7 +517,8 @@ impl View for PanelButtons {
|
||||||
&*tooltip_action,
|
&*tooltip_action,
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
}).detach();
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,8 +2,8 @@ mod dragged_item_receiver;
|
||||||
|
|
||||||
use super::{ItemHandle, SplitDirection};
|
use super::{ItemHandle, SplitDirection};
|
||||||
use crate::{
|
use crate::{
|
||||||
item::WeakItemHandle, toolbar::Toolbar, AutosaveSetting, Item, NewFile, NewSearch,
|
item::WeakItemHandle, toolbar::Toolbar, AutosaveSetting, Item, NewCenterTerminal, NewFile,
|
||||||
ToggleZoom, Workspace, WorkspaceSettings, NewCenterTerminal,
|
NewSearch, ToggleZoom, Workspace, WorkspaceSettings,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use collections::{HashMap, HashSet, VecDeque};
|
use collections::{HashMap, HashSet, VecDeque};
|
||||||
|
|
|
@ -53,9 +53,10 @@ use std::{
|
||||||
cmp, env,
|
cmp, env,
|
||||||
future::Future,
|
future::Future,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
rc::Rc,
|
||||||
str,
|
str,
|
||||||
sync::{atomic::AtomicUsize, Arc},
|
sync::{atomic::AtomicUsize, Arc},
|
||||||
time::Duration, rc::Rc,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -1623,14 +1624,21 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focus_panel<T: Panel>(&mut self, cx: &mut ViewContext<Self>) -> Option<ViewHandle<T>> {
|
pub fn focus_panel<T: Panel>(&mut self, cx: &mut ViewContext<Self>) -> Option<ViewHandle<T>> {
|
||||||
self.show_or_hide_panel::<T>(cx, |_, _| true)?.as_any().clone().downcast()
|
self.show_or_hide_panel::<T>(cx, |_, _| true)?
|
||||||
|
.as_any()
|
||||||
|
.clone()
|
||||||
|
.downcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_panel_focus<T: Panel>(&mut self, cx: &mut ViewContext<Self>) {
|
pub fn toggle_panel_focus<T: Panel>(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
self.show_or_hide_panel::<T>(cx, |panel, cx| !panel.has_focus(cx));
|
self.show_or_hide_panel::<T>(cx, |panel, cx| !panel.has_focus(cx));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_or_hide_panel<T: Panel>(&mut self, cx: &mut ViewContext<Self>, show: impl Fn(&dyn PanelHandle, &mut ViewContext<Dock>) -> bool) -> Option<Rc<dyn PanelHandle>> {
|
fn show_or_hide_panel<T: Panel>(
|
||||||
|
&mut self,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
show: impl Fn(&dyn PanelHandle, &mut ViewContext<Dock>) -> bool,
|
||||||
|
) -> Option<Rc<dyn PanelHandle>> {
|
||||||
for (dock, position) in [
|
for (dock, position) in [
|
||||||
self.left_dock.clone(),
|
self.left_dock.clone(),
|
||||||
self.bottom_dock.clone(),
|
self.bottom_dock.clone(),
|
||||||
|
|
|
@ -89,18 +89,9 @@ pub fn menus() -> Vec<Menu<'static>> {
|
||||||
MenuItem::action("Zoom Out", super::DecreaseBufferFontSize),
|
MenuItem::action("Zoom Out", super::DecreaseBufferFontSize),
|
||||||
MenuItem::action("Reset Zoom", super::ResetBufferFontSize),
|
MenuItem::action("Reset Zoom", super::ResetBufferFontSize),
|
||||||
MenuItem::separator(),
|
MenuItem::separator(),
|
||||||
MenuItem::action(
|
MenuItem::action("Toggle Left Dock", workspace::ToggleLeftDock),
|
||||||
"Toggle Left Dock",
|
MenuItem::action("Toggle Right Dock", workspace::ToggleRightDock),
|
||||||
workspace::ToggleLeftDock,
|
MenuItem::action("Toggle Bottom Dock", workspace::ToggleBottomDock),
|
||||||
),
|
|
||||||
MenuItem::action(
|
|
||||||
"Toggle Right Dock",
|
|
||||||
workspace::ToggleRightDock,
|
|
||||||
),
|
|
||||||
MenuItem::action(
|
|
||||||
"Toggle Bottom Dock",
|
|
||||||
workspace::ToggleBottomDock,
|
|
||||||
),
|
|
||||||
MenuItem::submenu(Menu {
|
MenuItem::submenu(Menu {
|
||||||
name: "Editor Layout",
|
name: "Editor Layout",
|
||||||
items: vec![
|
items: vec![
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue