1use std::{ops::ControlFlow, path::PathBuf, sync::Arc};
2
3use crate::TerminalView;
4use collections::{HashMap, HashSet};
5use db::kvp::KEY_VALUE_STORE;
6use futures::future::join_all;
7use gpui::{
8 actions, Action, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths,
9 FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription,
10 Task, View, ViewContext, VisualContext, WeakView, WindowContext,
11};
12use itertools::Itertools;
13use project::{Fs, ProjectEntryId};
14use search::{buffer_search::DivRegistrar, BufferSearchBar};
15use serde::{Deserialize, Serialize};
16use settings::Settings;
17use task::{static_source::RevealStrategy, SpawnInTerminal, TaskId};
18use terminal::{
19 terminal_settings::{Shell, TerminalDockPosition, TerminalSettings},
20 SpawnTask,
21};
22use ui::{h_flex, ButtonCommon, Clickable, IconButton, IconSize, Selectable, Tooltip};
23use util::{ResultExt, TryFutureExt};
24use workspace::{
25 dock::{DockPosition, Panel, PanelEvent},
26 item::Item,
27 pane,
28 ui::IconName,
29 DraggedTab, NewTerminal, Pane, Workspace,
30};
31
32use anyhow::Result;
33
34const TERMINAL_PANEL_KEY: &str = "TerminalPanel";
35
36actions!(terminal_panel, [ToggleFocus]);
37
38pub fn init(cx: &mut AppContext) {
39 cx.observe_new_views(
40 |workspace: &mut Workspace, _: &mut ViewContext<Workspace>| {
41 workspace.register_action(TerminalPanel::new_terminal);
42 workspace.register_action(TerminalPanel::open_terminal);
43 workspace.register_action(|workspace, _: &ToggleFocus, cx| {
44 workspace.toggle_panel_focus::<TerminalPanel>(cx);
45 });
46 },
47 )
48 .detach();
49}
50
51pub struct TerminalPanel {
52 pane: View<Pane>,
53 fs: Arc<dyn Fs>,
54 workspace: WeakView<Workspace>,
55 width: Option<Pixels>,
56 height: Option<Pixels>,
57 pending_serialization: Task<Option<()>>,
58 pending_terminals_to_add: usize,
59 _subscriptions: Vec<Subscription>,
60 deferred_tasks: HashMap<TaskId, Task<()>>,
61}
62
63impl TerminalPanel {
64 fn new(workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
65 let terminal_panel = cx.view().downgrade();
66 let pane = cx.new_view(|cx| {
67 let mut pane = Pane::new(
68 workspace.weak_handle(),
69 workspace.project().clone(),
70 Default::default(),
71 None,
72 NewTerminal.boxed_clone(),
73 cx,
74 );
75 pane.set_can_split(false, cx);
76 pane.set_can_navigate(false, cx);
77 pane.display_nav_history_buttons(false);
78 pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
79 let terminal_panel = terminal_panel.clone();
80 h_flex()
81 .gap_2()
82 .child(
83 IconButton::new("plus", IconName::Plus)
84 .icon_size(IconSize::Small)
85 .on_click(move |_, cx| {
86 terminal_panel
87 .update(cx, |panel, cx| panel.add_terminal(None, None, cx))
88 .log_err();
89 })
90 .tooltip(|cx| Tooltip::text("New Terminal", cx)),
91 )
92 .child({
93 let zoomed = pane.is_zoomed();
94 IconButton::new("toggle_zoom", IconName::Maximize)
95 .icon_size(IconSize::Small)
96 .selected(zoomed)
97 .selected_icon(IconName::Minimize)
98 .on_click(cx.listener(|pane, _, cx| {
99 pane.toggle_zoom(&workspace::ToggleZoom, cx);
100 }))
101 .tooltip(move |cx| {
102 Tooltip::text(if zoomed { "Zoom Out" } else { "Zoom In" }, cx)
103 })
104 })
105 .into_any_element()
106 });
107
108 let workspace = workspace.weak_handle();
109 pane.set_custom_drop_handle(cx, move |pane, dropped_item, cx| {
110 if let Some(tab) = dropped_item.downcast_ref::<DraggedTab>() {
111 let item = if &tab.pane == cx.view() {
112 pane.item_for_index(tab.ix)
113 } else {
114 tab.pane.read(cx).item_for_index(tab.ix)
115 };
116 if let Some(item) = item {
117 if item.downcast::<TerminalView>().is_some() {
118 return ControlFlow::Continue(());
119 } else if let Some(project_path) = item.project_path(cx) {
120 if let Some(entry_path) = workspace
121 .update(cx, |workspace, cx| {
122 workspace
123 .project()
124 .read(cx)
125 .absolute_path(&project_path, cx)
126 })
127 .log_err()
128 .flatten()
129 {
130 add_paths_to_terminal(pane, &[entry_path], cx);
131 }
132 }
133 }
134 } else if let Some(&entry_id) = dropped_item.downcast_ref::<ProjectEntryId>() {
135 if let Some(entry_path) = workspace
136 .update(cx, |workspace, cx| {
137 let project = workspace.project().read(cx);
138 project
139 .path_for_entry(entry_id, cx)
140 .and_then(|project_path| project.absolute_path(&project_path, cx))
141 })
142 .log_err()
143 .flatten()
144 {
145 add_paths_to_terminal(pane, &[entry_path], cx);
146 }
147 } else if let Some(paths) = dropped_item.downcast_ref::<ExternalPaths>() {
148 add_paths_to_terminal(pane, paths.paths(), cx);
149 }
150
151 ControlFlow::Break(())
152 });
153 let buffer_search_bar = cx.new_view(search::BufferSearchBar::new);
154 pane.toolbar()
155 .update(cx, |toolbar, cx| toolbar.add_item(buffer_search_bar, cx));
156 pane
157 });
158 let subscriptions = vec![
159 cx.observe(&pane, |_, _, cx| cx.notify()),
160 cx.subscribe(&pane, Self::handle_pane_event),
161 ];
162 let this = Self {
163 pane,
164 fs: workspace.app_state().fs.clone(),
165 workspace: workspace.weak_handle(),
166 pending_serialization: Task::ready(None),
167 width: None,
168 height: None,
169 pending_terminals_to_add: 0,
170 deferred_tasks: HashMap::default(),
171 _subscriptions: subscriptions,
172 };
173 this
174 }
175
176 pub async fn load(
177 workspace: WeakView<Workspace>,
178 mut cx: AsyncWindowContext,
179 ) -> Result<View<Self>> {
180 let serialized_panel = cx
181 .background_executor()
182 .spawn(async move { KEY_VALUE_STORE.read_kvp(TERMINAL_PANEL_KEY) })
183 .await
184 .log_err()
185 .flatten()
186 .map(|panel| serde_json::from_str::<SerializedTerminalPanel>(&panel))
187 .transpose()
188 .log_err()
189 .flatten();
190
191 let (panel, pane, items) = workspace.update(&mut cx, |workspace, cx| {
192 let panel = cx.new_view(|cx| TerminalPanel::new(workspace, cx));
193 let items = if let Some(serialized_panel) = serialized_panel.as_ref() {
194 panel.update(cx, |panel, cx| {
195 cx.notify();
196 panel.height = serialized_panel.height.map(|h| h.round());
197 panel.width = serialized_panel.width.map(|w| w.round());
198 panel.pane.update(cx, |_, cx| {
199 serialized_panel
200 .items
201 .iter()
202 .map(|item_id| {
203 TerminalView::deserialize(
204 workspace.project().clone(),
205 workspace.weak_handle(),
206 workspace.database_id(),
207 *item_id,
208 cx,
209 )
210 })
211 .collect::<Vec<_>>()
212 })
213 })
214 } else {
215 Vec::new()
216 };
217 let pane = panel.read(cx).pane.clone();
218 (panel, pane, items)
219 })?;
220
221 if let Some(workspace) = workspace.upgrade() {
222 panel
223 .update(&mut cx, |panel, cx| {
224 panel._subscriptions.push(cx.subscribe(
225 &workspace,
226 |terminal_panel, _, e, cx| {
227 if let workspace::Event::SpawnTask(spawn_in_terminal) = e {
228 terminal_panel.spawn_task(spawn_in_terminal, cx);
229 };
230 },
231 ))
232 })
233 .ok();
234 }
235
236 let pane = pane.downgrade();
237 let items = futures::future::join_all(items).await;
238 pane.update(&mut cx, |pane, cx| {
239 let active_item_id = serialized_panel
240 .as_ref()
241 .and_then(|panel| panel.active_item_id);
242 let mut active_ix = None;
243 for item in items {
244 if let Some(item) = item.log_err() {
245 let item_id = item.entity_id().as_u64();
246 pane.add_item(Box::new(item), false, false, None, cx);
247 if Some(item_id) == active_item_id {
248 active_ix = Some(pane.items_len() - 1);
249 }
250 }
251 }
252
253 if let Some(active_ix) = active_ix {
254 pane.activate_item(active_ix, false, false, cx)
255 }
256 })?;
257
258 Ok(panel)
259 }
260
261 fn handle_pane_event(
262 &mut self,
263 _pane: View<Pane>,
264 event: &pane::Event,
265 cx: &mut ViewContext<Self>,
266 ) {
267 match event {
268 pane::Event::ActivateItem { .. } => self.serialize(cx),
269 pane::Event::RemoveItem { .. } => self.serialize(cx),
270 pane::Event::Remove => cx.emit(PanelEvent::Close),
271 pane::Event::ZoomIn => cx.emit(PanelEvent::ZoomIn),
272 pane::Event::ZoomOut => cx.emit(PanelEvent::ZoomOut),
273
274 pane::Event::AddItem { item } => {
275 if let Some(workspace) = self.workspace.upgrade() {
276 let pane = self.pane.clone();
277 workspace.update(cx, |workspace, cx| item.added_to_pane(workspace, pane, cx))
278 }
279 }
280
281 _ => {}
282 }
283 }
284
285 pub fn open_terminal(
286 workspace: &mut Workspace,
287 action: &workspace::OpenTerminal,
288 cx: &mut ViewContext<Workspace>,
289 ) {
290 let Some(this) = workspace.focus_panel::<Self>(cx) else {
291 return;
292 };
293
294 this.update(cx, |this, cx| {
295 this.add_terminal(Some(action.working_directory.clone()), None, cx)
296 })
297 }
298
299 pub fn spawn_task(&mut self, spawn_in_terminal: &SpawnInTerminal, cx: &mut ViewContext<Self>) {
300 let mut spawn_task = SpawnTask {
301 id: spawn_in_terminal.id.clone(),
302 label: spawn_in_terminal.label.clone(),
303 command: spawn_in_terminal.command.clone(),
304 args: spawn_in_terminal.args.clone(),
305 env: spawn_in_terminal.env.clone(),
306 reveal: spawn_in_terminal.reveal,
307 };
308 // Set up shell args unconditionally, as tasks are always spawned inside of a shell.
309 let Some((shell, mut user_args)) = (match TerminalSettings::get_global(cx).shell.clone() {
310 Shell::System => std::env::var("SHELL").ok().map(|shell| (shell, vec![])),
311 Shell::Program(shell) => Some((shell, vec![])),
312 Shell::WithArguments { program, args } => Some((program, args)),
313 }) else {
314 return;
315 };
316
317 let mut command = std::mem::take(&mut spawn_task.command);
318 let args = std::mem::take(&mut spawn_task.args);
319 for arg in args {
320 command.push(' ');
321 command.push_str(&arg);
322 }
323 spawn_task.command = shell;
324 user_args.extend(["-i".to_owned(), "-c".to_owned(), command]);
325 spawn_task.args = user_args;
326 let reveal = spawn_task.reveal;
327
328 let working_directory = spawn_in_terminal.cwd.clone();
329 let allow_concurrent_runs = spawn_in_terminal.allow_concurrent_runs;
330 let use_new_terminal = spawn_in_terminal.use_new_terminal;
331
332 if allow_concurrent_runs && use_new_terminal {
333 self.spawn_in_new_terminal(spawn_task, working_directory, cx);
334 return;
335 }
336
337 let terminals_for_task = self.terminals_for_task(&spawn_in_terminal.id, cx);
338 if terminals_for_task.is_empty() {
339 self.spawn_in_new_terminal(spawn_task, working_directory, cx);
340 return;
341 }
342 let (existing_item_index, existing_terminal) = terminals_for_task
343 .last()
344 .expect("covered no terminals case above")
345 .clone();
346 if allow_concurrent_runs {
347 debug_assert!(
348 !use_new_terminal,
349 "Should have handled 'allow_concurrent_runs && use_new_terminal' case above"
350 );
351 self.replace_terminal(
352 working_directory,
353 spawn_task,
354 existing_item_index,
355 existing_terminal,
356 cx,
357 );
358 } else {
359 self.deferred_tasks.insert(
360 spawn_in_terminal.id.clone(),
361 cx.spawn(|terminal_panel, mut cx| async move {
362 wait_for_terminals_tasks(terminals_for_task, &mut cx).await;
363 terminal_panel
364 .update(&mut cx, |terminal_panel, cx| {
365 if use_new_terminal {
366 terminal_panel.spawn_in_new_terminal(
367 spawn_task,
368 working_directory,
369 cx,
370 );
371 } else {
372 terminal_panel.replace_terminal(
373 working_directory,
374 spawn_task,
375 existing_item_index,
376 existing_terminal,
377 cx,
378 );
379 }
380 })
381 .ok();
382 }),
383 );
384
385 match reveal {
386 RevealStrategy::Always => {
387 self.activate_terminal_view(existing_item_index, cx);
388 let task_workspace = self.workspace.clone();
389 cx.spawn(|_, mut cx| async move {
390 task_workspace
391 .update(&mut cx, |workspace, cx| workspace.focus_panel::<Self>(cx))
392 .ok()
393 })
394 .detach();
395 }
396 RevealStrategy::Never => {}
397 }
398 }
399 }
400
401 fn spawn_in_new_terminal(
402 &mut self,
403 spawn_task: SpawnTask,
404 working_directory: Option<PathBuf>,
405 cx: &mut ViewContext<Self>,
406 ) {
407 let reveal = spawn_task.reveal;
408 self.add_terminal(working_directory, Some(spawn_task), cx);
409 match reveal {
410 RevealStrategy::Always => {
411 let task_workspace = self.workspace.clone();
412 cx.spawn(|_, mut cx| async move {
413 task_workspace
414 .update(&mut cx, |workspace, cx| workspace.focus_panel::<Self>(cx))
415 .ok()
416 })
417 .detach();
418 }
419 RevealStrategy::Never => {}
420 }
421 }
422
423 ///Create a new Terminal in the current working directory or the user's home directory
424 fn new_terminal(
425 workspace: &mut Workspace,
426 _: &workspace::NewTerminal,
427 cx: &mut ViewContext<Workspace>,
428 ) {
429 let Some(this) = workspace.focus_panel::<Self>(cx) else {
430 return;
431 };
432
433 this.update(cx, |this, cx| this.add_terminal(None, None, cx))
434 }
435
436 fn terminals_for_task(
437 &self,
438 id: &TaskId,
439 cx: &mut AppContext,
440 ) -> Vec<(usize, View<TerminalView>)> {
441 self.pane
442 .read(cx)
443 .items()
444 .enumerate()
445 .filter_map(|(index, item)| Some((index, item.act_as::<TerminalView>(cx)?)))
446 .filter_map(|(index, terminal_view)| {
447 let task_state = terminal_view.read(cx).terminal().read(cx).task()?;
448 if &task_state.id == id {
449 Some((index, terminal_view))
450 } else {
451 None
452 }
453 })
454 .collect()
455 }
456
457 fn activate_terminal_view(&self, item_index: usize, cx: &mut WindowContext) {
458 self.pane.update(cx, |pane, cx| {
459 pane.activate_item(item_index, true, true, cx)
460 })
461 }
462
463 fn add_terminal(
464 &mut self,
465 working_directory: Option<PathBuf>,
466 spawn_task: Option<SpawnTask>,
467 cx: &mut ViewContext<Self>,
468 ) {
469 let workspace = self.workspace.clone();
470 self.pending_terminals_to_add += 1;
471 cx.spawn(|terminal_panel, mut cx| async move {
472 let pane = terminal_panel.update(&mut cx, |this, _| this.pane.clone())?;
473 workspace.update(&mut cx, |workspace, cx| {
474 let working_directory = if let Some(working_directory) = working_directory {
475 Some(working_directory)
476 } else {
477 let working_directory_strategy =
478 TerminalSettings::get_global(cx).working_directory.clone();
479 crate::get_working_directory(workspace, cx, working_directory_strategy)
480 };
481
482 let window = cx.window_handle();
483 if let Some(terminal) = workspace.project().update(cx, |project, cx| {
484 project
485 .create_terminal(working_directory, spawn_task, window, cx)
486 .log_err()
487 }) {
488 let terminal = Box::new(cx.new_view(|cx| {
489 TerminalView::new(
490 terminal,
491 workspace.weak_handle(),
492 workspace.database_id(),
493 cx,
494 )
495 }));
496 pane.update(cx, |pane, cx| {
497 let focus = pane.has_focus(cx);
498 pane.add_item(terminal, true, focus, None, cx);
499 });
500 }
501 })?;
502 terminal_panel.update(&mut cx, |this, cx| {
503 this.pending_terminals_to_add = this.pending_terminals_to_add.saturating_sub(1);
504 this.serialize(cx)
505 })?;
506 anyhow::Ok(())
507 })
508 .detach_and_log_err(cx);
509 }
510
511 fn serialize(&mut self, cx: &mut ViewContext<Self>) {
512 let mut items_to_serialize = HashSet::default();
513 let items = self
514 .pane
515 .read(cx)
516 .items()
517 .filter_map(|item| {
518 let terminal_view = item.act_as::<TerminalView>(cx)?;
519 if terminal_view.read(cx).terminal().read(cx).task().is_some() {
520 None
521 } else {
522 let id = item.item_id().as_u64();
523 items_to_serialize.insert(id);
524 Some(id)
525 }
526 })
527 .collect::<Vec<_>>();
528 let active_item_id = self
529 .pane
530 .read(cx)
531 .active_item()
532 .map(|item| item.item_id().as_u64())
533 .filter(|active_id| items_to_serialize.contains(active_id));
534 let height = self.height;
535 let width = self.width;
536 self.pending_serialization = cx.background_executor().spawn(
537 async move {
538 KEY_VALUE_STORE
539 .write_kvp(
540 TERMINAL_PANEL_KEY.into(),
541 serde_json::to_string(&SerializedTerminalPanel {
542 items,
543 active_item_id,
544 height,
545 width,
546 })?,
547 )
548 .await?;
549 anyhow::Ok(())
550 }
551 .log_err(),
552 );
553 }
554
555 fn replace_terminal(
556 &self,
557 working_directory: Option<PathBuf>,
558 spawn_task: SpawnTask,
559 terminal_item_index: usize,
560 terminal_to_replace: View<TerminalView>,
561 cx: &mut ViewContext<'_, Self>,
562 ) -> Option<()> {
563 let project = self
564 .workspace
565 .update(cx, |workspace, _| workspace.project().clone())
566 .ok()?;
567 let reveal = spawn_task.reveal;
568 let window = cx.window_handle();
569 let new_terminal = project.update(cx, |project, cx| {
570 project
571 .create_terminal(working_directory, Some(spawn_task), window, cx)
572 .log_err()
573 })?;
574 terminal_to_replace.update(cx, |terminal_to_replace, cx| {
575 terminal_to_replace.set_terminal(new_terminal, cx);
576 });
577
578 match reveal {
579 RevealStrategy::Always => {
580 self.activate_terminal_view(terminal_item_index, cx);
581 let task_workspace = self.workspace.clone();
582 cx.spawn(|_, mut cx| async move {
583 task_workspace
584 .update(&mut cx, |workspace, cx| workspace.focus_panel::<Self>(cx))
585 .ok()
586 })
587 .detach();
588 }
589 RevealStrategy::Never => {}
590 }
591
592 Some(())
593 }
594}
595
596async fn wait_for_terminals_tasks(
597 terminals_for_task: Vec<(usize, View<TerminalView>)>,
598 cx: &mut AsyncWindowContext,
599) {
600 let pending_tasks = terminals_for_task.iter().filter_map(|(_, terminal)| {
601 terminal
602 .update(cx, |terminal_view, cx| {
603 terminal_view
604 .terminal()
605 .update(cx, |terminal, cx| terminal.wait_for_completed_task(cx))
606 })
607 .ok()
608 });
609 let _: Vec<()> = join_all(pending_tasks).await;
610}
611
612fn add_paths_to_terminal(pane: &mut Pane, paths: &[PathBuf], cx: &mut ViewContext<'_, Pane>) {
613 if let Some(terminal_view) = pane
614 .active_item()
615 .and_then(|item| item.downcast::<TerminalView>())
616 {
617 cx.focus_view(&terminal_view);
618 let mut new_text = paths.iter().map(|path| format!(" {path:?}")).join("");
619 new_text.push(' ');
620 terminal_view.update(cx, |terminal_view, cx| {
621 terminal_view.terminal().update(cx, |terminal, _| {
622 terminal.paste(&new_text);
623 });
624 });
625 }
626}
627
628impl EventEmitter<PanelEvent> for TerminalPanel {}
629
630impl Render for TerminalPanel {
631 fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
632 let mut registrar = DivRegistrar::new(
633 |panel, cx| {
634 panel
635 .pane
636 .read(cx)
637 .toolbar()
638 .read(cx)
639 .item_of_type::<BufferSearchBar>()
640 },
641 cx,
642 );
643 BufferSearchBar::register(&mut registrar);
644 registrar.into_div().size_full().child(self.pane.clone())
645 }
646}
647
648impl FocusableView for TerminalPanel {
649 fn focus_handle(&self, cx: &AppContext) -> FocusHandle {
650 self.pane.focus_handle(cx)
651 }
652}
653
654impl Panel for TerminalPanel {
655 fn position(&self, cx: &WindowContext) -> DockPosition {
656 match TerminalSettings::get_global(cx).dock {
657 TerminalDockPosition::Left => DockPosition::Left,
658 TerminalDockPosition::Bottom => DockPosition::Bottom,
659 TerminalDockPosition::Right => DockPosition::Right,
660 }
661 }
662
663 fn position_is_valid(&self, _: DockPosition) -> bool {
664 true
665 }
666
667 fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
668 settings::update_settings_file::<TerminalSettings>(self.fs.clone(), cx, move |settings| {
669 let dock = match position {
670 DockPosition::Left => TerminalDockPosition::Left,
671 DockPosition::Bottom => TerminalDockPosition::Bottom,
672 DockPosition::Right => TerminalDockPosition::Right,
673 };
674 settings.dock = Some(dock);
675 });
676 }
677
678 fn size(&self, cx: &WindowContext) -> Pixels {
679 let settings = TerminalSettings::get_global(cx);
680 match self.position(cx) {
681 DockPosition::Left | DockPosition::Right => {
682 self.width.unwrap_or_else(|| settings.default_width)
683 }
684 DockPosition::Bottom => self.height.unwrap_or_else(|| settings.default_height),
685 }
686 }
687
688 fn set_size(&mut self, size: Option<Pixels>, cx: &mut ViewContext<Self>) {
689 match self.position(cx) {
690 DockPosition::Left | DockPosition::Right => self.width = size,
691 DockPosition::Bottom => self.height = size,
692 }
693 self.serialize(cx);
694 cx.notify();
695 }
696
697 fn is_zoomed(&self, cx: &WindowContext) -> bool {
698 self.pane.read(cx).is_zoomed()
699 }
700
701 fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext<Self>) {
702 self.pane.update(cx, |pane, cx| pane.set_zoomed(zoomed, cx));
703 }
704
705 fn set_active(&mut self, active: bool, cx: &mut ViewContext<Self>) {
706 if active && self.pane.read(cx).items_len() == 0 && self.pending_terminals_to_add == 0 {
707 self.add_terminal(None, None, cx)
708 }
709 }
710
711 fn icon_label(&self, cx: &WindowContext) -> Option<String> {
712 let count = self.pane.read(cx).items_len();
713 if count == 0 {
714 None
715 } else {
716 Some(count.to_string())
717 }
718 }
719
720 fn persistent_name() -> &'static str {
721 "TerminalPanel"
722 }
723
724 fn icon(&self, _cx: &WindowContext) -> Option<IconName> {
725 Some(IconName::Terminal)
726 }
727
728 fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
729 Some("Terminal Panel")
730 }
731
732 fn toggle_action(&self) -> Box<dyn gpui::Action> {
733 Box::new(ToggleFocus)
734 }
735}
736
737#[derive(Serialize, Deserialize)]
738struct SerializedTerminalPanel {
739 items: Vec<u64>,
740 active_item_id: Option<u64>,
741 width: Option<Pixels>,
742 height: Option<Pixels>,
743}