Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions AGENTS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ anyhow = "1"
base64 = "0.22"
base64-simd = "0.8"
dirs = "7"
ely-gpui-component = { git = "https://github.com/ELY-Open-Source/Ely-GPUI-Components.git", rev = "b0350ad820827fd498d3da0bccec3e548326ff31" }
ely-gpui-component = { git = "https://github.com/2youg1/Ely-GPUI-Components.git", rev = "0f628c2126b3f29fafa3a21cee861356e5b25d68" }
env_logger = "0.11"
flate2 = { version = "1.1", default-features = false, features = ["rust_backend"] }
futures = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Ghostty is the bar for what the terminal does, 1.4's kitty graphics, clipboard,
- Clipboard: copy, paste (bracketed when asked), copy on select per setting, OSC 52 writes.
- Kitty's clipboard protocol, OSC 5522, as Ghostty 1.4 takes it: writes up to 64 MiB allowed; each read asks first, showing what it would read, with a choice to allow a program's password for the session; text, images and file lists, written and read alike on every system; under mode 5522 a paste lists the clipboard's types with a password for one read.
- Kitty graphics, as Ghostty 1.4 takes them: images sent direct, from a file, a temporary file or shared memory, RGB, RGBA or PNG, zlib, in chunks, within a session's quota; placed at the cursor under the ground, between it and the text or over the text, cut and sized as asked, moving with scrolls, clears and resizes; Unicode placeholders and relative placements; animation, its frames composed and played on their clock, paused while its session is hidden. Payloads decode through SIMD. A hidden session gives its images' GPU textures back.
- Drop: files dropped on the terminal type their paths at the cursor, as macOS Terminal does, each kept literal for the session's shell and followed by a space.
- Drop: files dropped on the terminal type their paths at the cursor, as macOS Terminal does, each kept literal for the session's shell and followed by a space; a file or folder dragged from Files types its path the same way.
- Links: OSC 8 and plain URLs; Cmd-press (Ctrl-press off macOS) opens them. Inside herdr, while it takes the mouse, herdr opens them, web links only, as herdr does, whole where its pane wraps them, and underlines them while the key is held; with Shift the terminal opens what it sees.
- Focus reporting, title (OSC 0/2), scrollback limit per setting, find in scrollback (Ely's `FindWidget`).
- Idle history packed small, unpacked as it is read, on every system, as Ghostty 1.4 compresses its scrollback.
Expand Down
1 change: 1 addition & 0 deletions TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,4 @@ Each task ends with a short thanks on its issue or pull request, then closes it.
- [x] T136 Issues #42 and #50: a Homebrew tap, `ELY-Open-Source/homebrew-tap`, with a cask, and a winget manifest for the portable zip, each refreshed by a script at a release; the install guides tell SmartScreen's prompt from a Defender detection and say how to report a false positive.
- [x] T137 The README, its Chinese twin and the guides say what 0.2.1 does; PRD, AGENTS.md and the acceptance table hold T130 to T136.
- [x] T138 Release 0.2.1: the version raised, every build on the release, the notes in English and Chinese, the cask and the winget PR following, each issue answered.
- [ ] T139 A file or folder dragged from Files onto the terminal types its path at the cursor, kept literal for the session's shell and followed by a space, as an OS file drop does: Ely's Tree rows already drag a TreeDrag value, now public (ELY-Open-Source/Ely-GPUI-Components#9), so the terminal listens for it, asks the workspace to resolve the key through Files, and types the path as a paste.
2 changes: 1 addition & 1 deletion src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl Files {
}

/// The path a tree key stands for: the root, or an entry read.
fn path(&self, of: &str) -> Option<PathBuf> {
pub fn path(&self, of: &str) -> Option<PathBuf> {
self.named(of).map(|(path, _)| path)
}

Expand Down
17 changes: 14 additions & 3 deletions src/term/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
use std::path::PathBuf;

use anyhow::Context as _;
use ely_gpui_component::lists::TreeDrag;
use gpui::{Context, ExternalPaths};

use super::view::TerminalView;
use super::view::{TerminalEvent, TerminalView};

/// What a POSIX shell reads specially in a path: Ghostty's list, and zsh's `extendedglob` marks.
const SPECIAL: &str = "\\ ()[]{}<>\"'`!#$&;|*?^~";
Expand Down Expand Up @@ -72,7 +73,17 @@ pub fn typed(paths: &[PathBuf], quote: Quote) -> anyhow::Result<String> {
impl TerminalView {
/// Types the dropped paths at the cursor as a paste; a path it cannot type stops the drop.
pub(super) fn drop_paths(&mut self, dropped: &ExternalPaths, cx: &mut Context<Self>) {
let (paths, quote) = (dropped.paths(), self.pty.quote);
self.type_paths(dropped.paths(), cx);
}

/// A Files node's drag landed here; its owner resolves the key to a path.
pub(super) fn dragged(&mut self, drag: &TreeDrag, cx: &mut Context<Self>) {
cx.emit(TerminalEvent::Dragged(drag.key().clone()));
}

/// Types `paths` at the cursor as a paste; a path the session's shell cannot take typed stops it.
pub fn type_paths(&mut self, paths: &[PathBuf], cx: &mut Context<Self>) {
let quote = self.pty.quote;
match typed(paths, quote) {
Ok(text) => {
log::info!(
Expand All @@ -83,7 +94,7 @@ impl TerminalView {
self.paste_text(&text, cx);
}
Err(error) => log::error!(
"terminal {}: the drop types nothing: {error:#}",
"terminal {}: the paths type nothing: {error:#}",
self.pty.pid
),
}
Expand Down
7 changes: 6 additions & 1 deletion src/term/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ use alacritty_terminal::{
};
use ely_gpui_component::{
forms::{Copy, Paste, SelectAll},
lists::TreeDrag,
theme::ActiveTheme,
};
use futures::StreamExt;
use gpui::{
Bounds, Context, EventEmitter, ExternalPaths, FocusHandle, Focusable, IntoElement, MouseButton,
ParentElement, Pixels, Render, Styled, Subscription, Task, Window, div, prelude::*, px,
ParentElement, Pixels, Render, SharedString, Styled, Subscription, Task, Window, div,
prelude::*, px,
};

use super::{
Expand Down Expand Up @@ -57,6 +59,8 @@ pub enum TerminalEvent {
/// Its last command's status changed, to this one.
Ended(Option<i32>),
Exited(ExitStatus),
/// A Files node's drag landed on it: the node's tree key.
Dragged(SharedString),
}

/// A program on a pseudo-terminal, drawn cell by cell in the theme and font the settings choose.
Expand Down Expand Up @@ -361,6 +365,7 @@ impl Render for TerminalView {
.on_mouse_move(cx.listener(Self::mouse_move))
.on_scroll_wheel(cx.listener(Self::wheel))
.on_drop(cx.listener(|view, paths: &ExternalPaths, _, cx| view.drop_paths(paths, cx)))
.on_drop(cx.listener(|view, drag: &TreeDrag, _, cx| view.dragged(drag, cx)))
.size_full()
.px(px(settings.padding_x))
.py(px(settings.padding_y))
Expand Down
14 changes: 14 additions & 0 deletions src/workspace/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ impl Workspace {
session.waiting = true;
}
TerminalEvent::Shows(_) | TerminalEvent::Ended(_) => {}
TerminalEvent::Dragged(key) => {
if index != self.active {
return;
}
match self.files.read(cx).path(key) {
Some(path) => {
log::info!("app: {} dragged onto the terminal", path.display());
session
.terminal
.update(cx, |view, cx| view.type_paths(&[path], cx));
}
None => log::warn!("app: a tree drag of {key} types nothing"),
}
}
TerminalEvent::Exited(status) => {
let pid = session.terminal.read(cx).pid();
log::info!("app: session {pid}'s program ended, {status}");
Expand Down
2 changes: 1 addition & 1 deletion tasks/acceptance.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ What no check reached: issue #29's physical keyboard and fcitx5's own forwarding
| A scrollbar over the history: a drag on its thumb scrolls, whatever the program does with the wheel | T58 | `term::scrollbar` test: the thumb's share and place follow the history and the view's offset, and a place past either end of the track holds at it; under Xorg's dummy screen, after `seq 1 500`, the thumb stood at the bottom right, a drag to the top showed the first prompt and lines 1 to 39, and one back down lines 220 to 259; with mouse tracking on, the wheel went to the program as reports and did not scroll, while a drag on the thumb showed lines 245 to 284 | Pass |
| Windows 10: dragging a blurred window follows the pointer, its acrylic clear while it moves | T65 | on the owner's Windows 11 PC (build 26300) the release path logged `blur: Windows build 26300 moves acrylic as it is`; a probe build with the build check raised logged `acrylic clears while the window moves`, and a drag by the terminal's header moved the window 180 by 90 pixels, logged `the window moves clear` and `the window rests blurred again`, and pictured clear glass mid-drag and acrylic at rest; round 1 of T65's review found that blur turned on mid-move, which gpui sets as acrylic at once, kept acrylic for the rest of the move: a moving mark now clears it again, and the reviewer's replay of the procedure and the blur's changes against recorded Win32 calls passed its 9 cases, a blur turned on and on again mid-move among them; the drag on the PC logged both switches again; Windows 10 went untested | Pass |
| IME on Windows: the candidate box at the caret | T61 | on the owner's Windows 11 PC at 150%, WeType under powershell.exe: 23 compositions, on one line, on lines below, begun again at once after a commit, and under a status line redrawn every 100 ms, each logged `the input method asks for the caret` at the cursor's cell and drew the box under it; the user's jump did not reproduce and the owner closed it | Closed |
| Drop: files dropped on the terminal type their paths at the cursor, kept literal for the session's shell, each followed by a space | T66 | `term::drop` tests: a POSIX path escapes what a shell reads specially, spaces, quotes, parentheses, `&`, `$`, `^`, `~` and `#` among them, CJK kept, each path followed by a space; a PowerShell path is single-quoted with its quotes doubled, curly ones too; a cmd path is double-quoted, and one holding `%` types nothing; a path with a control character types nothing; `term::shell` test: zsh, fish and other shells take POSIX quoting, pwsh and powershell PowerShell's, cmd cmd's; round 1 of T66's review found Windows' quotes around a spaced path alone leaving `$(...)` and `;` live in PowerShell, and `^` unescaped under zsh's `extendedglob`: the formatter, extracted, typed 22 hard names that zsh with and without `extendedglob`, bash with `extglob`, fish and PowerShell each read back exactly, `it's`, `$HOME`, `$(1+1)`, `a;Write-Output(42)` and curly quotes among them, and cmd on the owner's PC echoed `&`, `|`, `<`, `>` and `^` inside its quotes back as text while it expanded `%PATH%`; round 2 found cmd's `/v:on` expanding `!` inside quotes, and `"C:\"` read by a program as one argument with the next: a `!` now stops a cmd drop, and the backslashes ending a path are doubled, so node, run from a cmd batch line on the owner's PC, received `C:\`, `D:\clip.mp4`, `C:\My Files\a&b^c.txt`, `C:\x|y<z>(1).txt`, `C:\dir with space\` and `C:\tmp\a;b,c=d.txt` exactly; on macOS `shot` dropped `/tmp/my file.png`, `/Users/x/it's (1).txt` and `/a/中文 b` on zsh after a pointer move, and the log read `3 paths dropped` and `pastes 53 characters, bracketed`; without the move, after typing, gpui passed the drop by, as AGENTS records | Pass |
| Drop: files dropped on the terminal type their paths at the cursor, kept literal for the session's shell, each followed by a space | T66 | `term::drop` tests: a POSIX path escapes what a shell reads specially, spaces, quotes, parentheses, `&`, `$`, `^`, `~` and `#` among them, CJK kept, each path followed by a space; a PowerShell path is single-quoted with its quotes doubled, curly ones too; a cmd path is double-quoted, and one holding `%` types nothing; a path with a control character types nothing; `term::shell` test: zsh, fish and other shells take POSIX quoting, pwsh and powershell PowerShell's, cmd cmd's; round 1 of T66's review found Windows' quotes around a spaced path alone leaving `$(...)` and `;` live in PowerShell, and `^` unescaped under zsh's `extendedglob`: the formatter, extracted, typed 22 hard names that zsh with and without `extendedglob`, bash with `extglob`, fish and PowerShell each read back exactly, `it's`, `$HOME`, `$(1+1)`, `a;Write-Output(42)` and curly quotes among them, and cmd on the owner's PC echoed `&`, `|`, `<`, `>` and `^` inside its quotes back as text while it expanded `%PATH%`; round 2 found cmd's `/v:on` expanding `!` inside quotes, and `"C:\"` read by a program as one argument with the next: a `!` now stops a cmd drop, and the backslashes ending a path are doubled, so node, run from a cmd batch line on the owner's PC, received `C:\`, `D:\clip.mp4`, `C:\My Files\a&b^c.txt`, `C:\x|y<z>(1).txt`, `C:\dir with space\` and `C:\tmp\a;b,c=d.txt` exactly; on macOS `shot` dropped `/tmp/my file.png`, `/Users/x/it's (1).txt` and `/a/中文 b` on zsh after a pointer move, and the log read `3 paths dropped` and `pastes 53 characters, bracketed`; without the move, after typing, gpui passed the drop by, as AGENTS records; T139: a Files node's drag lands on the terminal through Ely's now-public `TreeDrag` (`ely_gpui_component::lists::TreeDrag`, ELY-Open-Source/Ely-GPUI-Components#9 on the pin's branch): the terminal's second `on_drop` emits the node's key, the workspace resolves it through `Files::path` and calls `type_paths`, which types it with the drop's quoting and its log; `files` test: a tree key keeps its path, the resolver the drag relies on. The drag itself, from a row onto the terminal, awaits a manual pass on macOS, Windows and Linux | Partial |
| Click to move: a plain click on the line the shell reads, past its prompt, moves its cursor there, the press itself to a shell that takes clicks, else arrows | T59 | `term::marks` test: A's `click_events=1` and `2` read as a press at the screen's row or counted from the prompt; `term::click` tests: a shell that takes clicks hears an SGR left press at the clicked cell, a row below the prompt too, none before the prompt, in the history or on the alternate screen; B reads the line its prompt started; a click on the typed line counts the characters to it, left or right, past the end means the end, a wide character takes one arrow, soft-wrapped rows are one line, trailing spaces count up to the cursor, and a click on the prompt, another line, a line no prompt shows, output without marks or the alternate screen moves nothing; on macOS `shot` ran zsh with a marked prompt: after `echo hello` a click on the `h` logged `moves the cursor -5`, and `X` typed then ran `echo Xhello`; a drag sent nothing, and clicks on the prompt and on output logged `off the input`; round 1 of T59's review found fish 4.9 a code point per Left, so a count put `X` inside `é`, and its redraw dropped the wrap flag a count followed: with fish's own `click_events=1` the press goes to fish, which then typed `echo Xéabc`, and a second click on the redrawn wrapped line put `Y` at row 2, column 3; zsh still counted 4 arrows; a press let go in another cell and one whose program turned on tracking before the release sent nothing; round 2 found a click on fish's `$` sent to fish, which moved its cursor to the start: a press now goes only past the prompt's last cell before the cursor and never on a prompt cell, so clicks on `$` and its space logged `off the input` and `X` still ended `echo helloX`; round 3 found that a prompt whose only cells lie after the cursor, fish's empty left prompt beside a marked right one, crashed the press: with no prompt cell before the cursor the input starts at the prompt's first row, and a click on `o` there put `X` at `echXo`; round 3 found that a prompt that prints nothing left no cells to find the input by, so clicks on fish's typed line did nothing: B now stamps the typed line with a link of its own, numbered by the commands ended, so fish's empty prompt gave `abcXdef`, with a plain or no right prompt too, a click on the output above moved nothing, and fish's right prompt drawn again at each key kept the typed line's number, `echXo`; `term::prompts` test: input carries the commands ended before it, through a prompt drawn again; `term::click` tests: a prompt that prints nothing starts the input at its first typed cell, the output and the line run before refused; round 4 found the newest typed line taken by its place: after `printf '\e[H'` fish drew its prompt at the top over older lines, and a click on its typed line did nothing; the newest line is now the one of the highest number, and a press goes no lower than its last row or the cursor's, so that click gave `abcXdef`, the reviewer's scene sent `ESC[<0;6;1M`, and a click on the older text below moved nothing, where fish had moved its cursor | Pass |
| A bell makes no sound; the row marks it | T10, T12 | T12 review | Pass |
| CSI 16 t answers a cell's size in pixels | T131 | vte `8fa83a9` dispatches it, alacritty `d2781ca` answers it; `a_cell_size_query_is_answered_through_conpty` on the owner's PC reads `ESC[6;16;8t` through the bundled OpenConsole, where a probe saw 16 t dropped before; review round 1 | Pass |
Expand Down