mirror of
https://github.com/rust-kotlin/ashell.git
synced 2026-10-03 16:00:18 +00:00
Compare commits
14
Commits
v0.4.2
...
v0.4.5-fix2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caa8a58561 | ||
|
|
6150bd410b | ||
|
|
f55c3a8470 | ||
|
|
7ae44ab9a7 | ||
|
|
9c43b2dde7 | ||
|
|
e6134bc0d1 | ||
|
|
96cd85a8d3 | ||
|
|
f45c2ed60f | ||
|
|
8a8f280401 | ||
|
|
dc006f7144 | ||
|
|
daaebe4c2b | ||
|
|
2a37f45ba2 | ||
|
|
ee8c18844c | ||
|
|
c5b09628b3 |
@@ -12,7 +12,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write # needed to create / update the GitHub Release
|
||||
contents: write # needed to create / update the GitHub Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -26,15 +26,15 @@ jobs:
|
||||
target: x86_64-pc-windows-msvc
|
||||
name: windows-x86_64
|
||||
bin: ashell.exe
|
||||
- os: ubuntu-22.04 # build on the oldest supported runner for broader glibc compatibility
|
||||
- os: ubuntu-22.04 # build on the oldest supported runner for broader glibc compatibility
|
||||
target: x86_64-unknown-linux-gnu
|
||||
name: linux-x86_64
|
||||
bin: ashell
|
||||
- os: macos-14 # Apple Silicon
|
||||
- os: macos-14 # Apple Silicon
|
||||
target: aarch64-apple-darwin
|
||||
name: macos-aarch64
|
||||
bin: ashell
|
||||
- os: macos-14 # Intel (cross-compiled from Apple Silicon to avoid queue delays)
|
||||
- os: macos-14 # Intel (cross-compiled from Apple Silicon to avoid queue delays)
|
||||
target: x86_64-apple-darwin
|
||||
name: macos-x86_64
|
||||
bin: ashell
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
# Note: We build the bundle manually here rather than running
|
||||
# scripts/package-macos-app.sh, because that script runs `cargo build`
|
||||
# without respecting the `--target` flag from the matrix.
|
||||
|
||||
|
||||
APP="ashell.app"
|
||||
CONTENTS="$APP/Contents"
|
||||
mkdir -p "$CONTENTS/MacOS" "$CONTENTS/Resources"
|
||||
@@ -168,3 +168,84 @@ jobs:
|
||||
files: dist/**/*
|
||||
generate_release_notes: true
|
||||
fail_on_unmatched_files: true
|
||||
|
||||
cask:
|
||||
name: Update Homebrew Cask
|
||||
needs: publish
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Homebrew Tap
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: rust-kotlin/homebrew-taps
|
||||
token: ${{ secrets.TAP_GITHUB_TOKEN }}
|
||||
path: tap
|
||||
|
||||
- name: Download all macOS artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: macos-*
|
||||
path: dist
|
||||
|
||||
- name: Update Cask
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
SHA_ARM=$(sha256sum dist/macos-aarch64/*.zip | cut -d' ' -f1)
|
||||
SHA_INTEL=$(sha256sum dist/macos-x86_64/*.zip | cut -d' ' -f1)
|
||||
|
||||
mkdir -p tap/Casks
|
||||
CASK_FILE="tap/Casks/ashell.rb"
|
||||
|
||||
cat > "$CASK_FILE" <<EOF
|
||||
cask "ashell" do
|
||||
version "${VERSION}"
|
||||
|
||||
on_arm do
|
||||
sha256 "${SHA_ARM}"
|
||||
url "https://github.com/rust-kotlin/ashell/releases/download/v#{version}/ashell-v#{version}-macos-aarch64.zip"
|
||||
end
|
||||
on_intel do
|
||||
sha256 "${SHA_INTEL}"
|
||||
url "https://github.com/rust-kotlin/ashell/releases/download/v#{version}/ashell-v#{version}-macos-x86_64.zip"
|
||||
end
|
||||
|
||||
name "ashell"
|
||||
desc "ashell is a modern, fast, GPUI Component-based desktop terminal client written in Rust."
|
||||
homepage "https://github.com/rust-kotlin/ashell"
|
||||
|
||||
app "ashell.app"
|
||||
|
||||
postflight do
|
||||
puts "Removing quarantine flag from ashell.app..."
|
||||
system_command "/usr/bin/xattr",
|
||||
args: ["-rd", "com.apple.quarantine", "#{appdir}/ashell.app"],
|
||||
sudo: true
|
||||
end
|
||||
|
||||
caveats <<~EOS
|
||||
ashell uses ad-hoc signing. The installation includes a postflight script
|
||||
that removes the 'com.apple.quarantine' attribute from the application
|
||||
to allow it to run. This will require your administrator password.
|
||||
|
||||
ashell 采用本地签名。安装程序包含一个后置脚本,用于移除应用程序的
|
||||
'com.apple.quarantine' 属性以允许其运行。这需要您的管理员密码。
|
||||
EOS
|
||||
end
|
||||
EOF
|
||||
# Remove the 10 leading spaces added for YAML formatting
|
||||
sed -i 's/^ //' "$CASK_FILE"
|
||||
|
||||
- name: Commit and Push
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
cd tap
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
if [[ -n $(git status -s) ]]; then
|
||||
git add Casks/ashell.rb
|
||||
git commit -m "chore: bump ashell to v${VERSION}"
|
||||
git push
|
||||
else
|
||||
echo "No changes to commit"
|
||||
fi
|
||||
|
||||
Generated
+1
-1
@@ -303,7 +303,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ashell"
|
||||
version = "0.4.2"
|
||||
version = "0.4.5"
|
||||
dependencies = [
|
||||
"alacritty_terminal",
|
||||
"anyhow",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ashell"
|
||||
version = "0.4.2"
|
||||
version = "0.4.5"
|
||||
edition = "2024"
|
||||
authors = ["ashell contributors"]
|
||||
description = "A GPUI Component based SSH and local terminal client"
|
||||
|
||||
+22
-2
@@ -24,8 +24,28 @@ You can download the latest pre-compiled releases for macOS, Windows, and Linux
|
||||
|
||||
## Mac Installation Guide
|
||||
|
||||
After downloading, please unzip the file and move `ashell.app` to your **Applications** folder.
|
||||
Since the app uses ad-hoc signing, macOS may warn that the app is "damaged" upon first launch. If this happens, open Terminal and run the following command:
|
||||
### Method 1: Homebrew (Recommended)
|
||||
|
||||
If you use [Homebrew](https://brew.sh/), you can install it quickly with:
|
||||
|
||||
```bash
|
||||
brew install rust-kotlin/taps/ashell --cask
|
||||
```
|
||||
|
||||
To update the app:
|
||||
|
||||
```bash
|
||||
brew update
|
||||
brew upgrade ashell --cask
|
||||
```
|
||||
|
||||
> **Note**: Since the app uses ad-hoc signing, the Homebrew installation or update includes a postflight script to automatically handle the quarantine flag. This will require you to enter your administrator password for authorization.
|
||||
|
||||
### Method 2: Manual Download
|
||||
|
||||
1. Download and unzip from the [Releases page](https://github.com/rust-kotlin/ashell/releases/latest).
|
||||
2. Move `ashell.app` to your **Applications** folder.
|
||||
3. Since the app uses ad-hoc signing, macOS may warn that the app is "damaged" upon first launch. If this happens, open Terminal and run:
|
||||
|
||||
```bash
|
||||
sudo xattr -cr /Applications/ashell.app
|
||||
|
||||
@@ -24,8 +24,28 @@ v0.4 在 v0.3 打下的基础上,重点带来了更完整的工作区操作能
|
||||
|
||||
## Mac 安装指南
|
||||
|
||||
下载并解压后,请先将 `ashell.app` 拖入或移动到 **应用程序 (Applications)** 目录。
|
||||
由于应用采用本地签名,初次启动时如果系统提示“App 已损坏,无法打开”,请打开终端(Terminal)并执行以下命令:
|
||||
### 方法 1: Homebrew 安装 (推荐)
|
||||
|
||||
如果您使用 [Homebrew](https://brew.sh/),可以通过以下命令快速安装:
|
||||
|
||||
```bash
|
||||
brew install rust-kotlin/taps/ashell --cask
|
||||
```
|
||||
|
||||
更新应用:
|
||||
|
||||
```bash
|
||||
brew update
|
||||
brew upgrade ashell --cask
|
||||
```
|
||||
|
||||
> **注意**: 由于应用采用本地签名,Homebrew 在安装或更新过程中会执行一个后置脚本来自动处理隔离属性(quarantine flag),这需要您输入管理员密码以授权。
|
||||
|
||||
### 方法 2: 手动下载
|
||||
|
||||
1. 从 [Releases 页面](https://github.com/rust-kotlin/ashell/releases/latest) 下载并解压。
|
||||
2. 将 `ashell.app` 拖入或移动到 **应用程序 (Applications)** 目录。
|
||||
3. 由于应用采用本地签名,初次启动时如果系统提示“App 已损坏,无法打开”,请打开终端(Terminal)并执行以下命令:
|
||||
|
||||
```bash
|
||||
sudo xattr -cr /Applications/ashell.app
|
||||
|
||||
@@ -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"
|
||||
@@ -132,7 +136,13 @@ transfers_limit: " (Max 100 records)"
|
||||
press_new_key: "Press new key..."
|
||||
settings_open_settings: "Open Settings"
|
||||
settings_open_session: "Open Session"
|
||||
settings_open_transfers: "Open Transfer History"
|
||||
files_downloading: "%{count} files downloading"
|
||||
files_uploading: "%{count} files uploading"
|
||||
panel_minimize: "Minimize Panel"
|
||||
panel_expand: "Expand Panel"
|
||||
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"
|
||||
|
||||
+11
-2
@@ -23,7 +23,6 @@ system_path_warning: "警告:您即将删除系统关键路径!这可能会
|
||||
delete_success: "成功删除 %{count} 个项"
|
||||
delete_failed: "删除失败: %{err}"
|
||||
deleting_paths: "正在删除 %{count} 个项..."
|
||||
cancel: "取消"
|
||||
confirm: "确认"
|
||||
local_terminal: "本地终端"
|
||||
open_local_shell_tab: "打开一个新的本地终端页面"
|
||||
@@ -127,6 +126,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: "清空记录"
|
||||
@@ -135,7 +138,13 @@ transfers_limit: " (最多保留 100 条)"
|
||||
press_new_key: "请按下新的快捷键..."
|
||||
settings_open_settings: "打开设置"
|
||||
settings_open_session: "打开会话"
|
||||
settings_open_transfers: "打开传输历史"
|
||||
files_downloading: "%{count} 个文件正在下载"
|
||||
files_uploading: "%{count} 个文件正在上传"
|
||||
panel_minimize: "折叠面板"
|
||||
panel_expand: "展开面板"
|
||||
settings_new_ssh: "新建 SSH"
|
||||
settings_toggle_sidebar: "缩放侧边栏"
|
||||
settings_toggle_sftp_zoom: "缩放 SFTP 面板"
|
||||
settings_focus_pane_left: "向左切换焦点"
|
||||
settings_focus_pane_right: "向右切换焦点"
|
||||
@@ -146,4 +155,4 @@ settings_split_pane_right: "向右拆分面板"
|
||||
settings_split_pane_up: "向上拆分面板"
|
||||
settings_split_pane_down: "向下拆分面板"
|
||||
settings_close_pane: "关闭当前面板"
|
||||
keybind_conflict: "\"%{key}\" 已被「%{action}」使用,请选择其他快捷键"
|
||||
keybind_conflict: '"%{key}" 已被「%{action}」使用,请选择其他快捷键'
|
||||
|
||||
@@ -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;
|
||||
|
||||
+75
-8
@@ -21,6 +21,11 @@ use crate::{Ashell, session::config::AuthMethod, system::format_bytes};
|
||||
|
||||
impl Ashell {
|
||||
pub(crate) fn show_ssh_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.active_dialog.is_some() {
|
||||
return;
|
||||
}
|
||||
self.active_dialog = Some(crate::app::DialogKind::NewSsh);
|
||||
|
||||
let view = cx.entity();
|
||||
let session_name_input = self.session_name_input.clone();
|
||||
let host_input = self.host_input.clone();
|
||||
@@ -37,6 +42,15 @@ impl Ashell {
|
||||
.title(t!("new_ssh_connection"))
|
||||
.w(px(520.))
|
||||
.overlay_closable(true)
|
||||
.on_close({
|
||||
let view = view.clone();
|
||||
move |_, _, cx| {
|
||||
view.update(cx, |this, cx| {
|
||||
this.active_dialog = None;
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
})
|
||||
.content({
|
||||
let view = view.clone();
|
||||
let session_name_input = session_name_input.clone();
|
||||
@@ -146,7 +160,11 @@ impl Ashell {
|
||||
.child(
|
||||
Button::new("connect-ssh-cancel")
|
||||
.label(t!("cancel").to_string())
|
||||
.on_click(|_, window, cx| window.close_dialog(cx)),
|
||||
.on_click(window.listener_for(&view, |this, _, window, cx| {
|
||||
this.active_dialog = None;
|
||||
window.close_dialog(cx);
|
||||
cx.notify();
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
Button::new("connect-ssh-confirm")
|
||||
@@ -173,6 +191,11 @@ impl Ashell {
|
||||
});
|
||||
}
|
||||
pub(crate) fn show_selector_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.active_dialog.is_some() {
|
||||
return;
|
||||
}
|
||||
self.active_dialog = Some(crate::app::DialogKind::SessionSelector);
|
||||
|
||||
let view = cx.entity();
|
||||
let selector_focus_handle = self.selector_focus_handle.clone();
|
||||
let deferred_selector_focus_handle = selector_focus_handle.clone();
|
||||
@@ -183,6 +206,15 @@ impl Ashell {
|
||||
dialog
|
||||
.title(t!("open_session").to_string())
|
||||
.w(px(520.))
|
||||
.on_close({
|
||||
let view = view.clone();
|
||||
move |_, _, cx| {
|
||||
view.update(cx, |this, cx| {
|
||||
this.active_dialog = None;
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
})
|
||||
.on_ok({
|
||||
let view = view.clone();
|
||||
move |_, window, cx| {
|
||||
@@ -231,8 +263,10 @@ impl Ashell {
|
||||
.on_mouse_down(
|
||||
MouseButton::Left,
|
||||
window.listener_for(&view, |this, _, window, cx| {
|
||||
this.active_dialog = None;
|
||||
this.open_local(cx);
|
||||
window.close_dialog(cx);
|
||||
cx.notify();
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
@@ -273,8 +307,10 @@ impl Ashell {
|
||||
.on_mouse_down(
|
||||
MouseButton::Left,
|
||||
window.listener_for(&view, |this, _, window, cx| {
|
||||
this.active_dialog = None;
|
||||
window.close_dialog(cx);
|
||||
this.open_new_ssh_dialog(window, cx);
|
||||
cx.notify();
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
@@ -342,11 +378,13 @@ impl Ashell {
|
||||
window.listener_for(
|
||||
&view,
|
||||
move |this, _, window, cx| {
|
||||
this.active_dialog = None;
|
||||
this.connect_saved_session(
|
||||
connect_id.clone(),
|
||||
cx,
|
||||
);
|
||||
window.close_dialog(cx);
|
||||
cx.notify();
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -405,9 +443,26 @@ impl Ashell {
|
||||
});
|
||||
}
|
||||
pub(crate) fn show_transfers_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.active_dialog.is_some() {
|
||||
return;
|
||||
}
|
||||
self.active_dialog = Some(crate::app::DialogKind::Transfers);
|
||||
|
||||
let view = cx.entity();
|
||||
window.open_dialog(cx, move |dialog: Dialog, _window, _| {
|
||||
dialog.w(px(600.)).close_button(false).content({
|
||||
dialog
|
||||
.w(px(600.))
|
||||
.close_button(false)
|
||||
.on_close({
|
||||
let view = view.clone();
|
||||
move |_, _, cx| {
|
||||
view.update(cx, |this, cx| {
|
||||
this.active_dialog = None;
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
})
|
||||
.content({
|
||||
let view = view.clone();
|
||||
move |content, window, cx| {
|
||||
let can_clear = view.read(cx).transfers.iter().any(|t| {
|
||||
@@ -468,9 +523,11 @@ impl Ashell {
|
||||
.small()
|
||||
.ghost()
|
||||
.icon(IconName::Close)
|
||||
.on_click(|_, window, cx| {
|
||||
.on_click(window.listener_for(&view, |this, _, window, cx| {
|
||||
this.active_dialog = None;
|
||||
window.close_dialog(cx);
|
||||
}),
|
||||
cx.notify();
|
||||
})),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -997,6 +1054,11 @@ impl Ashell {
|
||||
});
|
||||
}
|
||||
pub(crate) fn show_settings_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.active_dialog.is_some() {
|
||||
return;
|
||||
}
|
||||
self.active_dialog = Some(crate::app::DialogKind::Settings);
|
||||
|
||||
let view = cx.entity();
|
||||
|
||||
// Unbind all workspace keys so they don't interfere with keybinding recording
|
||||
@@ -1013,6 +1075,7 @@ impl Ashell {
|
||||
move |_, _window, cx| {
|
||||
// Re-register all workspace keys when closing settings
|
||||
view.update(cx, |this, cx| {
|
||||
this.active_dialog = None;
|
||||
this.keybinds_suspended = false;
|
||||
this.recording_action = None;
|
||||
this.keybind_error = None;
|
||||
@@ -1541,11 +1604,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)
|
||||
|
||||
+115
-58
@@ -16,7 +16,9 @@ gpui::actions!(
|
||||
[
|
||||
OpenSettings,
|
||||
OpenSession,
|
||||
OpenTransfers,
|
||||
NewSsh,
|
||||
ToggleSidebar,
|
||||
ToggleSftpZoom,
|
||||
FocusPaneLeft,
|
||||
FocusPaneRight,
|
||||
@@ -50,11 +52,21 @@ pub(crate) const WORKSPACE_ACTIONS: &[WorkspaceAction] = &[
|
||||
label_key: "settings_open_session",
|
||||
default_suffix: "o",
|
||||
},
|
||||
WorkspaceAction {
|
||||
id: "OpenTransfers",
|
||||
label_key: "settings_open_transfers",
|
||||
default_suffix: "t",
|
||||
},
|
||||
WorkspaceAction {
|
||||
id: "NewSsh",
|
||||
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",
|
||||
@@ -192,7 +204,9 @@ pub(crate) fn unbind_all_workspace_keys(cx: &mut App, config: &ConfigStore) {
|
||||
|
||||
unbind_action!("OpenSettings", crate::OpenSettings);
|
||||
unbind_action!("OpenSession", crate::OpenSession);
|
||||
unbind_action!("OpenTransfers", crate::OpenTransfers);
|
||||
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);
|
||||
@@ -245,7 +259,9 @@ fn bind_workspace_actions(cx: &mut App, config: &ConfigStore) {
|
||||
|
||||
bind_action!("OpenSettings", crate::OpenSettings);
|
||||
bind_action!("OpenSession", crate::OpenSession);
|
||||
bind_action!("OpenTransfers", crate::OpenTransfers);
|
||||
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 +277,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", "OpenTransfers", "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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,14 @@ impl ScrollbarHandle for TerminalScrollbarHandle {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(crate) enum DialogKind {
|
||||
Settings,
|
||||
SessionSelector,
|
||||
Transfers,
|
||||
NewSsh,
|
||||
}
|
||||
|
||||
pub(crate) struct Ashell {
|
||||
pub(crate) focus_handle: FocusHandle,
|
||||
pub(crate) selector_focus_handle: FocusHandle,
|
||||
@@ -245,11 +253,14 @@ 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,
|
||||
pub(crate) system_sampler: SystemSampler,
|
||||
pub(crate) recording_action: Option<String>,
|
||||
pub(crate) active_dialog: Option<DialogKind>,
|
||||
/// Error message when a recorded keybinding conflicts with another
|
||||
pub(crate) keybind_error: Option<(String, String)>, // (action_id, error_message)
|
||||
/// Whether workspace keybindings are currently suspended (during settings)
|
||||
@@ -467,11 +478,14 @@ impl Ashell {
|
||||
dragging_splitter: None,
|
||||
drag_split_origin: None,
|
||||
sftp_panel_minimized: false,
|
||||
sidebar_collapsed: config.sidebar_collapsed(),
|
||||
collapsed_saved_scroll_handle: gpui::ScrollHandle::new(),
|
||||
prev_monitoring_size: None,
|
||||
status: "ready".into(),
|
||||
config,
|
||||
system_sampler,
|
||||
recording_action: None,
|
||||
active_dialog: None,
|
||||
keybind_error: None,
|
||||
keybinds_suspended: false,
|
||||
system,
|
||||
|
||||
+26
-1
@@ -239,6 +239,20 @@ pub(crate) fn open_main_window(cx: &mut App) {
|
||||
let view = cx.new(|cx| Ashell::new(window, cx));
|
||||
|
||||
tracing::info!("[ui] main application window opened");
|
||||
let focus_handle = view.read(cx).focus_handle.clone();
|
||||
window.focus(&focus_handle, cx);
|
||||
|
||||
let sftp_minimized = view.read(cx).config.sftp_panel_minimized();
|
||||
if sftp_minimized {
|
||||
window.defer(cx, {
|
||||
let view = view.clone();
|
||||
move |window, cx| {
|
||||
view.update(cx, |this, cx| {
|
||||
this.toggle_sftp_minimized(window, cx);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let workspace_panels_clone = view.read(cx).workspace_panels.clone();
|
||||
let body_panels_clone = view.read(cx).body_panels.clone();
|
||||
@@ -283,13 +297,24 @@ pub(crate) fn open_main_window(cx: &mut App) {
|
||||
.iter()
|
||||
.map(|s| s.into())
|
||||
.collect();
|
||||
let body_sizes: Vec<f32> = body_panels_clone
|
||||
let mut body_sizes: Vec<f32> = body_panels_clone
|
||||
.read(cx)
|
||||
.sizes()
|
||||
.iter()
|
||||
.map(|s| s.into())
|
||||
.collect();
|
||||
|
||||
if view_clone.read(cx).sftp_panel_minimized {
|
||||
if let Some(prev) = view_clone.read(cx).prev_monitoring_size {
|
||||
if body_sizes.len() > 1 {
|
||||
body_sizes[1] = prev.into();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.set_layout_state(Some(saved_bounds), Some(workspace_sizes), Some(body_sizes));
|
||||
config.set_sidebar_collapsed(view_clone.read(cx).sidebar_collapsed);
|
||||
config.set_sftp_panel_minimized(view_clone.read(cx).sftp_panel_minimized);
|
||||
let _ = config.save();
|
||||
true
|
||||
});
|
||||
|
||||
+540
-145
@@ -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,
|
||||
@@ -108,6 +108,9 @@ impl Ashell {
|
||||
},
|
||||
);
|
||||
}
|
||||
self.config
|
||||
.set_sftp_panel_minimized(self.sftp_panel_minimized);
|
||||
let _ = self.config.save();
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
@@ -118,9 +121,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 => {
|
||||
t!("files_downloading", count = active.len()).to_string()
|
||||
}
|
||||
crate::terminal::TransferType::Upload => {
|
||||
t!("files_uploading", count = active.len()).to_string()
|
||||
}
|
||||
};
|
||||
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 +285,131 @@ 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)
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.show_transfers_dialog(window, cx);
|
||||
}))
|
||||
})
|
||||
.when(!has_transfers, |this| {
|
||||
this.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
|
||||
})
|
||||
.label(if self.sftp_panel_minimized {
|
||||
t!("panel_expand").to_string()
|
||||
} else {
|
||||
t!("panel_minimize").to_string()
|
||||
})
|
||||
.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 +431,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 +445,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 +717,116 @@ 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)
|
||||
.label(t!("transfers").to_string())
|
||||
})
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.show_transfers_dialog(window, cx);
|
||||
})),
|
||||
|
||||
panel.into_any_element()
|
||||
)
|
||||
|
||||
.child(
|
||||
Button::new("sftp-minimize-toggle")
|
||||
.ghost()
|
||||
.small()
|
||||
.icon(if self.sftp_panel_minimized {
|
||||
IconName::ChevronUp
|
||||
} else {
|
||||
IconName::ChevronDown
|
||||
})
|
||||
.label(if self.sftp_panel_minimized {
|
||||
t!("panel_expand").to_string()
|
||||
} else {
|
||||
t!("panel_minimize").to_string()
|
||||
})
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.toggle_sftp_minimized(window, cx);
|
||||
})),
|
||||
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
outer.into_any_element()
|
||||
}
|
||||
|
||||
fn render_monitoring_panel(
|
||||
@@ -1323,6 +1537,17 @@ 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;
|
||||
this.config.set_sidebar_collapsed(true);
|
||||
let _ = this.config.save();
|
||||
cx.notify();
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
Button::new("sidebar-settings")
|
||||
.ghost()
|
||||
@@ -1521,6 +1746,153 @@ 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;
|
||||
this.config.set_sidebar_collapsed(false);
|
||||
let _ = this.config.save();
|
||||
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 +2230,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 +2279,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 +2366,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 +2374,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()
|
||||
@@ -2077,7 +2465,14 @@ impl Render for Ashell {
|
||||
.font_family(self.ui_font_family.clone())
|
||||
.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::OpenTransfers, window, cx| this.show_transfers_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;
|
||||
this.config.set_sidebar_collapsed(this.sidebar_collapsed);
|
||||
let _ = this.config.save();
|
||||
cx.notify();
|
||||
}))
|
||||
.on_action(cx.listener(|this, _: &crate::ToggleSftpZoom, window, cx| {
|
||||
this.toggle_sftp_minimized(window, cx);
|
||||
}))
|
||||
|
||||
+4
-2
@@ -16,7 +16,8 @@ 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,
|
||||
OpenSettings, OpenTransfers, 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);
|
||||
|
||||
@@ -135,6 +135,10 @@ pub struct ConfigFile {
|
||||
#[serde(default = "default_monitoring_position")]
|
||||
pub monitoring_position: String,
|
||||
#[serde(default)]
|
||||
pub sidebar_collapsed: bool,
|
||||
#[serde(default)]
|
||||
pub sftp_panel_minimized: bool,
|
||||
#[serde(default)]
|
||||
pub key_bindings: std::collections::HashMap<String, String>,
|
||||
}
|
||||
|
||||
@@ -410,6 +414,22 @@ impl ConfigStore {
|
||||
self.cache.show_hidden_files = val;
|
||||
}
|
||||
|
||||
pub fn sidebar_collapsed(&self) -> bool {
|
||||
self.cache.sidebar_collapsed
|
||||
}
|
||||
|
||||
pub fn set_sidebar_collapsed(&mut self, val: bool) {
|
||||
self.cache.sidebar_collapsed = val;
|
||||
}
|
||||
|
||||
pub fn sftp_panel_minimized(&self) -> bool {
|
||||
self.cache.sftp_panel_minimized
|
||||
}
|
||||
|
||||
pub fn set_sftp_panel_minimized(&mut self, val: bool) {
|
||||
self.cache.sftp_panel_minimized = val;
|
||||
}
|
||||
|
||||
pub fn get(&self, id: &str) -> Option<&Session> {
|
||||
self.cache.sessions.iter().find(|s| s.id == id)
|
||||
}
|
||||
|
||||
@@ -113,7 +113,9 @@ impl Ashell {
|
||||
|
||||
self.open_ssh_session(session, cx);
|
||||
self.editing_session_id = None;
|
||||
self.active_dialog = None;
|
||||
window.close_dialog(cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub(crate) fn set_input_value(
|
||||
@@ -368,6 +370,7 @@ impl Ashell {
|
||||
return;
|
||||
};
|
||||
|
||||
self.active_dialog = None;
|
||||
match entry {
|
||||
SelectorEntry::Local => {
|
||||
self.open_local(cx);
|
||||
@@ -382,6 +385,7 @@ impl Ashell {
|
||||
window.close_dialog(cx);
|
||||
}
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub(crate) fn on_selector_key_down(
|
||||
|
||||
Reference in New Issue
Block a user