mirror of
https://github.com/rust-kotlin/ashell.git
synced 2026-10-03 16:00:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f45c2ed60f | ||
|
|
8a8f280401 | ||
|
|
dc006f7144 | ||
|
|
daaebe4c2b | ||
|
|
2a37f45ba2 | ||
|
|
ee8c18844c | ||
|
|
c5b09628b3 |
Generated
+1
-1
@@ -303,7 +303,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ashell"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"alacritty_terminal",
|
||||
"anyhow",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ashell"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
edition = "2024"
|
||||
authors = ["ashell contributors"]
|
||||
description = "A GPUI Component based SSH and local terminal client"
|
||||
|
||||
@@ -124,6 +124,10 @@ settings_about: "About"
|
||||
settings_group_appearance: "Appearance"
|
||||
settings_group_font: "Font"
|
||||
settings_group_other: "Other"
|
||||
settings_group_keybind_general: "General"
|
||||
settings_group_keybind_zoom: "Zoom"
|
||||
settings_group_keybind_focus: "Focus"
|
||||
settings_group_keybind_panel: "Panel"
|
||||
theme: "Theme"
|
||||
theme_mode: "Theme Mode"
|
||||
clear_transfers: "Clear History"
|
||||
@@ -133,6 +137,7 @@ press_new_key: "Press new key..."
|
||||
settings_open_settings: "Open Settings"
|
||||
settings_open_session: "Open Session"
|
||||
settings_new_ssh: "New SSH"
|
||||
settings_toggle_sidebar: "Toggle Sidebar"
|
||||
settings_toggle_sftp_zoom: "Toggle SFTP Zoom"
|
||||
settings_focus_pane_left: "Focus Pane Left"
|
||||
settings_focus_pane_right: "Focus Pane Right"
|
||||
|
||||
@@ -127,6 +127,10 @@ settings_about: "关于"
|
||||
settings_group_appearance: "外观"
|
||||
settings_group_font: "字体"
|
||||
settings_group_other: "其它"
|
||||
settings_group_keybind_general: "常规"
|
||||
settings_group_keybind_zoom: "缩放"
|
||||
settings_group_keybind_focus: "焦点"
|
||||
settings_group_keybind_panel: "面板"
|
||||
theme: "主题"
|
||||
theme_mode: "主题模式"
|
||||
clear_transfers: "清空记录"
|
||||
@@ -136,6 +140,7 @@ press_new_key: "请按下新的快捷键..."
|
||||
settings_open_settings: "打开设置"
|
||||
settings_open_session: "打开会话"
|
||||
settings_new_ssh: "新建 SSH"
|
||||
settings_toggle_sidebar: "缩放侧边栏"
|
||||
settings_toggle_sftp_zoom: "缩放 SFTP 面板"
|
||||
settings_focus_pane_left: "向左切换焦点"
|
||||
settings_focus_pane_right: "向右切换焦点"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub(crate) const DEFAULT_COLS: u16 = 100;
|
||||
pub(crate) const DEFAULT_ROWS: u16 = 30;
|
||||
pub(crate) const SIDEBAR_WIDTH: f32 = 306.0;
|
||||
pub(crate) const COLLAPSED_SIDEBAR_WIDTH: f32 = 52.0;
|
||||
pub(crate) const TAB_BAR_HEIGHT: f32 = 52.0;
|
||||
pub(crate) const TERMINAL_PADDING_X: f32 = 32.0;
|
||||
pub(crate) const TERMINAL_PADDING_Y: f32 = 32.0;
|
||||
|
||||
+8
-4
@@ -1541,11 +1541,15 @@ impl Ashell {
|
||||
)
|
||||
)
|
||||
)
|
||||
.page(
|
||||
SettingPage::new(t!("settings_key_bindings").to_string())
|
||||
.page({
|
||||
let mut page = SettingPage::new(t!("settings_key_bindings").to_string())
|
||||
.icon(IconName::SquareTerminal)
|
||||
.group(crate::app::keybinding_recorder::KeybindingsPage::render(&view, cx))
|
||||
)
|
||||
.default_open(true);
|
||||
for group in crate::app::keybinding_recorder::KeybindingsPage::render_groups(&view, cx) {
|
||||
page = page.group(group);
|
||||
}
|
||||
page
|
||||
})
|
||||
.page(
|
||||
SettingPage::new(t!("settings_help").to_string())
|
||||
.icon(IconName::BookOpen)
|
||||
|
||||
+107
-58
@@ -17,6 +17,7 @@ gpui::actions!(
|
||||
OpenSettings,
|
||||
OpenSession,
|
||||
NewSsh,
|
||||
ToggleSidebar,
|
||||
ToggleSftpZoom,
|
||||
FocusPaneLeft,
|
||||
FocusPaneRight,
|
||||
@@ -55,6 +56,11 @@ pub(crate) const WORKSPACE_ACTIONS: &[WorkspaceAction] = &[
|
||||
label_key: "settings_new_ssh",
|
||||
default_suffix: "n",
|
||||
},
|
||||
WorkspaceAction {
|
||||
id: "ToggleSidebar",
|
||||
label_key: "settings_toggle_sidebar",
|
||||
default_suffix: "s",
|
||||
},
|
||||
WorkspaceAction {
|
||||
id: "ToggleSftpZoom",
|
||||
label_key: "settings_toggle_sftp_zoom",
|
||||
@@ -193,6 +199,7 @@ pub(crate) fn unbind_all_workspace_keys(cx: &mut App, config: &ConfigStore) {
|
||||
unbind_action!("OpenSettings", crate::OpenSettings);
|
||||
unbind_action!("OpenSession", crate::OpenSession);
|
||||
unbind_action!("NewSsh", crate::NewSsh);
|
||||
unbind_action!("ToggleSidebar", crate::ToggleSidebar);
|
||||
unbind_action!("ToggleSftpZoom", crate::ToggleSftpZoom);
|
||||
unbind_action!("FocusPaneLeft", crate::FocusPaneLeft);
|
||||
unbind_action!("FocusPaneRight", crate::FocusPaneRight);
|
||||
@@ -246,6 +253,7 @@ fn bind_workspace_actions(cx: &mut App, config: &ConfigStore) {
|
||||
bind_action!("OpenSettings", crate::OpenSettings);
|
||||
bind_action!("OpenSession", crate::OpenSession);
|
||||
bind_action!("NewSsh", crate::NewSsh);
|
||||
bind_action!("ToggleSidebar", crate::ToggleSidebar);
|
||||
bind_action!("ToggleSftpZoom", crate::ToggleSftpZoom);
|
||||
bind_action!("FocusPaneLeft", crate::FocusPaneLeft);
|
||||
bind_action!("FocusPaneRight", crate::FocusPaneRight);
|
||||
@@ -261,74 +269,115 @@ fn bind_workspace_actions(cx: &mut App, config: &ConfigStore) {
|
||||
}
|
||||
|
||||
impl KeybindingsPage {
|
||||
pub fn render(view: &Entity<Ashell>, cx: &mut App) -> SettingGroup {
|
||||
let mut group = SettingGroup::new();
|
||||
pub fn render_groups(view: &Entity<Ashell>, cx: &mut App) -> Vec<SettingGroup> {
|
||||
let groups = [
|
||||
(
|
||||
"settings_group_keybind_general",
|
||||
vec!["OpenSettings", "OpenSession", "NewSsh"],
|
||||
),
|
||||
(
|
||||
"settings_group_keybind_zoom",
|
||||
vec!["ToggleSidebar", "ToggleSftpZoom"],
|
||||
),
|
||||
(
|
||||
"settings_group_keybind_focus",
|
||||
vec![
|
||||
"FocusPaneLeft",
|
||||
"FocusPaneRight",
|
||||
"FocusPaneUp",
|
||||
"FocusPaneDown",
|
||||
],
|
||||
),
|
||||
(
|
||||
"settings_group_keybind_panel",
|
||||
vec![
|
||||
"SplitPaneLeft",
|
||||
"SplitPaneRight",
|
||||
"SplitPaneUp",
|
||||
"SplitPaneDown",
|
||||
"ClosePane",
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
for action in WORKSPACE_ACTIONS {
|
||||
let recording = view.read(cx).recording_action.as_deref() == Some(action.id);
|
||||
let has_error = view
|
||||
.read(cx)
|
||||
.keybind_error
|
||||
.as_ref()
|
||||
.is_some_and(|(id, _)| id == action.id);
|
||||
let error_msg = if has_error {
|
||||
view.read(cx)
|
||||
let mut result = Vec::new();
|
||||
|
||||
for (group_label, action_ids) in groups {
|
||||
let mut group = SettingGroup::new().title(t!(group_label).to_string());
|
||||
|
||||
for action_id in action_ids {
|
||||
let action = WORKSPACE_ACTIONS
|
||||
.iter()
|
||||
.find(|a| a.id == action_id)
|
||||
.expect("action exists");
|
||||
|
||||
let recording = view.read(cx).recording_action.as_deref() == Some(action.id);
|
||||
let has_error = view
|
||||
.read(cx)
|
||||
.keybind_error
|
||||
.as_ref()
|
||||
.map(|(_, msg)| msg.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
.is_some_and(|(id, _)| id == action.id);
|
||||
let error_msg = if has_error {
|
||||
view.read(cx)
|
||||
.keybind_error
|
||||
.as_ref()
|
||||
.map(|(_, msg)| msg.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let keystroke = {
|
||||
let config = &view.read(cx).config;
|
||||
configured_keystroke(config, action.id).unwrap_or_default()
|
||||
};
|
||||
let keystroke = {
|
||||
let config = &view.read(cx).config;
|
||||
configured_keystroke(config, action.id).unwrap_or_default()
|
||||
};
|
||||
|
||||
let btn_label = if recording {
|
||||
t!("press_new_key").to_string()
|
||||
} else if keystroke.is_empty() {
|
||||
t!("none").to_string()
|
||||
} else {
|
||||
format_keystroke(&keystroke)
|
||||
};
|
||||
let btn_label = if recording {
|
||||
t!("press_new_key").to_string()
|
||||
} else if keystroke.is_empty() {
|
||||
t!("none").to_string()
|
||||
} else {
|
||||
format_keystroke(&keystroke)
|
||||
};
|
||||
|
||||
let mut item = SettingItem::new(
|
||||
t!(action.label_key).to_string(),
|
||||
SettingField::render({
|
||||
let view = view.clone();
|
||||
let action_id = action.id.to_string();
|
||||
move |_, _window, _cx| {
|
||||
Button::new(gpui::SharedString::from(format!("keybind-{action_id}")))
|
||||
.label(btn_label.clone())
|
||||
.small()
|
||||
.when(recording, |this| this.primary())
|
||||
.when(has_error, |this| this.danger())
|
||||
.on_click({
|
||||
let view = view.clone();
|
||||
let action_id = action_id.clone();
|
||||
move |_event, window, cx| {
|
||||
view.update(cx, |this, cx| {
|
||||
// Clear any previous error when starting new recording
|
||||
this.keybind_error = None;
|
||||
this.recording_action = Some(action_id.clone());
|
||||
this.focus_handle.focus(window, cx);
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
}),
|
||||
);
|
||||
let mut item = SettingItem::new(
|
||||
t!(action.label_key).to_string(),
|
||||
SettingField::render({
|
||||
let view = view.clone();
|
||||
let action_id = action.id.to_string();
|
||||
move |_, _window, _cx| {
|
||||
Button::new(gpui::SharedString::from(format!("keybind-{action_id}")))
|
||||
.label(btn_label.clone())
|
||||
.small()
|
||||
.when(recording, |this| this.primary())
|
||||
.when(has_error, |this| this.danger())
|
||||
.on_click({
|
||||
let view = view.clone();
|
||||
let action_id = action_id.clone();
|
||||
move |_event, window, cx| {
|
||||
view.update(cx, |this, cx| {
|
||||
// Clear any previous error when starting new recording
|
||||
this.keybind_error = None;
|
||||
this.recording_action = Some(action_id.clone());
|
||||
this.focus_handle.focus(window, cx);
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
if let Some(msg) = error_msg {
|
||||
item = item.description(msg);
|
||||
if let Some(msg) = error_msg {
|
||||
item = item.description(msg);
|
||||
}
|
||||
|
||||
group = group.item(item);
|
||||
}
|
||||
|
||||
group = group.item(item);
|
||||
result.push(group);
|
||||
}
|
||||
|
||||
group
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +245,8 @@ pub(crate) struct Ashell {
|
||||
pub(crate) drag_split_origin: Option<gpui::Point<Pixels>>,
|
||||
pub(crate) terminal_marked_text: Option<String>,
|
||||
pub(crate) sftp_panel_minimized: bool,
|
||||
pub(crate) sidebar_collapsed: bool,
|
||||
pub(crate) collapsed_saved_scroll_handle: gpui::ScrollHandle,
|
||||
pub(crate) prev_monitoring_size: Option<Pixels>,
|
||||
pub(crate) status: SharedString,
|
||||
pub(crate) config: ConfigStore,
|
||||
@@ -467,6 +469,8 @@ impl Ashell {
|
||||
dragging_splitter: None,
|
||||
drag_split_origin: None,
|
||||
sftp_panel_minimized: false,
|
||||
sidebar_collapsed: false,
|
||||
collapsed_saved_scroll_handle: gpui::ScrollHandle::new(),
|
||||
prev_monitoring_size: None,
|
||||
status: "ready".into(),
|
||||
config,
|
||||
|
||||
+511
-144
@@ -5,7 +5,7 @@ use gpui::{
|
||||
prelude::FluentBuilder as _, px, rems, uniform_list,
|
||||
};
|
||||
use gpui_component::{
|
||||
ActiveTheme, Disableable as _, ElementExt, IconName, Root, Sizable as _,
|
||||
ActiveTheme, Disableable as _, ElementExt, Icon, IconName, Root, Size, Sizable as _,
|
||||
button::{Button, ButtonVariants as _},
|
||||
checkbox::Checkbox,
|
||||
h_flex,
|
||||
@@ -21,7 +21,7 @@ use rust_i18n::t;
|
||||
|
||||
use crate::{
|
||||
Ashell, PaneLayout,
|
||||
app::constants::{SIDEBAR_WIDTH, TERMINAL_KEY_CONTEXT},
|
||||
app::constants::{COLLAPSED_SIDEBAR_WIDTH, SIDEBAR_WIDTH, TERMINAL_KEY_CONTEXT},
|
||||
sftp::format_mtime,
|
||||
sftp::ops::is_editable_text_file,
|
||||
system::format_bytes,
|
||||
@@ -118,9 +118,65 @@ impl Ashell {
|
||||
) -> impl IntoElement {
|
||||
let active_sftp = self.active_sftp();
|
||||
|
||||
// Compute active download progress for status bar and minimized header
|
||||
let build_summary = |kind: crate::terminal::TransferType| -> Option<(String, String, f32)> {
|
||||
let active: Vec<&crate::terminal::Transfer> = self
|
||||
.transfers
|
||||
.iter()
|
||||
.filter(|t| {
|
||||
matches!(
|
||||
t.state,
|
||||
crate::terminal::TransferState::Running
|
||||
| crate::terminal::TransferState::Paused
|
||||
) && t.info.kind == kind
|
||||
})
|
||||
.collect();
|
||||
if active.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some(if active.len() == 1 {
|
||||
let t = &active[0];
|
||||
let pct = t.total.and_then(|total| {
|
||||
if total > 0 {
|
||||
Some((t.transferred as f64 / total as f64 * 100.0) as f32)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
match pct {
|
||||
Some(pct) => (t.info.name.clone(), format!("{:.0}%", pct), pct),
|
||||
None => (t.info.name.clone(), "-".to_string(), 0.0),
|
||||
}
|
||||
} else {
|
||||
let total_transferred: u64 = active.iter().map(|t| t.transferred).sum();
|
||||
let total_total: u64 = active.iter().filter_map(|t| t.total).sum();
|
||||
let pct = if total_total > 0 {
|
||||
Some((total_transferred as f64 / total_total as f64 * 100.0) as f32)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let label = match kind {
|
||||
crate::terminal::TransferType::Download => {
|
||||
format!("{} files downloading", active.len())
|
||||
}
|
||||
crate::terminal::TransferType::Upload => {
|
||||
format!("{} files uploading", active.len())
|
||||
}
|
||||
};
|
||||
match pct {
|
||||
Some(pct) => (label, format!("{:.0}%", pct), pct),
|
||||
None => (label, "-".to_string(), 0.0),
|
||||
}
|
||||
})
|
||||
};
|
||||
let dl_summary = build_summary(crate::terminal::TransferType::Download);
|
||||
let ul_summary = build_summary(crate::terminal::TransferType::Upload);
|
||||
let has_transfers = dl_summary.is_some() || ul_summary.is_some();
|
||||
|
||||
let header = h_flex()
|
||||
.flex_none()
|
||||
.h(px(34.))
|
||||
.px_2()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.border_b_1()
|
||||
@@ -226,61 +282,123 @@ impl Ashell {
|
||||
cx.notify();
|
||||
})),
|
||||
)
|
||||
})
|
||||
.child(
|
||||
Button::new("open-transfers")
|
||||
.ghost()
|
||||
.small()
|
||||
.icon(IconName::ArrowDown)
|
||||
.label(t!("transfers").to_string())
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.show_transfers_dialog(window, cx);
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
Button::new("sftp-minimize-toggle")
|
||||
.ghost()
|
||||
.small()
|
||||
.icon(if self.sftp_panel_minimized {
|
||||
IconName::ChevronUp
|
||||
} else {
|
||||
IconName::ChevronDown
|
||||
})
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.toggle_sftp_minimized(window, cx);
|
||||
})),
|
||||
);
|
||||
});
|
||||
|
||||
let Some(sftp) = active_sftp else {
|
||||
let mut panel = v_flex()
|
||||
let mut outer = v_flex()
|
||||
.gap_0()
|
||||
.border_color(cx.theme().border)
|
||||
.bg(cx.theme().background);
|
||||
|
||||
if !self.sftp_panel_minimized {
|
||||
panel = panel.size_full();
|
||||
} else {
|
||||
panel = panel.flex_none();
|
||||
}
|
||||
|
||||
panel = panel.child(header);
|
||||
|
||||
if !self.sftp_panel_minimized {
|
||||
panel = panel.child(
|
||||
.bg(cx.theme().background)
|
||||
.flex_1()
|
||||
.child(
|
||||
v_flex()
|
||||
.flex_1()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.p_3()
|
||||
.min_h(px(0.))
|
||||
.when(self.sftp_panel_minimized, |this| this.hidden())
|
||||
.child(header)
|
||||
.child(
|
||||
div()
|
||||
.text_size(rems(1.0))
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(t!("open_ssh_tab_sftp")),
|
||||
v_flex()
|
||||
.flex_1()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.p_3()
|
||||
.child(
|
||||
div()
|
||||
.text_size(rems(1.0))
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(t!("open_ssh_tab_sftp")),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return panel.into_any_element();
|
||||
outer = outer.child(
|
||||
h_flex()
|
||||
.flex_none()
|
||||
.h(px(24.))
|
||||
.px_3()
|
||||
.items_center()
|
||||
.border_t_1()
|
||||
.border_color(cx.theme().border)
|
||||
.bg(cx.theme().tab_bar)
|
||||
.child(div().flex_1())
|
||||
.child(
|
||||
Button::new("open-transfers")
|
||||
.ghost()
|
||||
.small()
|
||||
.when(has_transfers, |this| {
|
||||
let mut content = h_flex().items_center().gap_2();
|
||||
if let Some((ref label, ref pct_display, pct)) = dl_summary {
|
||||
content = content.child(
|
||||
h_flex().items_center().gap_1()
|
||||
.child(Icon::new(IconName::ArrowDown)
|
||||
.with_size(Size::Small)
|
||||
.text_color(cx.theme().primary))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(label.clone()))
|
||||
.child(Progress::new("sftp-status-dl")
|
||||
.with_size(px(4.))
|
||||
.value(pct)
|
||||
.color(cx.theme().primary)
|
||||
.w(px(50.0)))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(pct_display.clone())),
|
||||
);
|
||||
}
|
||||
if let Some((ref label, ref pct_display, pct)) = ul_summary {
|
||||
if dl_summary.is_some() {
|
||||
content = content.child(div().w(px(6.)));
|
||||
}
|
||||
content = content.child(
|
||||
h_flex().items_center().gap_1()
|
||||
.child(Icon::new(IconName::ArrowUp)
|
||||
.with_size(Size::Small)
|
||||
.text_color(cx.theme().primary))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(label.clone()))
|
||||
.child(Progress::new("sftp-status-ul")
|
||||
.with_size(px(4.))
|
||||
.value(pct)
|
||||
.color(cx.theme().primary)
|
||||
.w(px(50.0)))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(pct_display.clone())),
|
||||
);
|
||||
}
|
||||
this.child(content)
|
||||
})
|
||||
.when(!has_transfers, |this| {
|
||||
this.icon(IconName::ArrowDown)
|
||||
})
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.show_transfers_dialog(window, cx);
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
Button::new("sftp-minimize-toggle")
|
||||
.ghost()
|
||||
.small()
|
||||
.icon(if self.sftp_panel_minimized {
|
||||
IconName::ChevronUp
|
||||
} else {
|
||||
IconName::ChevronDown
|
||||
})
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.toggle_sftp_minimized(window, cx);
|
||||
})),
|
||||
),
|
||||
);
|
||||
return outer.into_any_element();
|
||||
};
|
||||
|
||||
let selected_path = sftp.selected_path.clone();
|
||||
@@ -302,18 +420,11 @@ impl Ashell {
|
||||
let size_col_width = px(96.);
|
||||
let modified_col_width = px(152.);
|
||||
|
||||
let mut panel = v_flex()
|
||||
let mut outer = v_flex()
|
||||
.gap_0()
|
||||
.border_color(cx.theme().border)
|
||||
.bg(cx.theme().background);
|
||||
|
||||
if !self.sftp_panel_minimized {
|
||||
panel = panel.size_full();
|
||||
} else {
|
||||
panel = panel.flex_none();
|
||||
}
|
||||
|
||||
panel = panel
|
||||
.bg(cx.theme().background)
|
||||
.flex_1()
|
||||
.on_drop(
|
||||
cx.listener(|this, paths: &gpui::ExternalPaths, _window, cx| {
|
||||
let paths_to_upload: Vec<String> = paths
|
||||
@@ -323,11 +434,14 @@ impl Ashell {
|
||||
.collect();
|
||||
this.upload_sftp_files_batch(paths_to_upload, cx);
|
||||
}),
|
||||
)
|
||||
.child(header);
|
||||
);
|
||||
|
||||
if !self.sftp_panel_minimized {
|
||||
panel = panel
|
||||
outer = outer.child(
|
||||
v_flex()
|
||||
.flex_1()
|
||||
.min_h(px(0.))
|
||||
.when(self.sftp_panel_minimized, |this| this.hidden())
|
||||
.child(header)
|
||||
.child(
|
||||
h_flex()
|
||||
.h(px(36.))
|
||||
@@ -592,27 +706,106 @@ impl Ashell {
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
.flex_none()
|
||||
.h(px(24.))
|
||||
.px_3()
|
||||
.items_center()
|
||||
.border_t_1()
|
||||
.border_color(cx.theme().border)
|
||||
.bg(cx.theme().tab_bar)
|
||||
.child(
|
||||
div()
|
||||
.min_w(px(0.))
|
||||
.overflow_hidden()
|
||||
.text_size(rems(0.917))
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(status),
|
||||
),
|
||||
);
|
||||
}
|
||||
outer = outer.child(
|
||||
h_flex()
|
||||
.flex_none()
|
||||
.h(px(24.))
|
||||
.px_3()
|
||||
.items_center()
|
||||
.border_t_1()
|
||||
.border_color(cx.theme().border)
|
||||
.bg(cx.theme().tab_bar)
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w(px(0.))
|
||||
.overflow_hidden()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(status),
|
||||
)
|
||||
.child(
|
||||
Button::new("open-transfers")
|
||||
.ghost()
|
||||
.small()
|
||||
.when(has_transfers, |this| {
|
||||
let mut content = h_flex().items_center().gap_2();
|
||||
if let Some((ref label, ref pct_display, pct)) = dl_summary {
|
||||
content = content.child(
|
||||
h_flex().items_center().gap_1()
|
||||
.child(Icon::new(IconName::ArrowDown)
|
||||
.with_size(Size::Small)
|
||||
.text_color(cx.theme().primary))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(label.clone()))
|
||||
.child(Progress::new("sftp-status-dl")
|
||||
.with_size(px(4.))
|
||||
.value(pct)
|
||||
.color(cx.theme().primary)
|
||||
.w(px(50.0)))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(pct_display.clone())),
|
||||
);
|
||||
}
|
||||
if let Some((ref label, ref pct_display, pct)) = ul_summary {
|
||||
if dl_summary.is_some() {
|
||||
content = content.child(div().w(px(6.)));
|
||||
}
|
||||
content = content.child(
|
||||
h_flex().items_center().gap_1()
|
||||
.child(Icon::new(IconName::ArrowUp)
|
||||
.with_size(Size::Small)
|
||||
.text_color(cx.theme().primary))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(label.clone()))
|
||||
.child(Progress::new("sftp-status-ul")
|
||||
.with_size(px(4.))
|
||||
.value(pct)
|
||||
.color(cx.theme().primary)
|
||||
.w(px(50.0)))
|
||||
.child(div()
|
||||
.text_size(rems(0.833))
|
||||
.text_color(cx.theme().primary)
|
||||
.italic()
|
||||
.child(pct_display.clone())),
|
||||
);
|
||||
}
|
||||
this.child(content)
|
||||
})
|
||||
.when(!has_transfers, |this| {
|
||||
this.icon(IconName::ArrowDown)
|
||||
})
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.show_transfers_dialog(window, cx);
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
Button::new("sftp-minimize-toggle")
|
||||
.ghost()
|
||||
.small()
|
||||
.icon(if self.sftp_panel_minimized {
|
||||
IconName::ChevronUp
|
||||
} else {
|
||||
IconName::ChevronDown
|
||||
})
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.toggle_sftp_minimized(window, cx);
|
||||
})),
|
||||
),
|
||||
);
|
||||
|
||||
panel.into_any_element()
|
||||
outer.into_any_element()
|
||||
}
|
||||
|
||||
fn render_monitoring_panel(
|
||||
@@ -1323,6 +1516,15 @@ impl Ashell {
|
||||
.child("Ashell"),
|
||||
)
|
||||
.child(div().flex_1())
|
||||
.child(
|
||||
Button::new("sidebar-collapse-toggle")
|
||||
.ghost()
|
||||
.icon(IconName::PanelLeftClose)
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
this.sidebar_collapsed = true;
|
||||
cx.notify();
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
Button::new("sidebar-settings")
|
||||
.ghost()
|
||||
@@ -1521,6 +1723,151 @@ impl Ashell {
|
||||
)
|
||||
}
|
||||
|
||||
fn render_collapsed_sidebar(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let sessions = self.config.sessions().to_vec();
|
||||
let active_session_id = self.active_session_id().map(ToOwned::to_owned);
|
||||
|
||||
v_flex()
|
||||
.w_full()
|
||||
.h_full()
|
||||
.min_w(px(0.))
|
||||
.p_2()
|
||||
.border_r_1()
|
||||
.border_color(cx.theme().sidebar_border)
|
||||
.bg(cx.theme().sidebar)
|
||||
.overflow_hidden()
|
||||
.items_center()
|
||||
// Top: expand button only
|
||||
.child(
|
||||
div()
|
||||
.w_full()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.pb_2()
|
||||
.child(
|
||||
Button::new("sidebar-expand-toggle")
|
||||
.ghost()
|
||||
.icon(IconName::PanelLeftOpen)
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
this.sidebar_collapsed = false;
|
||||
cx.notify();
|
||||
})),
|
||||
),
|
||||
)
|
||||
// Saved sessions as compact cards
|
||||
.child(
|
||||
div()
|
||||
.relative()
|
||||
.flex_1()
|
||||
.min_h(px(0.))
|
||||
.w_full()
|
||||
.child(
|
||||
v_flex()
|
||||
.size_full()
|
||||
.id("collapsed-saved-sessions-scroll")
|
||||
.track_scroll(&self.collapsed_saved_scroll_handle)
|
||||
.overflow_y_scroll()
|
||||
.gap_2()
|
||||
.items_center()
|
||||
.children(sessions.into_iter().enumerate().map(
|
||||
|(ix, session)| {
|
||||
let connect_id = session.id.clone();
|
||||
let is_active = active_session_id.as_deref()
|
||||
== Some(session.id.as_str());
|
||||
let name = session.name.clone();
|
||||
|
||||
// Abbreviate: first 1 char for CJK, first 2 chars for Latin
|
||||
let abbrev = {
|
||||
let mut chars = name.chars();
|
||||
if let Some(first) = chars.next() {
|
||||
if first > '\u{2E7F}' {
|
||||
// CJK character range — show 1 char
|
||||
first.to_string()
|
||||
} else {
|
||||
// Latin / ASCII — show first 2 chars
|
||||
let mut s = first.to_string();
|
||||
if let Some(second) = chars.next() {
|
||||
s.push(second);
|
||||
}
|
||||
s
|
||||
}
|
||||
} else {
|
||||
"?".to_string()
|
||||
}
|
||||
};
|
||||
|
||||
div()
|
||||
.id(("collapsed-saved", ix))
|
||||
.w(px(36.))
|
||||
.h(px(36.))
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.rounded_md()
|
||||
.border_1()
|
||||
.border_color(if is_active {
|
||||
cx.theme().primary
|
||||
} else {
|
||||
cx.theme().border
|
||||
})
|
||||
.bg(if is_active {
|
||||
cx.theme().tab_active
|
||||
} else {
|
||||
cx.theme().muted
|
||||
})
|
||||
.cursor_pointer()
|
||||
.hover(|this| this.bg(cx.theme().secondary))
|
||||
.on_mouse_down(
|
||||
MouseButton::Left,
|
||||
cx.listener(move |this, _, _, cx| {
|
||||
this.connect_saved_session(
|
||||
connect_id.clone(),
|
||||
cx,
|
||||
)
|
||||
}),
|
||||
)
|
||||
.tooltip({
|
||||
let tooltip_text = format!("{} {}", name, session.user);
|
||||
move |window, cx| {
|
||||
gpui_component::tooltip::Tooltip::new(tooltip_text.clone()).build(window, cx)
|
||||
}
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.text_size(rems(0.833))
|
||||
.font_weight(FontWeight::BOLD)
|
||||
.text_color(if is_active {
|
||||
cx.theme().primary
|
||||
} else {
|
||||
cx.theme().foreground
|
||||
})
|
||||
.child(abbrev),
|
||||
)
|
||||
},
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_0()
|
||||
.bottom_0()
|
||||
.left_0()
|
||||
.right_0()
|
||||
.child(
|
||||
gpui_component::scroll::Scrollbar::new(
|
||||
&self.collapsed_saved_scroll_handle,
|
||||
)
|
||||
.id("collapsed-saved-scrollbar")
|
||||
.axis(gpui_component::scroll::ScrollbarAxis::Vertical)
|
||||
.scrollbar_show(
|
||||
gpui_component::scroll::ScrollbarShow::Scrolling,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn render_tab_bar(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let active_tab_index = self
|
||||
.active_tab
|
||||
@@ -1858,8 +2205,7 @@ impl Ashell {
|
||||
.children(children.iter().enumerate().flat_map(|(i, child)| {
|
||||
let mut items: Vec<gpui::AnyElement> = Vec::new();
|
||||
if i > 0 {
|
||||
let mut splitter_path = path.to_vec();
|
||||
splitter_path.push(i - 1); // path to the pane BEFORE this splitter
|
||||
let splitter_path = path.to_vec(); // path to the CONTAINER that has the ratio
|
||||
items.push(
|
||||
div()
|
||||
.h(px(4.))
|
||||
@@ -1908,15 +2254,14 @@ impl Ashell {
|
||||
.size_full()
|
||||
.children(children.iter().enumerate().flat_map(|(i, child)| {
|
||||
let mut items: Vec<gpui::AnyElement> = Vec::new();
|
||||
if i > 0 {
|
||||
let mut splitter_path = path.to_vec();
|
||||
splitter_path.push(i - 1);
|
||||
items.push(
|
||||
div()
|
||||
.w(px(4.))
|
||||
.h_full()
|
||||
.flex_none()
|
||||
.cursor_col_resize()
|
||||
if i > 0 {
|
||||
let splitter_path = path.to_vec(); // path to the CONTAINER that has the ratio
|
||||
items.push(
|
||||
div()
|
||||
.w(px(4.))
|
||||
.h_full()
|
||||
.flex_none()
|
||||
.cursor_col_resize()
|
||||
.bg(cx.theme().border)
|
||||
.hover(|s| s.bg(cx.theme().accent))
|
||||
.on_mouse_down(
|
||||
@@ -1996,16 +2341,6 @@ impl Render for Ashell {
|
||||
}
|
||||
}
|
||||
|
||||
let sidebar_area = resizable_panel()
|
||||
.size(px(self
|
||||
.config
|
||||
.workspace_panels()
|
||||
.and_then(|s| s.first().copied())
|
||||
.unwrap_or(SIDEBAR_WIDTH)))
|
||||
.size_range(px(240.)..px(520.))
|
||||
.flex_none()
|
||||
.child(self.sidebar(cx));
|
||||
|
||||
let monitoring_contents = v_flex()
|
||||
.size_full()
|
||||
.when(self.config.monitoring_position() == "Bottom", |this| {
|
||||
@@ -2014,61 +2349,89 @@ impl Render for Ashell {
|
||||
.child(self.render_sftp_panel(window, cx));
|
||||
|
||||
let is_monitor_bottom = self.config.monitoring_position() == "Bottom";
|
||||
let minimized_height = if is_monitor_bottom { 114. } else { 34. };
|
||||
let minimized_height = if is_monitor_bottom { 104. } else { 24. };
|
||||
let min_panel_height = if is_monitor_bottom { 260. } else { 180. };
|
||||
let default_panel_height = if is_monitor_bottom { 328. } else { 248. };
|
||||
|
||||
let body_panel = if self.sftp_panel_minimized {
|
||||
v_flex()
|
||||
let sftp_size = if self.sftp_panel_minimized {
|
||||
px(minimized_height)
|
||||
} else {
|
||||
px(self
|
||||
.config
|
||||
.body_panels()
|
||||
.and_then(|s| s.get(1).copied())
|
||||
.unwrap_or(default_panel_height))
|
||||
};
|
||||
|
||||
let body_panel = v_resizable("ashell-body")
|
||||
.with_state(&self.body_panels)
|
||||
.child(resizable_panel().child(self.render_terminal_panel(cx)))
|
||||
.child(
|
||||
resizable_panel()
|
||||
.size(sftp_size)
|
||||
.size_range(
|
||||
if self.sftp_panel_minimized {
|
||||
px(minimized_height)..px(minimized_height)
|
||||
} else {
|
||||
px(min_panel_height)..px(1200.)
|
||||
},
|
||||
)
|
||||
.child(monitoring_contents),
|
||||
)
|
||||
.into_any_element();
|
||||
|
||||
let workspace = if self.sidebar_collapsed {
|
||||
h_flex()
|
||||
.size_full()
|
||||
.child(
|
||||
div().flex_1().min_h(px(0.)).child(
|
||||
v_resizable("ashell-body")
|
||||
.with_state(&self.body_panels)
|
||||
.child(resizable_panel().child(self.render_terminal_panel(cx))),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex_none()
|
||||
.h(px(minimized_height))
|
||||
.w_full()
|
||||
.border_t_1()
|
||||
.border_color(cx.theme().border)
|
||||
.child(monitoring_contents),
|
||||
.w(px(COLLAPSED_SIDEBAR_WIDTH))
|
||||
.h_full()
|
||||
.child(self.render_collapsed_sidebar(cx)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.h_full()
|
||||
.min_w(px(0.))
|
||||
.child(
|
||||
v_flex()
|
||||
.size_full()
|
||||
.relative()
|
||||
.overflow_hidden()
|
||||
.child(self.render_tab_bar(cx))
|
||||
.child(body_panel),
|
||||
),
|
||||
)
|
||||
.into_any_element()
|
||||
} else {
|
||||
v_resizable("ashell-body")
|
||||
.with_state(&self.body_panels)
|
||||
.child(resizable_panel().child(self.render_terminal_panel(cx)))
|
||||
.child(
|
||||
resizable_panel()
|
||||
.size(px(self
|
||||
.config
|
||||
.body_panels()
|
||||
.and_then(|s| s.get(1).copied())
|
||||
.unwrap_or(default_panel_height)))
|
||||
.size_range(px(min_panel_height)..px(1200.))
|
||||
.child(monitoring_contents),
|
||||
)
|
||||
let sidebar_area = resizable_panel()
|
||||
.size(px(self
|
||||
.config
|
||||
.workspace_panels()
|
||||
.and_then(|s| s.first().copied())
|
||||
.unwrap_or(SIDEBAR_WIDTH)))
|
||||
.size_range(px(240.)..px(520.))
|
||||
.flex_none()
|
||||
.child(self.sidebar(cx));
|
||||
|
||||
let main_area = resizable_panel().child(
|
||||
v_flex()
|
||||
.size_full()
|
||||
.relative()
|
||||
.overflow_hidden()
|
||||
.child(self.render_tab_bar(cx))
|
||||
.child(body_panel),
|
||||
);
|
||||
|
||||
h_resizable("ashell-workspace")
|
||||
.with_state(&self.workspace_panels)
|
||||
.child(sidebar_area)
|
||||
.child(main_area)
|
||||
.into_any_element()
|
||||
};
|
||||
|
||||
let main_area = resizable_panel().child(
|
||||
v_flex()
|
||||
.size_full()
|
||||
.relative()
|
||||
.overflow_hidden()
|
||||
.child(self.render_tab_bar(cx))
|
||||
.child(body_panel),
|
||||
);
|
||||
|
||||
let workspace = h_resizable("ashell-workspace")
|
||||
.with_state(&self.workspace_panels)
|
||||
.child(sidebar_area)
|
||||
.child(main_area);
|
||||
|
||||
div()
|
||||
.id("ashell-root")
|
||||
.size_full()
|
||||
@@ -2078,6 +2441,10 @@ impl Render for Ashell {
|
||||
.on_action(cx.listener(|this, _: &crate::OpenSettings, window, cx| this.show_settings_dialog(window, cx)))
|
||||
.on_action(cx.listener(|this, _: &crate::OpenSession, window, cx| this.show_selector_dialog(window, cx)))
|
||||
.on_action(cx.listener(|this, _: &crate::NewSsh, window, cx| this.show_ssh_dialog(window, cx)))
|
||||
.on_action(cx.listener(|this, _: &crate::ToggleSidebar, _, cx| {
|
||||
this.sidebar_collapsed = !this.sidebar_collapsed;
|
||||
cx.notify();
|
||||
}))
|
||||
.on_action(cx.listener(|this, _: &crate::ToggleSftpZoom, window, cx| {
|
||||
this.toggle_sftp_minimized(window, cx);
|
||||
}))
|
||||
|
||||
+3
-1
@@ -17,6 +17,7 @@ gpui::actions!(ashell_terminal, [TerminalTabKey, TerminalBacktabKey]);
|
||||
pub(crate) use app::keybinding_recorder::{
|
||||
ClosePane, FocusPaneDown, FocusPaneLeft, FocusPaneRight, FocusPaneUp, NewSsh, OpenSession,
|
||||
OpenSettings, SplitPaneDown, SplitPaneLeft, SplitPaneRight, SplitPaneUp, ToggleSftpZoom,
|
||||
ToggleSidebar,
|
||||
};
|
||||
|
||||
pub(crate) use app::{
|
||||
@@ -30,10 +31,11 @@ fn main() {
|
||||
#[cfg(target_os = "macos")]
|
||||
let app = gpui_platform::application()
|
||||
.with_assets(Assets)
|
||||
.with_quit_mode(gpui::QuitMode::Explicit);
|
||||
.with_quit_mode(gpui::QuitMode::LastWindowClosed);
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let app = gpui_platform::application().with_assets(Assets);
|
||||
|
||||
app.on_reopen(|cx| {
|
||||
if cx.windows().is_empty() {
|
||||
app::startup::open_main_window(cx);
|
||||
|
||||
Reference in New Issue
Block a user