Prevent splits in the terminal panel

This commit is contained in:
Antonio Scandurra 2023-05-09 12:29:16 +02:00
parent e6be35c9a5
commit 26fe7a81f3
2 changed files with 10 additions and 2 deletions

View file

@ -28,6 +28,7 @@ impl TerminalPanel {
workspace.app_state().background_actions, workspace.app_state().background_actions,
cx, cx,
); );
pane.set_can_split(false, cx);
pane.on_can_drop(move |drag_and_drop, cx| { pane.on_can_drop(move |drag_and_drop, cx| {
drag_and_drop drag_and_drop
.currently_dragged::<DraggedItem>(window_id) .currently_dragged::<DraggedItem>(window_id)

View file

@ -149,6 +149,7 @@ pub struct Pane {
workspace: WeakViewHandle<Workspace>, workspace: WeakViewHandle<Workspace>,
has_focus: bool, has_focus: bool,
can_drop: Rc<dyn Fn(&DragAndDrop<Workspace>, &WindowContext) -> bool>, can_drop: Rc<dyn Fn(&DragAndDrop<Workspace>, &WindowContext) -> bool>,
can_split: bool,
} }
pub struct ItemNavHistory { pub struct ItemNavHistory {
@ -255,6 +256,7 @@ impl Pane {
workspace, workspace,
has_focus: false, has_focus: false,
can_drop: Rc::new(|_, _| true), can_drop: Rc::new(|_, _| true),
can_split: true,
} }
} }
@ -282,6 +284,11 @@ impl Pane {
self.can_drop = Rc::new(can_drop); self.can_drop = Rc::new(can_drop);
} }
pub fn set_can_split(&mut self, can_split: bool, cx: &mut ViewContext<Self>) {
self.can_split = can_split;
cx.notify();
}
pub fn nav_history_for_item<T: Item>(&self, item: &ViewHandle<T>) -> ItemNavHistory { pub fn nav_history_for_item<T: Item>(&self, item: &ViewHandle<T>) -> ItemNavHistory {
ItemNavHistory { ItemNavHistory {
history: self.nav_history.clone(), history: self.nav_history.clone(),
@ -1563,8 +1570,8 @@ impl View for Pane {
self, self,
0, 0,
self.active_item_index + 1, self.active_item_index + 1,
false, !self.can_split,
Some(100.), if self.can_split { Some(100.) } else { None },
cx, cx,
{ {
let toolbar = self.toolbar.clone(); let toolbar = self.toolbar.clone();