Introduced ItemEvent and to_item_events function to Item trait which converts the Item's events into a standard ItemEvent similar to how SearchableItems work.
Add breadcrumb_location and breadcrumbs functions to item trait which handles rendering of the breadcrumb elements Change breadcrumb toolbar to use these new functions rather than having hard coded breadcrumb logic Add breadcrumb support to the terminal tabs Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
co-authored by
Mikayla Maki
parent
ab81093ef5
commit
31ecb2f7bc
@@ -83,6 +83,7 @@ const DEBUG_LINE_HEIGHT: f32 = 5.;
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Event {
|
||||
TitleChanged,
|
||||
BreadcrumbsChanged,
|
||||
CloseTerminal,
|
||||
Bell,
|
||||
Wakeup,
|
||||
@@ -494,9 +495,11 @@ impl Terminal {
|
||||
match event {
|
||||
AlacTermEvent::Title(title) => {
|
||||
self.breadcrumb_text = title.to_string();
|
||||
cx.emit(Event::BreadcrumbsChanged);
|
||||
}
|
||||
AlacTermEvent::ResetTitle => {
|
||||
self.breadcrumb_text = String::new();
|
||||
cx.emit(Event::BreadcrumbsChanged);
|
||||
}
|
||||
AlacTermEvent::ClipboardStore(_, data) => {
|
||||
cx.write_to_clipboard(ClipboardItem::new(data.to_string()))
|
||||
|
||||
@@ -9,7 +9,7 @@ use gpui::{
|
||||
};
|
||||
use util::truncate_and_trailoff;
|
||||
use workspace::searchable::{SearchEvent, SearchOptions, SearchableItem, SearchableItemHandle};
|
||||
use workspace::{Item, ItemEvent, Workspace};
|
||||
use workspace::{Item, ItemEvent, ToolbarItemLocation, Workspace};
|
||||
|
||||
use crate::TerminalSize;
|
||||
use project::{LocalWorktree, Project, ProjectPath};
|
||||
@@ -363,13 +363,37 @@ impl Item for TerminalContainer {
|
||||
Some(Box::new(handle.clone()))
|
||||
}
|
||||
|
||||
fn to_item_events(event: &Self::Event) -> Vec<workspace::ItemEvent> {
|
||||
fn to_item_events(event: &Self::Event) -> Vec<ItemEvent> {
|
||||
match event {
|
||||
Event::BreadcrumbsChanged => vec![ItemEvent::UpdateBreadcrumbs],
|
||||
Event::TitleChanged | Event::Wakeup => vec![ItemEvent::UpdateTab],
|
||||
Event::CloseTerminal => vec![ItemEvent::CloseItem],
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn breadcrumb_location(&self) -> ToolbarItemLocation {
|
||||
if self.connected().is_some() {
|
||||
ToolbarItemLocation::PrimaryLeft { flex: None }
|
||||
} else {
|
||||
ToolbarItemLocation::Hidden
|
||||
}
|
||||
}
|
||||
|
||||
fn breadcrumbs(&self, theme: &theme::Theme, cx: &AppContext) -> Option<Vec<ElementBox>> {
|
||||
let connected = self.connected()?;
|
||||
|
||||
Some(vec![Text::new(
|
||||
connected
|
||||
.read(cx)
|
||||
.terminal()
|
||||
.read(cx)
|
||||
.breadcrumb_text
|
||||
.to_string(),
|
||||
theme.breadcrumbs.text.clone(),
|
||||
)
|
||||
.boxed()])
|
||||
}
|
||||
}
|
||||
|
||||
impl SearchableItem for TerminalContainer {
|
||||
|
||||
Reference in New Issue
Block a user