mirror of
https://github.com/rust-kotlin/ashell.git
synced 2026-10-03 16:00:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
108a9cf95b | ||
|
|
9885b2573a | ||
|
|
cdf4cc3d53 | ||
|
|
5b381045f9 | ||
|
|
f246c952a2 | ||
|
|
2276eef191 | ||
|
|
bb39626173 | ||
|
|
2cb8ab50aa | ||
|
|
785670c428 | ||
|
|
d33babe552 | ||
|
|
985f88fb1a | ||
|
|
8deafbfe4e | ||
|
|
efc57560d8 | ||
|
|
a7428bd47c | ||
|
|
a44bbe1580 | ||
|
|
56030a0e77 | ||
|
|
56b41d625a |
@@ -0,0 +1,159 @@
|
||||
name: Release
|
||||
|
||||
# Build native binaries for Windows / Linux / macOS.
|
||||
# - Push a tag like `v0.2.3` -> builds all platforms and attaches the archives
|
||||
# to a GitHub Release.
|
||||
# - Run manually (workflow_dispatch) -> builds all platforms and uploads them as
|
||||
# downloadable workflow artifacts (no release created).
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write # needed to create / update the GitHub Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
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
|
||||
target: x86_64-unknown-linux-gnu
|
||||
name: linux-x86_64
|
||||
bin: ashell
|
||||
- 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)
|
||||
target: x86_64-apple-darwin
|
||||
name: macos-x86_64
|
||||
bin: ashell
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# GPUI needs these system libs on Linux to compile.
|
||||
- name: Install Linux GUI dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
build-essential pkg-config cmake \
|
||||
libfontconfig1-dev libfreetype6-dev \
|
||||
libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
|
||||
libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev \
|
||||
libgl1-mesa-dev libegl1-mesa-dev libgtk-3-dev \
|
||||
libudev-dev
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Cache cargo build
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: ${{ matrix.target }}
|
||||
|
||||
- name: Build (release)
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Package
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
VERSION="${GITHUB_REF_NAME:-dev}"
|
||||
STAGE="ashell-${VERSION}-${{ matrix.name }}"
|
||||
|
||||
if [ "${{ runner.os }}" = "macOS" ]; then
|
||||
# ── Build a proper .app bundle ────────────────────────────────────
|
||||
# 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"
|
||||
|
||||
cp "target/${{ matrix.target }}/release/ashell" "$CONTENTS/MacOS/"
|
||||
cp "assets/icons/ashell.icns" "$CONTENTS/Resources/ashell.icns"
|
||||
|
||||
VERSION_NUM="${VERSION#v}"
|
||||
cat > "$CONTENTS/Info.plist" <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>ashell</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>ashell.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>dev.ashell.app</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>ashell</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${VERSION_NUM}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
printf 'APPL????' > "$CONTENTS/PkgInfo"
|
||||
|
||||
# Ad-hoc code-sign the assembled bundle.
|
||||
codesign --force --deep --sign - "$APP"
|
||||
codesign --verify --verbose "$APP"
|
||||
|
||||
# Package with ditto (Apple's tool) to preserve signature/metadata
|
||||
ditto -c -k --keepParent "$APP" "${STAGE}.zip"
|
||||
echo "ASSET=${STAGE}.zip" >> "$GITHUB_ENV"
|
||||
|
||||
elif [ "${{ runner.os }}" = "Windows" ]; then
|
||||
mkdir "$STAGE"
|
||||
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$STAGE/"
|
||||
7z a "${STAGE}.zip" "$STAGE" >/dev/null
|
||||
echo "ASSET=${STAGE}.zip" >> "$GITHUB_ENV"
|
||||
|
||||
else
|
||||
# Linux
|
||||
mkdir "$STAGE"
|
||||
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$STAGE/"
|
||||
tar -czf "${STAGE}.tar.gz" "$STAGE"
|
||||
echo "ASSET=${STAGE}.tar.gz" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Upload workflow artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.name }}
|
||||
path: ${{ env.ASSET }}
|
||||
|
||||
- name: Attach to GitHub Release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ${{ env.ASSET }}
|
||||
fail_on_unmatched_files: true
|
||||
Generated
+95
-19
@@ -1,6 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "accesskit"
|
||||
@@ -296,15 +296,18 @@ dependencies = [
|
||||
"gpui-component",
|
||||
"gpui-component-assets",
|
||||
"gpui_platform",
|
||||
"image",
|
||||
"menu",
|
||||
"portable-pty",
|
||||
"rfd",
|
||||
"russh",
|
||||
"russh-keys",
|
||||
"russh-sftp",
|
||||
"rust-i18n 3.1.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"ssh-key",
|
||||
"sys-locale",
|
||||
"sysinfo 0.33.1",
|
||||
"tar",
|
||||
"thiserror 1.0.69",
|
||||
@@ -313,6 +316,7 @@ dependencies = [
|
||||
"tracing-subscriber",
|
||||
"uuid",
|
||||
"walkdir",
|
||||
"winres",
|
||||
"zip",
|
||||
]
|
||||
|
||||
@@ -753,7 +757,7 @@ dependencies = [
|
||||
"bitflags 2.12.1",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools 0.11.0",
|
||||
"itertools 0.13.0",
|
||||
"log",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
@@ -1682,7 +1686,7 @@ dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users 0.5.2",
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1942,7 +1946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2563,7 +2567,7 @@ dependencies = [
|
||||
"log",
|
||||
"presser",
|
||||
"thiserror 2.0.18",
|
||||
"windows 0.58.0",
|
||||
"windows 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2697,7 +2701,7 @@ dependencies = [
|
||||
"paste",
|
||||
"regex",
|
||||
"ropey",
|
||||
"rust-i18n",
|
||||
"rust-i18n 4.1.0",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -3258,7 +3262,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core 0.58.0",
|
||||
"windows-core 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4122,7 +4126,7 @@ version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08"
|
||||
dependencies = [
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4308,7 +4312,7 @@ version = "0.50.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||
dependencies = [
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5984,6 +5988,20 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n"
|
||||
version = "3.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fda2551fdfaf6cc5ee283adc15e157047b92ae6535cf80f6d4962d05717dc332"
|
||||
dependencies = [
|
||||
"globwalk",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"rust-i18n-macro 3.1.5",
|
||||
"rust-i18n-support 3.1.5",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n"
|
||||
version = "4.1.0"
|
||||
@@ -5992,11 +6010,28 @@ checksum = "55691a65892c33ee2de49c15ea5600c6f4a70e8eeb8e6c3cd96d2a231d230c40"
|
||||
dependencies = [
|
||||
"globwalk",
|
||||
"regex",
|
||||
"rust-i18n-macro",
|
||||
"rust-i18n-support",
|
||||
"rust-i18n-macro 4.1.0",
|
||||
"rust-i18n-support 4.1.0",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-macro"
|
||||
version = "3.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22baf7d7f56656d23ebe24f6bb57a5d40d2bce2a5f1c503e692b5b2fa450f965"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rust-i18n-support 3.1.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-macro"
|
||||
version = "4.1.0"
|
||||
@@ -6006,13 +6041,36 @@ dependencies = [
|
||||
"glob",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rust-i18n-support",
|
||||
"rust-i18n-support 4.1.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-support"
|
||||
version = "3.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "940ed4f52bba4c0152056d771e563b7133ad9607d4384af016a134b58d758f19"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"base62",
|
||||
"globwalk",
|
||||
"itertools 0.11.0",
|
||||
"lazy_static",
|
||||
"normpath",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"siphasher",
|
||||
"toml 0.8.23",
|
||||
"triomphe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-support"
|
||||
version = "4.1.0"
|
||||
@@ -6069,7 +6127,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6082,7 +6140,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6737,7 +6795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6845,7 +6903,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"psm",
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7205,7 +7263,7 @@ dependencies = [
|
||||
"getrandom 0.4.2",
|
||||
"once_cell",
|
||||
"rustix 1.1.4",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7425,6 +7483,15 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.23"
|
||||
@@ -7682,7 +7749,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
|
||||
dependencies = [
|
||||
"memoffset 0.9.1",
|
||||
"tempfile",
|
||||
"windows-sys 0.60.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -8442,7 +8509,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9079,6 +9146,15 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winres"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
|
||||
dependencies = [
|
||||
"toml 0.5.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winsafe"
|
||||
version = "0.0.19"
|
||||
|
||||
@@ -24,6 +24,8 @@ rfd = "0.15"
|
||||
russh = "0.49"
|
||||
russh-keys = "0.49"
|
||||
russh-sftp = "2"
|
||||
rust-i18n = "3"
|
||||
sys-locale = "0.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
ssh-key = "0.6"
|
||||
@@ -36,9 +38,13 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
uuid = { version = "1", features = ["v4", "serde"] }
|
||||
walkdir = "2"
|
||||
zip = { version = "2", default-features = false, features = ["deflate"] }
|
||||
image = { version = "0.25.9", default-features = false, features = ["png"] }
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
lto = "thin"
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
|
||||
[build-dependencies]
|
||||
winres = "0.1.12"
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
[中文](README.md) | [English](README.en.md)
|
||||
|
||||
# ashell
|
||||
|
||||

|
||||
|
||||
`ashell` is a modern, GPUI Component-based desktop terminal client written in Rust.
|
||||
|
||||
This project focuses on providing a high-performance and visually appealing shell workspace by combining local and remote environments with a rich set of built-in features.
|
||||
|
||||
## Download
|
||||
|
||||
You can download the latest pre-compiled releases for macOS, Windows, and Linux from the [GitHub Releases page](https://github.com/rust-kotlin/ashell/releases/latest).
|
||||
|
||||
## 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:
|
||||
|
||||
```bash
|
||||
sudo xattr -cr /Applications/ashell.app
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
The current version provides a fully-featured GPUI-native workspace:
|
||||
|
||||
- **Local & Remote Sessions:** Open local terminal tabs or connect to remote servers via SSH.
|
||||
- **Advanced SSH Authentication:** Supports both password-based and key-based (file path or inline) SSH connections.
|
||||
- **Session Management:** Easily save, reopen, edit, and remove your SSH sessions.
|
||||
- **SFTP Integration:** Built-in SFTP file manager to browse, upload, download, and manage remote files.
|
||||
- **Robust Terminal Emulator:** Parses terminal output with `alacritty_terminal`, supporting rich ANSI color spans, fast rendering, and complete keyboard input forwarding.
|
||||
- **System Telemetry:** Real-time visualization of CPU, memory, swap, network, and disk metrics in the left cockpit sidebar.
|
||||
- **Theming System:** Switch between multiple GPUI Component themes directly from the top toolbar.
|
||||
- **Embedded Fonts:** Uses embedded Maple Mono NF CN fonts out-of-the-box for excellent CJK character and Nerd Font icon support.
|
||||
|
||||
## Run
|
||||
|
||||
To run the application locally:
|
||||
|
||||
```bash
|
||||
cargo run --release
|
||||
```
|
||||
|
||||
## Package macOS App
|
||||
|
||||
```bash
|
||||
./scripts/package-macos-app.sh
|
||||
open target/release/ashell.app
|
||||
```
|
||||
|
||||
The packaging script creates a standard `.app` bundle. It does not attach an entitlements file, and after signing, it verifies that `com.apple.security.app-sandbox` is not present (meaning it runs non-sandboxed).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the [GPL-3.0-or-later License](LICENSE).
|
||||
@@ -1,41 +1,56 @@
|
||||
[English](README.md) | [中文](README.zh-CN.md)
|
||||
[中文](README.md) | [English](README.en.md)
|
||||
|
||||
# ashell
|
||||
|
||||
`ashell` is a modern, GPUI Component-based desktop terminal client written in Rust.
|
||||

|
||||
|
||||
This project focuses on providing a high-performance and visually appealing shell workspace by combining local and remote environments with a rich set of built-in features.
|
||||
`ashell` 是一款现代化的、基于 GPUI Component 构建的 Rust 桌面终端客户端。
|
||||
|
||||
## Features
|
||||
该项目旨在通过结合本地和远程环境,并内置丰富的核心功能,提供一个高性能且美观的 Shell 工作区。
|
||||
|
||||
The current version provides a fully-featured GPUI-native workspace:
|
||||
## 下载
|
||||
|
||||
- **Local & Remote Sessions:** Open local terminal tabs or connect to remote servers via SSH.
|
||||
- **Advanced SSH Authentication:** Supports both password-based and key-based (file path or inline) SSH connections.
|
||||
- **Session Management:** Easily save, reopen, edit, and remove your SSH sessions.
|
||||
- **SFTP Integration:** Built-in SFTP file manager to browse, upload, download, and manage remote files.
|
||||
- **Robust Terminal Emulator:** Parses terminal output with `alacritty_terminal`, supporting rich ANSI color spans, fast rendering, and complete keyboard input forwarding.
|
||||
- **System Telemetry:** Real-time visualization of CPU, memory, swap, network, and disk metrics in the left cockpit sidebar.
|
||||
- **Theming System:** Switch between multiple GPUI Component themes directly from the top toolbar.
|
||||
- **Embedded Fonts:** Uses embedded Maple Mono NF CN fonts out-of-the-box for excellent CJK character and Nerd Font icon support.
|
||||
您可以从 [GitHub Releases 页面](https://github.com/rust-kotlin/ashell/releases/latest) 下载 macOS、Windows 和 Linux 版本的最新预编译程序。
|
||||
|
||||
## Run
|
||||
## Mac 安装指南
|
||||
|
||||
To run the application locally:
|
||||
下载并解压后,请先将 `ashell.app` 拖入或移动到 **应用程序 (Applications)** 目录。
|
||||
由于应用采用本地签名,初次启动时如果系统提示“App 已损坏,无法打开”,请打开终端(Terminal)并执行以下命令:
|
||||
|
||||
```bash
|
||||
sudo xattr -cr /Applications/ashell.app
|
||||
```
|
||||
|
||||
## 功能特性
|
||||
|
||||
当前版本提供了一个功能完备的 GPUI 原生工作区:
|
||||
|
||||
- **本地与远程会话**:支持打开本地终端标签页或通过 SSH 连接到远程服务器。
|
||||
- **高级 SSH 认证**:支持基于密码和基于密钥(文件路径或内联内容)的 SSH 连接方式。
|
||||
- **会话管理**:可以轻松地保存、重新打开、编辑和删除您的 SSH 会话。
|
||||
- **SFTP 集成**:内置 SFTP 文件管理器,可以浏览、上传、下载以及管理远程文件。
|
||||
- **强大的终端模拟器**:使用 `alacritty_terminal` 解析终端输出,支持丰富的 ANSI 颜色代码、极速渲染和完整的键盘输入转发。
|
||||
- **系统遥测**:在左侧边栏实时可视化显示 CPU、内存、Swap、网络和磁盘的使用指标。
|
||||
- **主题系统**:支持直接从顶部工具栏切换多种 GPUI Component 颜色主题。
|
||||
- **内置字体**:开箱即用,内置 Maple Mono NF CN 字体,提供卓越的中日韩(CJK)字符与 Nerd Font 图标支持。
|
||||
|
||||
## 运行
|
||||
|
||||
在本地运行该应用:
|
||||
|
||||
```bash
|
||||
cargo run --release
|
||||
```
|
||||
|
||||
## Package macOS App
|
||||
## 打包 macOS 应用
|
||||
|
||||
```bash
|
||||
./scripts/package-macos-app.sh
|
||||
open target/release/ashell.app
|
||||
```
|
||||
|
||||
The packaging script creates a standard `.app` bundle. It does not attach an entitlements file, and after signing, it verifies that `com.apple.security.app-sandbox` is not present (meaning it runs non-sandboxed).
|
||||
该打包脚本会创建一个标准的 `.app` 应用程序包。它没有附加 entitlements 文件,并且在签名后会验证是否不存在 `com.apple.security.app-sandbox`(这意味着它在非沙盒模式下运行)。
|
||||
|
||||
## License
|
||||
## 协议
|
||||
|
||||
This project is licensed under the [GPL-3.0-or-later License](LICENSE).
|
||||
本项目采用 [GPL-3.0-or-later 协议](LICENSE) 开源。
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
[English](README.md) | [中文](README.zh-CN.md)
|
||||
|
||||
# ashell
|
||||
|
||||
`ashell` 是一款现代化的、基于 GPUI Component 构建的 Rust 桌面终端客户端。
|
||||
|
||||
该项目旨在通过结合本地和远程环境,并内置丰富的核心功能,提供一个高性能且美观的 Shell 工作区。
|
||||
|
||||
## 功能特性
|
||||
|
||||
当前版本提供了一个功能完备的 GPUI 原生工作区:
|
||||
|
||||
- **本地与远程会话**:支持打开本地终端标签页或通过 SSH 连接到远程服务器。
|
||||
- **高级 SSH 认证**:支持基于密码和基于密钥(文件路径或内联内容)的 SSH 连接方式。
|
||||
- **会话管理**:可以轻松地保存、重新打开、编辑和删除您的 SSH 会话。
|
||||
- **SFTP 集成**:内置 SFTP 文件管理器,可以浏览、上传、下载以及管理远程文件。
|
||||
- **强大的终端模拟器**:使用 `alacritty_terminal` 解析终端输出,支持丰富的 ANSI 颜色代码、极速渲染和完整的键盘输入转发。
|
||||
- **系统遥测**:在左侧边栏实时可视化显示 CPU、内存、Swap、网络和磁盘的使用指标。
|
||||
- **主题系统**:支持直接从顶部工具栏切换多种 GPUI Component 颜色主题。
|
||||
- **内置字体**:开箱即用,内置 Maple Mono NF CN 字体,提供卓越的中日韩(CJK)字符与 Nerd Font 图标支持。
|
||||
|
||||
## 运行
|
||||
|
||||
在本地运行该应用:
|
||||
|
||||
```bash
|
||||
cargo run --release
|
||||
```
|
||||
|
||||
## 打包 macOS 应用
|
||||
|
||||
```bash
|
||||
./scripts/package-macos-app.sh
|
||||
open target/release/ashell.app
|
||||
```
|
||||
|
||||
该打包脚本会创建一个标准的 `.app` 应用程序包。它没有附加 entitlements 文件,并且在签名后会验证是否不存在 `com.apple.security.app-sandbox`(这意味着它在非沙盒模式下运行)。
|
||||
|
||||
## 协议
|
||||
|
||||
本项目采用 [GPL-3.0-or-later 协议](LICENSE) 开源。
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 110 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 437 KiB |
@@ -0,0 +1,8 @@
|
||||
fn main() {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let mut res = winres::WindowsResource::new();
|
||||
res.set_icon("assets/icons/ashell.ico");
|
||||
res.compile().unwrap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
remote_files: "REMOTE FILES"
|
||||
open_ssh_tab_sftp: "Open an SSH tab to browse SFTP files."
|
||||
sftp_connecting: "sftp connecting..."
|
||||
refresh: "Refresh"
|
||||
upload_file: "Upload File"
|
||||
upload_folder: "Upload Folder"
|
||||
hidden: "Hidden"
|
||||
download: "Download"
|
||||
download_count: "Download (%{count})"
|
||||
name: "NAME"
|
||||
size: "SIZE"
|
||||
modified: "MODIFIED"
|
||||
new_ssh_connection: "New SSH Connection"
|
||||
create_or_edit_ssh_session: "Create or edit an SSH session"
|
||||
local_terminal: "Local Terminal"
|
||||
open_local_shell_tab: "Open a new local shell tab"
|
||||
connect: "Connect"
|
||||
edit: "Edit"
|
||||
delete: "Delete"
|
||||
host: "Host"
|
||||
port: "Port"
|
||||
user: "User"
|
||||
password: "Password"
|
||||
key: "Key"
|
||||
private_key_path: "Private Key Path"
|
||||
private_key_data: "Private Key Data"
|
||||
save_and_connect: "Save & Connect"
|
||||
save: "Save"
|
||||
cancel: "Cancel"
|
||||
host_and_user_required: "Host and user are required"
|
||||
language: "Language"
|
||||
follow_system: "Follow System"
|
||||
light_theme: "Light Theme"
|
||||
dark_theme: "Dark Theme"
|
||||
use_light_mode: "Use Light Mode"
|
||||
use_dark_mode: "Use Dark Mode"
|
||||
english: "English"
|
||||
chinese: "简体中文"
|
||||
idle_no_session: "idle / No session"
|
||||
system: "SYSTEM"
|
||||
cpu: "CPU"
|
||||
mem: "MEM"
|
||||
swap: "SWAP"
|
||||
net: "NET"
|
||||
disk: "DISK"
|
||||
global_load: "global load"
|
||||
live: "Live"
|
||||
idle: "idle"
|
||||
saved: "SAVED"
|
||||
add_ssh: "+ ssh"
|
||||
open_local_or_ssh: "Open a local terminal or pick an SSH session."
|
||||
open_session: "Open Session"
|
||||
settings: "Settings"
|
||||
terminal_font_size: "Terminal Font Size"
|
||||
theme_management_hint: "Theme mode and light/dark theme families are managed from the top-bar theme button."
|
||||
local_host: "local host"
|
||||
local_terminal_opened: "local terminal opened"
|
||||
connecting: "Connecting"
|
||||
starting_connection: "starting connection..."
|
||||
connection_failed: "Connection Failed"
|
||||
@@ -0,0 +1,60 @@
|
||||
remote_files: "远程文件"
|
||||
open_ssh_tab_sftp: "打开一个 SSH 会话面板以浏览 SFTP 文件。"
|
||||
sftp_connecting: "正在连接 SFTP..."
|
||||
refresh: "刷新"
|
||||
upload_file: "上传文件"
|
||||
upload_folder: "上传文件夹"
|
||||
hidden: "显示隐藏文件"
|
||||
download: "下载"
|
||||
download_count: "下载 (%{count})"
|
||||
name: "名称"
|
||||
size: "大小"
|
||||
modified: "修改时间"
|
||||
new_ssh_connection: "新建 SSH 连接"
|
||||
create_or_edit_ssh_session: "创建或编辑一个 SSH 会话"
|
||||
local_terminal: "本地终端"
|
||||
open_local_shell_tab: "打开一个新的本地终端页面"
|
||||
connect: "连接"
|
||||
edit: "编辑"
|
||||
delete: "删除"
|
||||
host: "主机 (Host)"
|
||||
port: "端口 (Port)"
|
||||
user: "用户 (User)"
|
||||
password: "密码 (Password)"
|
||||
key: "密钥 (Key)"
|
||||
private_key_path: "私钥路径"
|
||||
private_key_data: "私钥内容"
|
||||
save_and_connect: "保存并连接"
|
||||
save: "保存"
|
||||
cancel: "取消"
|
||||
host_and_user_required: "主机名和用户名不能为空"
|
||||
language: "显示语言"
|
||||
follow_system: "跟随系统"
|
||||
light_theme: "浅色主题"
|
||||
dark_theme: "深色主题"
|
||||
use_light_mode: "使用浅色模式"
|
||||
use_dark_mode: "使用深色模式"
|
||||
english: "English"
|
||||
chinese: "简体中文"
|
||||
idle_no_session: "空闲 / 未连接会话"
|
||||
system: "系统"
|
||||
cpu: "CPU"
|
||||
mem: "内存"
|
||||
swap: "虚拟内存"
|
||||
net: "网络"
|
||||
disk: "磁盘"
|
||||
global_load: "全局负载"
|
||||
live: "实时"
|
||||
idle: "空闲"
|
||||
saved: "已保存会话"
|
||||
add_ssh: "+ SSH"
|
||||
open_local_or_ssh: "打开本地终端或选择一个 SSH 会话。"
|
||||
open_session: "打开会话"
|
||||
settings: "设置"
|
||||
terminal_font_size: "终端字体大小"
|
||||
theme_management_hint: "主题模式和亮/暗主题系列可通过顶栏的主题按钮管理。"
|
||||
local_host: "本地主机"
|
||||
local_terminal_opened: "已打开本地终端"
|
||||
connecting: "正在连接"
|
||||
starting_connection: "开始连接..."
|
||||
connection_failed: "连接失败"
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 292 KiB |
@@ -17,6 +17,8 @@ rm -rf "$APP_DIR"
|
||||
mkdir -p "$MACOS_DIR" "$RESOURCES_DIR"
|
||||
cp "$ROOT_DIR/target/release/$APP_NAME" "$MACOS_DIR/$APP_NAME"
|
||||
|
||||
cp "$ROOT_DIR/assets/icons/ashell.icns" "$RESOURCES_DIR/ashell.icns"
|
||||
|
||||
cat > "$CONTENTS_DIR/Info.plist" <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
@@ -27,6 +29,8 @@ cat > "$CONTENTS_DIR/Info.plist" <<EOF
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$APP_NAME</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>ashell.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$BUNDLE_ID</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
|
||||
+28
-1
@@ -75,15 +75,23 @@ pub struct ConfigFile {
|
||||
#[serde(default)]
|
||||
pub follow_system_theme: bool,
|
||||
#[serde(default)]
|
||||
pub theme_mode: String,
|
||||
#[serde(default)]
|
||||
pub light_theme_name: String,
|
||||
#[serde(default)]
|
||||
pub dark_theme_name: String,
|
||||
#[serde(default = "default_locale")]
|
||||
pub locale: String,
|
||||
#[serde(default = "default_terminal_font_size")]
|
||||
pub terminal_font_size: f32,
|
||||
#[serde(default)]
|
||||
pub sessions: Vec<Session>,
|
||||
}
|
||||
|
||||
fn default_locale() -> String {
|
||||
"system".to_string()
|
||||
}
|
||||
|
||||
fn default_terminal_font_size() -> f32 {
|
||||
13.0
|
||||
}
|
||||
@@ -136,6 +144,10 @@ impl ConfigStore {
|
||||
self.cache.follow_system_theme
|
||||
}
|
||||
|
||||
pub fn theme_mode(&self) -> &str {
|
||||
&self.cache.theme_mode
|
||||
}
|
||||
|
||||
pub fn light_theme_name(&self) -> &str {
|
||||
&self.cache.light_theme_name
|
||||
}
|
||||
@@ -144,6 +156,18 @@ impl ConfigStore {
|
||||
&self.cache.dark_theme_name
|
||||
}
|
||||
|
||||
pub fn locale(&self) -> &str {
|
||||
if self.cache.locale.is_empty() {
|
||||
"system"
|
||||
} else {
|
||||
&self.cache.locale
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_locale(&mut self, locale: &str) {
|
||||
self.cache.locale = locale.to_string();
|
||||
}
|
||||
|
||||
pub fn terminal_font_size(&self) -> f32 {
|
||||
if self.cache.terminal_font_size <= 0.0 {
|
||||
default_terminal_font_size()
|
||||
@@ -155,10 +179,12 @@ impl ConfigStore {
|
||||
pub fn set_theme_preferences(
|
||||
&mut self,
|
||||
follow_system_theme: bool,
|
||||
theme_mode: impl Into<String>,
|
||||
light_theme_name: impl Into<String>,
|
||||
dark_theme_name: impl Into<String>,
|
||||
) {
|
||||
self.cache.follow_system_theme = follow_system_theme;
|
||||
self.cache.theme_mode = theme_mode.into();
|
||||
self.cache.light_theme_name = light_theme_name.into();
|
||||
self.cache.dark_theme_name = dark_theme_name.into();
|
||||
}
|
||||
@@ -188,6 +214,7 @@ impl ConfigStore {
|
||||
return Ok(());
|
||||
}
|
||||
let raw = serde_json::to_string_pretty(&self.cache)?;
|
||||
fs::write(&self.path, raw).with_context(|| format!("failed to write {}", self.path.display()))
|
||||
fs::write(&self.path, raw)
|
||||
.with_context(|| format!("failed to write {}", self.path.display()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use portable_pty::{native_pty_system, CommandBuilder, PtySize};
|
||||
use portable_pty::{CommandBuilder, PtySize, native_pty_system};
|
||||
|
||||
use crate::terminal::{BackendCommand, BackendEvent, BackendTx};
|
||||
|
||||
@@ -34,7 +34,10 @@ pub fn spawn_local_terminal(
|
||||
});
|
||||
|
||||
let mut cmd = CommandBuilder::new(&shell);
|
||||
cmd.env("TERM", std::env::var("TERM").unwrap_or_else(|_| "xterm-256color".into()));
|
||||
cmd.env(
|
||||
"TERM",
|
||||
std::env::var("TERM").unwrap_or_else(|_| "xterm-256color".into()),
|
||||
);
|
||||
cmd.env(
|
||||
"COLORTERM",
|
||||
std::env::var("COLORTERM").unwrap_or_else(|_| "truecolor".into()),
|
||||
|
||||
+464
-102
File diff suppressed because it is too large
Load Diff
+116
-30
@@ -4,15 +4,15 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use directories::BaseDirs;
|
||||
use flate2::read::GzDecoder;
|
||||
use russh::{
|
||||
client::{self, Handler},
|
||||
keys::{decode_secret_key, key::PrivateKeyWithHashAlg, load_secret_key, HashAlg, PrivateKey},
|
||||
Disconnect,
|
||||
client::{self, Handler},
|
||||
keys::{HashAlg, PrivateKey, decode_secret_key, key::PrivateKeyWithHashAlg, load_secret_key},
|
||||
};
|
||||
use russh_sftp::client::SftpSession;
|
||||
use tokio::{
|
||||
@@ -38,6 +38,7 @@ pub struct RemoteEntry {
|
||||
pub modified: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PreviewData {
|
||||
pub path: String,
|
||||
@@ -47,16 +48,23 @@ pub struct PreviewData {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum SftpCommand {
|
||||
pub enum SftpCommand {
|
||||
ListDir(String),
|
||||
#[allow(dead_code)]
|
||||
Preview(String),
|
||||
Download { remote: String, local_dir: String },
|
||||
UploadPaths { locals: Vec<String>, remote_dir: String },
|
||||
Download {
|
||||
remote: String,
|
||||
local_dir: String,
|
||||
},
|
||||
UploadPaths {
|
||||
locals: Vec<String>,
|
||||
remote_dir: String,
|
||||
},
|
||||
Close,
|
||||
}
|
||||
|
||||
pub struct SftpHandle {
|
||||
commands: UnboundedSender<SftpCommand>,
|
||||
pub commands: UnboundedSender<SftpCommand>,
|
||||
#[allow(dead_code)]
|
||||
join: Option<JoinHandle<()>>,
|
||||
}
|
||||
@@ -75,16 +83,21 @@ impl SftpHandle {
|
||||
let _ = self.commands.send(SftpCommand::ListDir(path));
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn preview(&self, path: String) {
|
||||
let _ = self.commands.send(SftpCommand::Preview(path));
|
||||
}
|
||||
|
||||
pub fn download(&self, remote: String, local_dir: String) {
|
||||
let _ = self.commands.send(SftpCommand::Download { remote, local_dir });
|
||||
let _ = self
|
||||
.commands
|
||||
.send(SftpCommand::Download { remote, local_dir });
|
||||
}
|
||||
|
||||
pub fn upload_paths(&self, locals: Vec<String>, remote_dir: String) {
|
||||
let _ = self.commands.send(SftpCommand::UploadPaths { locals, remote_dir });
|
||||
let _ = self
|
||||
.commands
|
||||
.send(SftpCommand::UploadPaths { locals, remote_dir });
|
||||
}
|
||||
|
||||
pub fn close(&self) {
|
||||
@@ -137,14 +150,25 @@ async fn run_sftp(
|
||||
.await
|
||||
.context("sftp handshake")?;
|
||||
|
||||
let home = sftp.canonicalize(".").await.unwrap_or_else(|_| "/".to_string());
|
||||
let home = sftp
|
||||
.canonicalize(".")
|
||||
.await
|
||||
.unwrap_or_else(|_| "/".to_string());
|
||||
emit_entries(&events, &tab_id, &sftp, &home).await?;
|
||||
|
||||
while let Some(command) = commands.recv().await {
|
||||
match command {
|
||||
SftpCommand::Close => break,
|
||||
SftpCommand::ListDir(path) => {
|
||||
if let Err(err) = emit_entries(&events, &tab_id, &sftp, &path).await {
|
||||
let actual_path = if path == "~" {
|
||||
home.clone()
|
||||
} else if let Some(rest) = path.strip_prefix("~/") {
|
||||
crate::sftp::join_remote(&home, rest)
|
||||
} else {
|
||||
path
|
||||
};
|
||||
|
||||
if let Err(err) = emit_entries(&events, &tab_id, &sftp, &actual_path).await {
|
||||
let _ = events.send(BackendEvent::SftpStatus {
|
||||
tab_id: tab_id.clone(),
|
||||
text: format!("list failed: {err:#}"),
|
||||
@@ -210,7 +234,9 @@ async fn run_sftp(
|
||||
}
|
||||
}
|
||||
|
||||
let _ = handle.disconnect(Disconnect::ByApplication, "bye", "").await;
|
||||
let _ = handle
|
||||
.disconnect(Disconnect::ByApplication, "bye", "")
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -233,7 +259,9 @@ async fn emit_entries(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn connect_and_authenticate(session: &Session) -> Result<russh::client::Handle<SftpClientHandler>> {
|
||||
async fn connect_and_authenticate(
|
||||
session: &Session,
|
||||
) -> Result<russh::client::Handle<SftpClientHandler>> {
|
||||
let config = Arc::new(client::Config {
|
||||
inactivity_timeout: Some(std::time::Duration::from_secs(600)),
|
||||
..Default::default()
|
||||
@@ -360,6 +388,7 @@ fn join_remote(parent: &str, child: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn strip_archive_suffix(name: &str) -> &str {
|
||||
for suffix in [".tar.gz", ".tgz", ".zip", ".tar"] {
|
||||
if let Some(stripped) = name.strip_suffix(suffix) {
|
||||
@@ -429,7 +458,10 @@ async fn list_dir_impl(sftp: &SftpSession, path: &str) -> Result<Vec<RemoteEntry
|
||||
}
|
||||
|
||||
async fn preview_impl(sftp: &SftpSession, path: &str) -> Result<PreviewData> {
|
||||
let metadata = sftp.metadata(path).await.with_context(|| format!("metadata {path}"))?;
|
||||
let metadata = sftp
|
||||
.metadata(path)
|
||||
.await
|
||||
.with_context(|| format!("metadata {path}"))?;
|
||||
let is_dir = metadata
|
||||
.permissions
|
||||
.map(|mode| (mode & 0o170_000) == 0o040_000)
|
||||
@@ -450,9 +482,15 @@ async fn preview_impl(sftp: &SftpSession, path: &str) -> Result<PreviewData> {
|
||||
});
|
||||
}
|
||||
|
||||
let mut remote_file = sftp.open(path).await.with_context(|| format!("open remote {path}"))?;
|
||||
let mut remote_file = sftp
|
||||
.open(path)
|
||||
.await
|
||||
.with_context(|| format!("open remote {path}"))?;
|
||||
let mut buffer = vec![0u8; 128 * 1024];
|
||||
let read = remote_file.read(&mut buffer).await.context("read preview bytes")?;
|
||||
let read = remote_file
|
||||
.read(&mut buffer)
|
||||
.await
|
||||
.context("read preview bytes")?;
|
||||
buffer.truncate(read);
|
||||
|
||||
let nul_ratio = if buffer.is_empty() {
|
||||
@@ -488,7 +526,10 @@ async fn download_path_impl(
|
||||
.await
|
||||
.with_context(|| format!("create {}", local_dir.display()))?;
|
||||
|
||||
let metadata = sftp.metadata(remote).await.with_context(|| format!("metadata {remote}"))?;
|
||||
let metadata = sftp
|
||||
.metadata(remote)
|
||||
.await
|
||||
.with_context(|| format!("metadata {remote}"))?;
|
||||
let is_dir = metadata
|
||||
.permissions
|
||||
.map(|mode| (mode & 0o170_000) == 0o040_000)
|
||||
@@ -500,7 +541,8 @@ async fn download_path_impl(
|
||||
base_name(remote),
|
||||
Uuid::new_v4()
|
||||
));
|
||||
let extracted_to = download_remote_directory_archive(handle, sftp, remote, &local_archive).await?;
|
||||
let extracted_to =
|
||||
download_remote_directory_archive(handle, sftp, remote, &local_archive).await?;
|
||||
return Ok(format!("downloaded folder to {}", extracted_to.display()));
|
||||
}
|
||||
|
||||
@@ -509,7 +551,12 @@ async fn download_path_impl(
|
||||
Ok(format!("downloaded file to {}", local_path.display()))
|
||||
}
|
||||
|
||||
async fn download_dir_recursive(sftp: &SftpSession, remote_dir: &str, local_dir: &Path) -> Result<()> {
|
||||
#[allow(dead_code)]
|
||||
async fn download_dir_recursive(
|
||||
sftp: &SftpSession,
|
||||
remote_dir: &str,
|
||||
local_dir: &Path,
|
||||
) -> Result<()> {
|
||||
tokio::fs::create_dir_all(local_dir)
|
||||
.await
|
||||
.with_context(|| format!("create {}", local_dir.display()))?;
|
||||
@@ -532,7 +579,11 @@ async fn download_remote_directory_archive(
|
||||
remote_dir: &str,
|
||||
local_archive: &Path,
|
||||
) -> Result<PathBuf> {
|
||||
let remote_archive = format!("/tmp/ashell-{}-{}.tar.gz", base_name(remote_dir), Uuid::new_v4());
|
||||
let remote_archive = format!(
|
||||
"/tmp/ashell-{}-{}.tar.gz",
|
||||
base_name(remote_dir),
|
||||
Uuid::new_v4()
|
||||
);
|
||||
create_remote_archive(handle, remote_dir, &remote_archive).await?;
|
||||
let local_extract_root = local_archive
|
||||
.parent()
|
||||
@@ -541,7 +592,11 @@ async fn download_remote_directory_archive(
|
||||
|
||||
let archive_download = async {
|
||||
download_file_impl(sftp, &remote_archive, local_archive).await?;
|
||||
extract_archive_to(local_archive, local_archive.parent().unwrap_or_else(|| Path::new("."))).await?;
|
||||
extract_archive_to(
|
||||
local_archive,
|
||||
local_archive.parent().unwrap_or_else(|| Path::new(".")),
|
||||
)
|
||||
.await?;
|
||||
tokio::fs::remove_file(local_archive)
|
||||
.await
|
||||
.with_context(|| format!("remove {}", local_archive.display()))?;
|
||||
@@ -560,14 +615,20 @@ async fn download_remote_directory_archive(
|
||||
}
|
||||
|
||||
async fn download_file_impl(sftp: &SftpSession, remote: &str, local: &Path) -> Result<()> {
|
||||
let mut remote_file = sftp.open(remote).await.with_context(|| format!("open remote {remote}"))?;
|
||||
let mut remote_file = sftp
|
||||
.open(remote)
|
||||
.await
|
||||
.with_context(|| format!("open remote {remote}"))?;
|
||||
let mut local_file = tokio::fs::File::create(local)
|
||||
.await
|
||||
.with_context(|| format!("create local {}", local.display()))?;
|
||||
|
||||
let mut buffer = vec![0u8; 64 * 1024];
|
||||
loop {
|
||||
let read = remote_file.read(&mut buffer).await.context("read remote file")?;
|
||||
let read = remote_file
|
||||
.read(&mut buffer)
|
||||
.await
|
||||
.context("read remote file")?;
|
||||
if read == 0 {
|
||||
break;
|
||||
}
|
||||
@@ -580,7 +641,11 @@ async fn download_file_impl(sftp: &SftpSession, remote: &str, local: &Path) -> R
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn upload_paths_impl(sftp: &SftpSession, locals: &[String], remote_dir: &str) -> Result<String> {
|
||||
async fn upload_paths_impl(
|
||||
sftp: &SftpSession,
|
||||
locals: &[String],
|
||||
remote_dir: &str,
|
||||
) -> Result<String> {
|
||||
create_remote_dir_all(sftp, remote_dir).await?;
|
||||
let mut file_count = 0usize;
|
||||
let mut folder_count = 0usize;
|
||||
@@ -604,7 +669,11 @@ async fn upload_paths_impl(sftp: &SftpSession, locals: &[String], remote_dir: &s
|
||||
Ok(summary)
|
||||
}
|
||||
|
||||
async fn upload_directory_impl(sftp: &SftpSession, local_dir: &Path, remote_parent: &str) -> Result<()> {
|
||||
async fn upload_directory_impl(
|
||||
sftp: &SftpSession,
|
||||
local_dir: &Path,
|
||||
remote_parent: &str,
|
||||
) -> Result<()> {
|
||||
let root_name = local_dir
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
@@ -643,7 +712,11 @@ async fn upload_directory_impl(sftp: &SftpSession, local_dir: &Path, remote_pare
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn upload_file_to_dir_impl(sftp: &SftpSession, local_file: &Path, remote_dir: &str) -> Result<()> {
|
||||
async fn upload_file_to_dir_impl(
|
||||
sftp: &SftpSession,
|
||||
local_file: &Path,
|
||||
remote_dir: &str,
|
||||
) -> Result<()> {
|
||||
let file_name = local_file
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
@@ -779,8 +852,13 @@ fn shell_quote(value: &str) -> String {
|
||||
format!("'{}'", value.replace('\'', "'\"'\"'"))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn maybe_extract_archive(path: &Path) -> Result<Option<PathBuf>> {
|
||||
let Some(file_name) = path.file_name().and_then(|name| name.to_str()).map(|name| name.to_string()) else {
|
||||
let Some(file_name) = path
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.map(|name| name.to_string())
|
||||
else {
|
||||
return Ok(None);
|
||||
};
|
||||
let is_archive = [".zip", ".tar", ".tar.gz", ".tgz"]
|
||||
@@ -826,7 +904,9 @@ async fn maybe_extract_archive(path: &Path) -> Result<Option<PathBuf>> {
|
||||
.with_context(|| format!("open {}", archive_path.display()))?;
|
||||
let decoder = GzDecoder::new(file);
|
||||
let mut archive = tar::Archive::new(decoder);
|
||||
archive.unpack(&target_dir).context("unpack tar.gz archive")?;
|
||||
archive
|
||||
.unpack(&target_dir)
|
||||
.context("unpack tar.gz archive")?;
|
||||
} else if file_name.ends_with(".tar") {
|
||||
let file = fs::File::open(&archive_path)
|
||||
.with_context(|| format!("open {}", archive_path.display()))?;
|
||||
@@ -843,7 +923,11 @@ async fn maybe_extract_archive(path: &Path) -> Result<Option<PathBuf>> {
|
||||
}
|
||||
|
||||
async fn extract_archive_to(path: &Path, target_dir: &Path) -> Result<()> {
|
||||
let Some(file_name) = path.file_name().and_then(|name| name.to_str()).map(|name| name.to_string()) else {
|
||||
let Some(file_name) = path
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.map(|name| name.to_string())
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
let archive_path = path.to_path_buf();
|
||||
@@ -878,7 +962,9 @@ async fn extract_archive_to(path: &Path, target_dir: &Path) -> Result<()> {
|
||||
.with_context(|| format!("open {}", archive_path.display()))?;
|
||||
let decoder = GzDecoder::new(file);
|
||||
let mut archive = tar::Archive::new(decoder);
|
||||
archive.unpack(&target_dir).context("unpack tar.gz archive")?;
|
||||
archive
|
||||
.unpack(&target_dir)
|
||||
.context("unpack tar.gz archive")?;
|
||||
} else if file_name.ends_with(".tar") {
|
||||
let file = fs::File::open(&archive_path)
|
||||
.with_context(|| format!("open {}", archive_path.display()))?;
|
||||
|
||||
+4
-4
@@ -3,19 +3,19 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use async_trait::async_trait;
|
||||
use directories::BaseDirs;
|
||||
use russh::{
|
||||
client::{self, Handler},
|
||||
keys::{decode_secret_key, key::PrivateKeyWithHashAlg, load_secret_key, HashAlg, PrivateKey},
|
||||
ChannelMsg, Disconnect,
|
||||
client::{self, Handler},
|
||||
keys::{HashAlg, PrivateKey, decode_secret_key, key::PrivateKeyWithHashAlg, load_secret_key},
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::{
|
||||
config::{AuthMethod, Session},
|
||||
system::{remote_snapshot_from_kv, SystemSnapshot},
|
||||
system::{SystemSnapshot, remote_snapshot_from_kv},
|
||||
terminal::{BackendCommand, BackendEvent, BackendTx},
|
||||
};
|
||||
|
||||
|
||||
+11
-13
@@ -1,6 +1,9 @@
|
||||
use std::{collections::BTreeMap, time::{Duration, Instant}};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::{Result, anyhow};
|
||||
use sysinfo::{Disks, Networks, System};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -69,7 +72,10 @@ impl SystemSampler {
|
||||
let rx_total: u64 = self.nets.iter().map(|(_, d)| d.total_received()).sum();
|
||||
let tx_total: u64 = self.nets.iter().map(|(_, d)| d.total_transmitted()).sum();
|
||||
let now = Instant::now();
|
||||
let elapsed = now.duration_since(self.last_instant).as_secs_f64().max(0.001);
|
||||
let elapsed = now
|
||||
.duration_since(self.last_instant)
|
||||
.as_secs_f64()
|
||||
.max(0.001);
|
||||
let rx_rate = (rx_total.saturating_sub(self.last_rx_total) as f64 / elapsed) as u64;
|
||||
let tx_rate = (tx_total.saturating_sub(self.last_tx_total) as f64 / elapsed) as u64;
|
||||
self.last_rx_total = rx_total;
|
||||
@@ -92,16 +98,8 @@ impl SystemSampler {
|
||||
cpu_percent,
|
||||
mem_percent: ratio(mem_used, mem_total),
|
||||
swap_percent: ratio(swap_used, swap_total),
|
||||
mem_detail: format!(
|
||||
"{}/{}",
|
||||
format_bytes(mem_used),
|
||||
format_bytes(mem_total)
|
||||
),
|
||||
swap_detail: format!(
|
||||
"{}/{}",
|
||||
format_bytes(swap_used),
|
||||
format_bytes(swap_total)
|
||||
),
|
||||
mem_detail: format!("{}/{}", format_bytes(mem_used), format_bytes(mem_total)),
|
||||
swap_detail: format!("{}/{}", format_bytes(swap_used), format_bytes(swap_total)),
|
||||
net_rx: format!("{}/s", format_bytes(rx_rate)),
|
||||
net_tx: format!("{}/s", format_bytes(tx_rate)),
|
||||
disks,
|
||||
|
||||
+122
-29
@@ -5,10 +5,7 @@ use alacritty_terminal::{
|
||||
grid::{Dimensions, Scroll},
|
||||
index::{Column, Point, Side},
|
||||
selection::{Selection, SelectionRange, SelectionType},
|
||||
term::{
|
||||
cell::Cell,
|
||||
point_to_viewport, viewport_to_point, Config, Term, TermMode,
|
||||
},
|
||||
term::{Config, Term, TermMode, cell::Cell, point_to_viewport, viewport_to_point},
|
||||
vte::ansi::{CursorShape, Processor},
|
||||
};
|
||||
use gpui::Keystroke;
|
||||
@@ -32,15 +29,46 @@ pub enum BackendCommand {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum BackendEvent {
|
||||
Output { tab_id: String, bytes: Vec<u8> },
|
||||
Status { tab_id: String, text: String },
|
||||
Connected { tab_id: String },
|
||||
SftpEntries { tab_id: String, path: String, entries: Vec<RemoteEntry> },
|
||||
SftpPreview { tab_id: String, preview: PreviewData },
|
||||
SftpStatus { tab_id: String, text: String },
|
||||
RemoteSystem { tab_id: String, snapshot: SystemSnapshot },
|
||||
RemoteSystemUnavailable { tab_id: String, reason: String },
|
||||
Closed { tab_id: String, reason: String },
|
||||
Output {
|
||||
tab_id: String,
|
||||
bytes: Vec<u8>,
|
||||
},
|
||||
Status {
|
||||
tab_id: String,
|
||||
text: String,
|
||||
},
|
||||
Connected {
|
||||
tab_id: String,
|
||||
},
|
||||
SftpEntries {
|
||||
tab_id: String,
|
||||
path: String,
|
||||
entries: Vec<RemoteEntry>,
|
||||
},
|
||||
SftpPreview {
|
||||
tab_id: String,
|
||||
preview: PreviewData,
|
||||
},
|
||||
SftpStatus {
|
||||
tab_id: String,
|
||||
text: String,
|
||||
},
|
||||
RemoteSystem {
|
||||
tab_id: String,
|
||||
snapshot: SystemSnapshot,
|
||||
},
|
||||
RemoteSystemUnavailable {
|
||||
tab_id: String,
|
||||
reason: String,
|
||||
},
|
||||
Closed {
|
||||
tab_id: String,
|
||||
reason: String,
|
||||
},
|
||||
TerminalTitleChanged {
|
||||
tab_id: String,
|
||||
title: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -118,20 +146,42 @@ pub struct SftpUiState {
|
||||
pub entries: Vec<RemoteEntry>,
|
||||
pub selected_path: Option<String>,
|
||||
pub preview: Option<PreviewData>,
|
||||
pub selected_entries: std::collections::HashSet<String>,
|
||||
}
|
||||
|
||||
impl TerminalTab {
|
||||
pub fn new_local(id: String, title: String, backend: BackendTx) -> Self {
|
||||
Self::new(id, title, TabKind::Local, "local shell".into(), backend)
|
||||
pub fn new_local(
|
||||
id: String,
|
||||
title: String,
|
||||
backend: BackendTx,
|
||||
events: std::sync::mpsc::Sender<BackendEvent>,
|
||||
) -> Self {
|
||||
Self::new(
|
||||
id,
|
||||
title,
|
||||
TabKind::Local,
|
||||
"local shell".into(),
|
||||
backend,
|
||||
events,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_ssh(id: String, session: &Session, backend: BackendTx) -> Self {
|
||||
pub fn new_ssh(
|
||||
id: String,
|
||||
session: &Session,
|
||||
backend: BackendTx,
|
||||
events: std::sync::mpsc::Sender<BackendEvent>,
|
||||
) -> Self {
|
||||
let mut tab = Self::new(
|
||||
id,
|
||||
session.name.clone(),
|
||||
TabKind::Ssh,
|
||||
format!("connecting {}@{}:{}", session.user, session.host, session.port),
|
||||
format!(
|
||||
"connecting {}@{}:{}",
|
||||
session.user, session.host, session.port
|
||||
),
|
||||
backend,
|
||||
events,
|
||||
);
|
||||
tab.session = Some(session.clone());
|
||||
tab.connected = false;
|
||||
@@ -141,13 +191,21 @@ impl TerminalTab {
|
||||
entries: Vec::new(),
|
||||
selected_path: None,
|
||||
preview: None,
|
||||
selected_entries: std::collections::HashSet::new(),
|
||||
});
|
||||
tab
|
||||
}
|
||||
|
||||
fn new(id: String, title: String, kind: TabKind, status: String, backend: BackendTx) -> Self {
|
||||
fn new(
|
||||
id: String,
|
||||
title: String,
|
||||
kind: TabKind,
|
||||
status: String,
|
||||
backend: BackendTx,
|
||||
events: std::sync::mpsc::Sender<BackendEvent>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
id: id.clone(),
|
||||
title,
|
||||
kind,
|
||||
status,
|
||||
@@ -155,7 +213,7 @@ impl TerminalTab {
|
||||
session: None,
|
||||
sftp: None,
|
||||
processor: Processor::new(),
|
||||
term: new_term(100, 30, backend.clone()),
|
||||
term: new_term(100, 30, backend.clone(), id, events),
|
||||
cols: 100,
|
||||
rows: 30,
|
||||
backend,
|
||||
@@ -260,8 +318,11 @@ impl TerminalTab {
|
||||
self.term.scroll_display(Scroll::Bottom);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn has_selection(&self) -> bool {
|
||||
self.term.selection_to_string().is_some_and(|text| !text.is_empty())
|
||||
self.term
|
||||
.selection_to_string()
|
||||
.is_some_and(|text| !text.is_empty())
|
||||
}
|
||||
|
||||
pub fn clear_selection(&mut self) {
|
||||
@@ -269,7 +330,9 @@ impl TerminalTab {
|
||||
}
|
||||
|
||||
pub fn selection_text(&self) -> Option<String> {
|
||||
self.term.selection_to_string().filter(|text| !text.is_empty())
|
||||
self.term
|
||||
.selection_to_string()
|
||||
.filter(|text| !text.is_empty())
|
||||
}
|
||||
|
||||
pub fn begin_selection(
|
||||
@@ -297,19 +360,25 @@ impl TerminalTab {
|
||||
}
|
||||
|
||||
pub fn paste_text(&mut self, text: &str) {
|
||||
let paste_text = text.replace('\x1b', "").replace("\r\n", "\r").replace('\n', "\r");
|
||||
let paste_text = text
|
||||
.replace('\x1b', "")
|
||||
.replace("\r\n", "\r")
|
||||
.replace('\n', "\r");
|
||||
|
||||
self.backend
|
||||
.send(BackendCommand::Input(paste_text.into_bytes()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn viewport_selection_from_range(
|
||||
display_offset: usize,
|
||||
selection: &Option<SelectionRange>,
|
||||
) -> Option<ViewportSelection> {
|
||||
let SelectionRange { start, end, is_block } = selection.as_ref().copied()?;
|
||||
let SelectionRange {
|
||||
start,
|
||||
end,
|
||||
is_block,
|
||||
} = selection.as_ref().copied()?;
|
||||
let start = point_to_viewport(display_offset, start)?;
|
||||
let end = point_to_viewport(display_offset, end)?;
|
||||
|
||||
@@ -324,13 +393,17 @@ fn viewport_selection_from_range(
|
||||
|
||||
#[derive(Clone)]
|
||||
struct TerminalListener {
|
||||
tab_id: String,
|
||||
backend: BackendTx,
|
||||
events: std::sync::mpsc::Sender<BackendEvent>,
|
||||
}
|
||||
|
||||
impl EventListener for TerminalListener {
|
||||
fn send_event(&self, event: Event) {
|
||||
match event {
|
||||
Event::PtyWrite(output) => self.backend.send(BackendCommand::Input(output.into_bytes())),
|
||||
Event::PtyWrite(output) => self
|
||||
.backend
|
||||
.send(BackendCommand::Input(output.into_bytes())),
|
||||
Event::TextAreaSizeRequest(format) => {
|
||||
let size = alacritty_terminal::event::WindowSize {
|
||||
num_lines: 30,
|
||||
@@ -341,19 +414,35 @@ impl EventListener for TerminalListener {
|
||||
self.backend
|
||||
.send(BackendCommand::Input(format(size).into_bytes()));
|
||||
}
|
||||
Event::Title(title) => {
|
||||
let _ = self.events.send(BackendEvent::TerminalTitleChanged {
|
||||
tab_id: self.tab_id.clone(),
|
||||
title,
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn new_term(cols: u16, rows: u16, backend: BackendTx) -> Term<TerminalListener> {
|
||||
fn new_term(
|
||||
cols: u16,
|
||||
rows: u16,
|
||||
backend: BackendTx,
|
||||
tab_id: String,
|
||||
events: std::sync::mpsc::Sender<BackendEvent>,
|
||||
) -> Term<TerminalListener> {
|
||||
Term::new(
|
||||
Config {
|
||||
scrolling_history: 2000,
|
||||
..Config::default()
|
||||
},
|
||||
&TerminalSize::new(cols, rows),
|
||||
TerminalListener { backend },
|
||||
TerminalListener {
|
||||
tab_id,
|
||||
backend,
|
||||
events,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -385,7 +474,11 @@ impl Dimensions for TerminalSize {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn encode_key(keystroke: &Keystroke, app_cursor_mode: bool, option_as_meta: bool) -> Option<Vec<u8>> {
|
||||
pub fn encode_key(
|
||||
keystroke: &Keystroke,
|
||||
app_cursor_mode: bool,
|
||||
option_as_meta: bool,
|
||||
) -> Option<Vec<u8>> {
|
||||
zed_like_to_esc_str(keystroke, app_cursor_mode, option_as_meta)
|
||||
.map(|text| text.into_owned().into_bytes())
|
||||
}
|
||||
|
||||
+56
-27
@@ -3,9 +3,10 @@ use alacritty_terminal::{
|
||||
vte::ansi::{Color as AnsiColor, CursorShape, NamedColor},
|
||||
};
|
||||
use gpui::{
|
||||
App, Bounds, Element, ElementId, Entity, FocusHandle, Font, FontStyle, FontWeight, GlobalElementId, Hsla, InputHandler, IntoElement,
|
||||
LayoutId, Pixels, Point, Rgba, StrikethroughStyle, TextRun, TextStyle, UTF16Selection, UnderlineStyle, Window, fill, point, px,
|
||||
relative, rgb,
|
||||
App, Bounds, Element, ElementId, Entity, FocusHandle, Font, FontStyle, FontWeight,
|
||||
GlobalElementId, Hsla, InputHandler, IntoElement, LayoutId, Pixels, Point, Rgba,
|
||||
StrikethroughStyle, TextRun, TextStyle, UTF16Selection, UnderlineStyle, Window, fill, point,
|
||||
px, relative, rgb,
|
||||
};
|
||||
use gpui_component::ActiveTheme as _;
|
||||
|
||||
@@ -81,7 +82,13 @@ impl BatchedTextRun {
|
||||
}
|
||||
}
|
||||
|
||||
fn paint(&self, origin: Point<Pixels>, metrics: TerminalMetrics, window: &mut Window, cx: &mut App) {
|
||||
fn paint(
|
||||
&self,
|
||||
origin: Point<Pixels>,
|
||||
metrics: TerminalMetrics,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) {
|
||||
let pos = point(
|
||||
origin.x + metrics.cell_width * self.col as f32,
|
||||
origin.y + metrics.line_height * self.row as f32,
|
||||
@@ -146,10 +153,13 @@ impl InputHandler for TerminalInputHandler {
|
||||
_window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Option<UTF16Selection> {
|
||||
self.view.read(cx).terminal_accepts_text_input().then_some(UTF16Selection {
|
||||
range: 0..0,
|
||||
reversed: false,
|
||||
})
|
||||
self.view
|
||||
.read(cx)
|
||||
.terminal_accepts_text_input()
|
||||
.then_some(UTF16Selection {
|
||||
range: 0..0,
|
||||
reversed: false,
|
||||
})
|
||||
}
|
||||
|
||||
fn marked_text_range(
|
||||
@@ -277,15 +287,21 @@ impl TerminalElement {
|
||||
fg.a *= 0.7;
|
||||
}
|
||||
|
||||
let underline = cell.flags.intersects(Flags::ALL_UNDERLINES).then(|| UnderlineStyle {
|
||||
color: Some(fg),
|
||||
thickness: px(1.0),
|
||||
wavy: cell.flags.contains(Flags::UNDERCURL),
|
||||
});
|
||||
let strikethrough = cell.flags.contains(Flags::STRIKEOUT).then(|| StrikethroughStyle {
|
||||
color: Some(fg),
|
||||
thickness: px(1.0),
|
||||
});
|
||||
let underline = cell
|
||||
.flags
|
||||
.intersects(Flags::ALL_UNDERLINES)
|
||||
.then(|| UnderlineStyle {
|
||||
color: Some(fg),
|
||||
thickness: px(1.0),
|
||||
wavy: cell.flags.contains(Flags::UNDERCURL),
|
||||
});
|
||||
let strikethrough = cell
|
||||
.flags
|
||||
.contains(Flags::STRIKEOUT)
|
||||
.then(|| StrikethroughStyle {
|
||||
color: Some(fg),
|
||||
thickness: px(1.0),
|
||||
});
|
||||
|
||||
let weight = if cell.flags.intersects(Flags::BOLD | Flags::DIM_BOLD) {
|
||||
FontWeight::BOLD
|
||||
@@ -326,10 +342,9 @@ impl TerminalElement {
|
||||
continue;
|
||||
}
|
||||
|
||||
let selected = self
|
||||
.snapshot
|
||||
.selection
|
||||
.is_some_and(|selection| selection_contains(selection, render_cell.row, render_cell.col));
|
||||
let selected = self.snapshot.selection.is_some_and(|selection| {
|
||||
selection_contains(selection, render_cell.row, render_cell.col)
|
||||
});
|
||||
let bg = color_to_hsla(cell.bg, false, cx);
|
||||
if selected || !is_default_bg(cell.bg) {
|
||||
rects.push(LayoutRect {
|
||||
@@ -525,7 +540,11 @@ impl Element for TerminalElement {
|
||||
}
|
||||
|
||||
if let Some(cursor) = prepaint.cursor {
|
||||
if self.marked_text.as_ref().is_some_and(|text| !text.is_empty()) {
|
||||
if self
|
||||
.marked_text
|
||||
.as_ref()
|
||||
.is_some_and(|text| !text.is_empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
let x = prepaint.bounds.origin.x + prepaint.metrics.cell_width * cursor.col as f32;
|
||||
@@ -534,7 +553,10 @@ impl Element for TerminalElement {
|
||||
CursorShape::Hidden => {}
|
||||
CursorShape::Beam => {
|
||||
window.paint_quad(fill(
|
||||
Bounds::new(point(x, y), gpui::size(px(2.), prepaint.metrics.line_height)),
|
||||
Bounds::new(
|
||||
point(x, y),
|
||||
gpui::size(px(2.), prepaint.metrics.line_height),
|
||||
),
|
||||
cursor.color,
|
||||
));
|
||||
}
|
||||
@@ -572,7 +594,10 @@ fn merge_rects(mut rects: Vec<LayoutRect>) -> Vec<LayoutRect> {
|
||||
|
||||
for rect in rects {
|
||||
if let Some(last) = merged.last_mut() {
|
||||
if last.row == rect.row && last.color == rect.color && last.col + last.cells as i32 == rect.col {
|
||||
if last.row == rect.row
|
||||
&& last.color == rect.color
|
||||
&& last.col + last.cells as i32 == rect.col
|
||||
{
|
||||
last.cells += rect.cells;
|
||||
continue;
|
||||
}
|
||||
@@ -601,7 +626,11 @@ fn selection_contains(selection: ViewportSelection, row: i32, col: i32) -> bool
|
||||
}
|
||||
|
||||
fn is_blank(cell: &alacritty_terminal::term::cell::Cell) -> bool {
|
||||
cell.c == ' ' && cell.zerowidth().is_none() && !cell.flags.intersects(Flags::ALL_UNDERLINES | Flags::STRIKEOUT)
|
||||
cell.c == ' '
|
||||
&& cell.zerowidth().is_none()
|
||||
&& !cell
|
||||
.flags
|
||||
.intersects(Flags::ALL_UNDERLINES | Flags::STRIKEOUT)
|
||||
}
|
||||
|
||||
fn is_default_bg(color: AnsiColor) -> bool {
|
||||
@@ -623,8 +652,8 @@ fn color_to_hsla(color: AnsiColor, foreground: bool, cx: &App) -> Hsla {
|
||||
|
||||
fn ansi_index_color(index: u8, _cx: &App) -> Hsla {
|
||||
const ANSI_16: [u32; 16] = [
|
||||
0x1f2430, 0xff5c57, 0x5af78e, 0xf3f99d, 0x57c7ff, 0xff6ac1, 0x9aedfe, 0xf1f1f0,
|
||||
0x686868, 0xff5c57, 0x5af78e, 0xf3f99d, 0x57c7ff, 0xff6ac1, 0x9aedfe, 0xffffff,
|
||||
0x1f2430, 0xff5c57, 0x5af78e, 0xf3f99d, 0x57c7ff, 0xff6ac1, 0x9aedfe, 0xf1f1f0, 0x686868,
|
||||
0xff5c57, 0x5af78e, 0xf3f99d, 0x57c7ff, 0xff6ac1, 0x9aedfe, 0xffffff,
|
||||
];
|
||||
|
||||
if (index as usize) < ANSI_16.len() {
|
||||
|
||||
Reference in New Issue
Block a user