Distinguish local and SSH tabs by color and hostname
Replace the window-wide connection badge with purple local tabs and teal SSH tabs. Show the SSH hostname below the remote tab title, including during tab renaming.
This commit is contained in:
@@ -244,9 +244,10 @@ or the server stops.
|
|||||||
## Appearance
|
## Appearance
|
||||||
|
|
||||||
The inset terminal surface and titlebar use the dark Sybil palette shared by
|
The inset terminal surface and titlebar use the dark Sybil palette shared by
|
||||||
Huayra, Attractor, and Sybil. Tabs retain violet accents; pane headers use teal,
|
Huayra, Attractor, and Sybil. Local tabs have a purple accent. SSH tabs have a
|
||||||
with a matching border around the active pane. The titlebar contains equal-width
|
teal accent and show the destination hostname beneath their title. Pane headers
|
||||||
tabs and connection/window controls. `src/chrome.rs` records the theme sources.
|
use teal, with a matching border around the active pane.
|
||||||
|
`src/chrome.rs` records the theme sources.
|
||||||
|
|
||||||
Tab changes and new panes slide with Neovide's 150 ms exponential window-motion
|
Tab changes and new panes slide with Neovide's 150 ms exponential window-motion
|
||||||
curve. Outgoing content remains visible during the transition; only the incoming
|
curve. Outgoing content remains visible during the transition; only the incoming
|
||||||
|
|||||||
+86
-33
@@ -23,7 +23,6 @@ pub const BORDER: u32 = 0x282145;
|
|||||||
pub const TEXT: u32 = 0xf3f1f8;
|
pub const TEXT: u32 = 0xf3f1f8;
|
||||||
pub const MUTED: u32 = 0xa29fbc;
|
pub const MUTED: u32 = 0xa29fbc;
|
||||||
pub const ACCENT: u32 = 0x9858f9;
|
pub const ACCENT: u32 = 0x9858f9;
|
||||||
pub const CYAN: u32 = 0x4bdbf1;
|
|
||||||
// Huayra's Sybil green: hsl(163 72% 45%).
|
// Huayra's Sybil green: hsl(163 72% 45%).
|
||||||
pub const PANE_FOCUS: u32 = 0x20c597;
|
pub const PANE_FOCUS: u32 = 0x20c597;
|
||||||
pub const PANE_MUTED: u32 = 0x527f73;
|
pub const PANE_MUTED: u32 = 0x527f73;
|
||||||
@@ -34,6 +33,7 @@ pub const HEADER_HEIGHT: f32 = 44.;
|
|||||||
pub struct ChromeTab {
|
pub struct ChromeTab {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub label: SharedString,
|
pub label: SharedString,
|
||||||
|
pub remote: Option<String>,
|
||||||
pub active: bool,
|
pub active: bool,
|
||||||
pub editor: Option<Entity<RenameField>>,
|
pub editor: Option<Entity<RenameField>>,
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,6 @@ pub struct ChromeTab {
|
|||||||
/// An app-owned titlebar. Callbacks issue server commands; no tab state lives here.
|
/// An app-owned titlebar. Callbacks issue server commands; no tab state lives here.
|
||||||
/// The close callback should detach this GUI, leaving server sessions alive.
|
/// The close callback should detach this GUI, leaving server sessions alive.
|
||||||
pub fn header(
|
pub fn header(
|
||||||
connection: SharedString,
|
|
||||||
tabs: Vec<ChromeTab>,
|
tabs: Vec<ChromeTab>,
|
||||||
reserve_traffic_lights: bool,
|
reserve_traffic_lights: bool,
|
||||||
on_tab: impl Fn(u64, &mut Window, &mut App) + 'static,
|
on_tab: impl Fn(u64, &mut Window, &mut App) + 'static,
|
||||||
@@ -61,41 +60,68 @@ pub fn header(
|
|||||||
let on_tab = on_tab.clone();
|
let on_tab = on_tab.clone();
|
||||||
let active = tab.active;
|
let active = tab.active;
|
||||||
let id = tab.id;
|
let id = tab.id;
|
||||||
let label = div()
|
let (accent, selected_bg, hover_bg, selected_border) = if tab.remote.is_some() {
|
||||||
|
(PANE_FOCUS, 0x102d28, 0x112720, 0x285749)
|
||||||
|
} else {
|
||||||
|
(ACCENT, ACTIVE_BACKGROUND, HOVER_BACKGROUND, BORDER)
|
||||||
|
};
|
||||||
|
let mut label = div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
.min_w_0()
|
.min_w_0()
|
||||||
.h_full()
|
.h_full()
|
||||||
.flex()
|
.flex()
|
||||||
.items_center()
|
.flex_col()
|
||||||
|
.justify_center()
|
||||||
.overflow_hidden();
|
.overflow_hidden();
|
||||||
let label = if let Some(editor) = tab.editor {
|
if let Some(editor) = tab.editor {
|
||||||
label.child(editor)
|
label = label.child(editor);
|
||||||
} else {
|
} else {
|
||||||
label.child(middle_label(tab.label))
|
label = label.child(
|
||||||
};
|
div()
|
||||||
|
.h(px(16.))
|
||||||
|
.line_height(px(16.))
|
||||||
|
.child(middle_label(tab.label)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if let Some(destination) = tab.remote {
|
||||||
|
label = label.child(
|
||||||
|
div()
|
||||||
|
.h(px(12.))
|
||||||
|
.line_height(px(12.))
|
||||||
|
.text_size(px(10.))
|
||||||
|
.text_color(rgb(PANE_FOCUS))
|
||||||
|
.child(middle_label(
|
||||||
|
remote_hostname(&destination).to_owned().into(),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
tab_strip = tab_strip.child(
|
tab_strip = tab_strip.child(
|
||||||
div()
|
div()
|
||||||
.id(ElementId::Name(format!("tab-{id}").into()))
|
.id(ElementId::Name(format!("tab-{id}").into()))
|
||||||
.flex()
|
.flex()
|
||||||
.items_center()
|
.items_center()
|
||||||
.gap(px(7.))
|
.gap(px(7.))
|
||||||
.h(px(29.))
|
.h(px(38.))
|
||||||
.flex_basis(px(200.))
|
.flex_basis(px(200.))
|
||||||
.flex_shrink()
|
.flex_shrink()
|
||||||
.min_w_0()
|
.min_w_0()
|
||||||
.max_w(px(200.))
|
.max_w(px(200.))
|
||||||
.px(px(10.))
|
.px(px(10.))
|
||||||
.border_1()
|
.border_1()
|
||||||
.border_color(rgb(if active { BORDER } else { PANEL_BACKGROUND }))
|
.border_color(rgb(if active {
|
||||||
|
selected_border
|
||||||
|
} else {
|
||||||
|
PANEL_BACKGROUND
|
||||||
|
}))
|
||||||
.bg(rgb(if active {
|
.bg(rgb(if active {
|
||||||
ACTIVE_BACKGROUND
|
selected_bg
|
||||||
} else {
|
} else {
|
||||||
PANEL_BACKGROUND
|
PANEL_BACKGROUND
|
||||||
}))
|
}))
|
||||||
.text_color(rgb(if active { TEXT } else { MUTED }))
|
.text_color(rgb(if active { TEXT } else { MUTED }))
|
||||||
.text_size(px(11.))
|
.text_size(px(11.))
|
||||||
.cursor_pointer()
|
.cursor_pointer()
|
||||||
.hover(|style| style.bg(rgb(HOVER_BACKGROUND)).text_color(rgb(TEXT)))
|
.hover(move |style| style.bg(rgb(hover_bg)).text_color(rgb(TEXT)))
|
||||||
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
|
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
|
||||||
.on_click(move |_, window, cx| {
|
.on_click(move |_, window, cx| {
|
||||||
cx.stop_propagation();
|
cx.stop_propagation();
|
||||||
@@ -105,8 +131,8 @@ pub fn header(
|
|||||||
div()
|
div()
|
||||||
.w(px(3.))
|
.w(px(3.))
|
||||||
.flex_shrink_0()
|
.flex_shrink_0()
|
||||||
.h(px(12.))
|
.h(px(if active { 22. } else { 12. }))
|
||||||
.bg(rgb(if active { ACCENT } else { BORDER })),
|
.bg(rgb(accent)),
|
||||||
)
|
)
|
||||||
.child(label),
|
.child(label),
|
||||||
);
|
);
|
||||||
@@ -141,18 +167,6 @@ pub fn header(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.child(tab_strip)
|
.child(tab_strip)
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.flex()
|
|
||||||
.items_center()
|
|
||||||
.flex_shrink_0()
|
|
||||||
.gap(px(5.))
|
|
||||||
.max_w(px(170.))
|
|
||||||
.text_size(px(10.))
|
|
||||||
.text_color(rgb(MUTED))
|
|
||||||
.child(div().size(px(4.)).rounded_full().bg(rgb(CYAN)))
|
|
||||||
.child(div().text_ellipsis().child(connection)),
|
|
||||||
)
|
|
||||||
.child(control("new-tab", "+", false, on_new))
|
.child(control("new-tab", "+", false, on_new))
|
||||||
.when(!cfg!(target_os = "macos"), |row| {
|
.when(!cfg!(target_os = "macos"), |row| {
|
||||||
row.child(control("detach-window", "×", true, on_close))
|
row.child(control("detach-window", "×", true, on_close))
|
||||||
@@ -160,6 +174,22 @@ pub fn header(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Keep SSH aliases as entered, omitting user, URI port and IPv6 brackets.
|
||||||
|
fn remote_hostname(destination: &str) -> &str {
|
||||||
|
let uri = destination.strip_prefix("ssh://");
|
||||||
|
let address = uri.unwrap_or(destination).trim_end_matches('/');
|
||||||
|
let host = address.rsplit_once('@').map_or(address, |(_, host)| host);
|
||||||
|
if let Some((ipv6, _)) = host.strip_prefix('[').and_then(|s| s.split_once(']')) {
|
||||||
|
return ipv6;
|
||||||
|
}
|
||||||
|
if uri.is_some()
|
||||||
|
&& let Some((name, _)) = host.split_once(':')
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
host
|
||||||
|
}
|
||||||
|
|
||||||
fn control(
|
fn control(
|
||||||
id: &'static str,
|
id: &'static str,
|
||||||
label: &'static str,
|
label: &'static str,
|
||||||
@@ -197,18 +227,41 @@ fn control(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn displays_hostnames_for_ssh_destinations() {
|
||||||
|
for (destination, hostname) in [
|
||||||
|
("workstation", "workstation"),
|
||||||
|
("alice@build.lan", "build.lan"),
|
||||||
|
("alice@2001:db8::1", "2001:db8::1"),
|
||||||
|
("[2001:db8::1]", "2001:db8::1"),
|
||||||
|
("ssh://alice@build.lan:2222", "build.lan"),
|
||||||
|
("ssh://alice@[2001:db8::1]:2222/", "2001:db8::1"),
|
||||||
|
] {
|
||||||
|
assert_eq!(remote_hostname(destination), hostname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn header_constructs_each_control_without_duplicate_hover_styles() {
|
fn header_constructs_each_control_without_duplicate_hover_styles() {
|
||||||
// GPUI rejects installing a hover style twice before the first window
|
// GPUI rejects installing a hover style twice before the first window
|
||||||
// frame. Exercise the complete header, including its danger control.
|
// frame. Exercise the complete header, including its danger control.
|
||||||
let _ = header(
|
let _ = header(
|
||||||
"Local".into(),
|
vec![
|
||||||
vec![ChromeTab {
|
ChromeTab {
|
||||||
id: 1,
|
id: 1,
|
||||||
label: "Shell".into(),
|
label: "Shell".into(),
|
||||||
active: true,
|
remote: None,
|
||||||
editor: None,
|
active: true,
|
||||||
}],
|
editor: None,
|
||||||
|
},
|
||||||
|
ChromeTab {
|
||||||
|
id: 2,
|
||||||
|
label: "Build".into(),
|
||||||
|
remote: Some("user@work".into()),
|
||||||
|
active: false,
|
||||||
|
editor: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
cfg!(target_os = "macos"),
|
cfg!(target_os = "macos"),
|
||||||
|_, _, _| {},
|
|_, _, _| {},
|
||||||
|_, _| {},
|
|_, _| {},
|
||||||
|
|||||||
+1
-7
@@ -212,10 +212,6 @@ pub(crate) fn run_gui(
|
|||||||
session: SessionTarget,
|
session: SessionTarget,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let (client, updates) = client::Client::connect(&socket, remote.as_deref(), session)?;
|
let (client, updates) = client::Client::connect(&socket, remote.as_deref(), session)?;
|
||||||
let connection: SharedString = remote
|
|
||||||
.map(|host| format!("SSH · {host}"))
|
|
||||||
.unwrap_or_else(|| "Local".into())
|
|
||||||
.into();
|
|
||||||
Application::new().run(move |cx: &mut App| {
|
Application::new().run(move |cx: &mut App| {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
@@ -256,9 +252,7 @@ pub(crate) fn run_gui(
|
|||||||
app_id: Some("dev.buzzert.psyterm".into()),
|
app_id: Some("dev.buzzert.psyterm".into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
move |window, cx| {
|
move |window, cx| cx.new(|cx| terminal::Workspace::new(client, updates, window, cx)),
|
||||||
cx.new(|cx| terminal::Workspace::new(client, updates, connection, window, cx))
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
.expect("could not open psyTerm window");
|
.expect("could not open psyTerm window");
|
||||||
cx.activate(true);
|
cx.activate(true);
|
||||||
|
|||||||
+5
-4
@@ -38,7 +38,6 @@ struct TabRename {
|
|||||||
|
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
client: Client,
|
client: Client,
|
||||||
connection: SharedString,
|
|
||||||
font: TerminalFont,
|
font: TerminalFont,
|
||||||
snapshot: Option<Arc<Snapshot>>,
|
snapshot: Option<Arc<Snapshot>>,
|
||||||
panes: HashMap<u64, Entity<TerminalPane>>,
|
panes: HashMap<u64, Entity<TerminalPane>>,
|
||||||
@@ -328,7 +327,6 @@ impl Workspace {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
client: Client,
|
client: Client,
|
||||||
updates: Updates,
|
updates: Updates,
|
||||||
connection: SharedString,
|
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -479,7 +477,6 @@ impl Workspace {
|
|||||||
});
|
});
|
||||||
Self {
|
Self {
|
||||||
client,
|
client,
|
||||||
connection,
|
|
||||||
font,
|
font,
|
||||||
snapshot: None,
|
snapshot: None,
|
||||||
panes: HashMap::new(),
|
panes: HashMap::new(),
|
||||||
@@ -529,6 +526,11 @@ impl Render for Workspace {
|
|||||||
.map(|tab| chrome::ChromeTab {
|
.map(|tab| chrome::ChromeTab {
|
||||||
id: tab.id,
|
id: tab.id,
|
||||||
label: tab.title.clone().into(),
|
label: tab.title.clone().into(),
|
||||||
|
remote: tab
|
||||||
|
.remote
|
||||||
|
.as_deref()
|
||||||
|
.or(self.client.remote())
|
||||||
|
.map(str::to_owned),
|
||||||
active: tab.id == s.active_tab,
|
active: tab.id == s.active_tab,
|
||||||
editor: self
|
editor: self
|
||||||
.tab_rename
|
.tab_rename
|
||||||
@@ -542,7 +544,6 @@ impl Render for Workspace {
|
|||||||
let client = self.client.clone();
|
let client = self.client.clone();
|
||||||
let new_client = self.client.clone();
|
let new_client = self.client.clone();
|
||||||
let header = chrome::header(
|
let header = chrome::header(
|
||||||
self.connection.clone(),
|
|
||||||
tabs,
|
tabs,
|
||||||
cfg!(target_os = "macos") && !window.is_fullscreen(),
|
cfg!(target_os = "macos") && !window.is_fullscreen(),
|
||||||
move |tab, _, _| {
|
move |tab, _, _| {
|
||||||
|
|||||||
Reference in New Issue
Block a user