Skip to content
Closed
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
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,5 @@ ELYTerminal. A terminal on GPUI and Ely components. `PRD.md` says what it does;
- 2026-10-24: Linux packages, which a user offered in PR #16: a DEB, an RPM and an AppImage beside the tarball, all four from one x86_64 binary built in Docker on Ubuntu 22.04, whose glibc 2.35 every package holds to: `linux_init` refuses a binary that asks for a newer one. The DEB's runtime libraries come from `dpkg-shlibdeps` over the binary and the RPM's from rpmbuild's own reading of it, beside what gpui loads at run time and what ELYTerminal starts, `git`, `curl` and `xdg-utils`; the AppImage bundles the keyboard libraries alone and leaves glibc, X11, Wayland, the graphics stack and the fonts to the host, and its tools download from fixed URLs checked by SHA-256. FreeType is linked in, as `freetype-sys` builds its own copy on Ubuntu 22.04, with its license and a lintian override that says why. The packaging workflow checks the scripts with `sh -n` and ShellCheck, lints the DEB, installs, reinstalls and removes the DEB on Ubuntu 22.04, 24.04 and Debian 12 and the RPM on Fedora 43, a settings file kept through each, and starts the installed DEB and the AppImage under Xvfb on software OpenGL, where software Vulkan drew black; it keeps the packages as artifacts and publishes nothing, so a release takes them through `scripts/release-asset.sh`: v0.1.9 took all four from the workflow's run on its commit, checked against the run's SHA-256. The merge kept main's decoder, so the packages carry libX11's notice for its tables, `libX11-lcUniConv`, where the PR named xim-rs's MIT license, and the PR's record of its own branch's checks stays in the PR, its claims about that branch no longer true of main. The tarball now carries ELYTerminal's own license and the fonts' too, and the man page, which the PR's tar script left in its stage; the README's install lines put the page under `~/.local/share/man/man1`, where Ubuntu 22.04's man-db finds it. The workflow's run on the merge, 40143259149, passed every step. On this Mac `scripts/linux-tar.sh` built the ARM64 tarball through the new builder, glibc 2.35, and the PR's GUI helper, in its Ubuntu 22.04 test image under Xvfb, found its window, its painted frame, its PTY and `终端测试` drawn.
- 2026-10-24: a maximized window on Linux takes every press, the right column's Git and Files switch among them, which a user found dead in issue #28 under GNOME 50.1's Wayland. Ely's `ResizeBorder` started a window resize from a press within its 10-pixel margin of the window's rim, measured on `window_bounds`, which gpui's Wayland window gives as the restore size while maximized or full screen, and on every edge, tiled or not; so in a window maximized from a smaller size, a press past that size's right or bottom margin, on the switch, the Files tree or the terminal, asked the compositor for a resize. Mutter kept the release of a maximized window, so no click landed; full screen it let the release through. Ely `fd1c7d9` on the pin's branch and `c360498` on its main measure on the viewport and resize from an untiled edge alone, so a maximized or full-screen window, tiled on every side, starts none; the window buttons and the headers' rows occlude what lies under them, so they always took their presses. The default log filter takes Ely's info lines, `ely_gpui_component=info`, so a resize Ely starts and a segment chosen show beside ELYTerminal's own: the report's log could not name the cause. Under headless GNOME 48.7 and 50.1 in Docker, a window kept at 800 by 560 on a 1200 by 900 screen: 0.1.8's switch took both presses in the normal window and none maximized, each logged as `window: resize from Right`, and full screen took them with the resize logged; this build's took every press in every state and logged no resize but the one a drag on the normal window's right margin started, which still widened it, and its restore button still restored it. The earlier runs had kept the default 1200 by 760, which GNOME maximized at once, so no press lay past the restore size.
- 2026-10-24: each update notification opens its own release's page, as T56 asked, whatever a later check found or is doing, which T89's review of the acceptance table found lost: the press read the page from the last check's state, which a Check now replaces while it runs, and with its error when it fails offline, so the press opened nothing. A notification now carries its release's tag, `elyterminal-update-VERSION`, and the app keeps each newer release's page by that tag, from every check that finds one, automatic or not; so a later release, found by a Check now or posted beside it, as Linux keeps every notification, leaves an older one's page, and the same release's notifications share a tag, the later taking the earlier's place where the system allows. A notification from an earlier run opens its page once a check of this run finds its release, and nothing, logged, before; 0.1.8's notifications, whose tag carries no version, pass to the sessions and are logged as no session's. ELYTerminal's tests hold no gpui test platform, whose `test-support` would add `proptest` and more to every platform's build, so a harness compiled the updater's own functions against stubs and pressed each notification by its tag in 20 cases: after it posted, while a Check now or the daily check ran, after one failed offline or read a malformed release, after a check found this version, an older one, the same release or a later one, beside a later release's notification, from an earlier run, and with automatic checks off. T89's third review had pressed the old code and opened nothing; T90's first pressed a fix that kept only the last page found, and the older notification opened the later release's page.
- 2026-10-27: on Windows a wheel over a full-screen program scrolls it, which the owner found dead in RPI's `--tui-mode fullscreen`, where the wheel moved the draft instead of the transcript above it. ConPTY drops a program's mouse DECSET: a program that writes `CSI ? 1000 h`, `1002 h` or `1006 h` to its stdout never has that byte reach the reader, so the tap's `Modes` never learns the program asked for the mouse and the view's `mouse` stays `Off`, while `1049 h`, `2004 h`, `1001 h`, `1015 h` and `1030 h` do reach it. The wheel therefore took the alternate-screen branch and sent arrows, which RPI's editor answered. ConPTY does translate an SGR mouse report written to its input pipe into a `MOUSE_EVENT` for the program, whether or not its own DECSET survived, so `TerminalView::wheel` sends an SGR report instead of arrows when the tap has never read a mouse mode, the pointer is over the alternate screen and Shift is not held; `saw_mouse` tells the two apart and a full reset clears it. `report` takes the format as an argument, since that path needs SGR where the program's own mode named another. Writing through `WriteConsoleW` with `ENABLE_VIRTUAL_TERMINAL_PROCESSING`, and `CreatePseudoConsole`'s flags, both leave the DECSET dropped, so neither is the answer; Windows Terminal's flags match alacritty's. A limit: a program on the alternate screen that wants no mouse, vim with its own scroll off among them, now takes the wheel as a report.
- 2026-10-27: an input method composing a newline no longer panics the app, which the owner found typing by voice on Windows: gpui's `shape_line` asserts its text holds no newline, and a composition that did reached it in `paint_preedit`, so the app died while the IME was still composing. A composition is drawn on one line now, each control character as its picture, `␊` for a newline, as `sessions::one_line` already drew labels; `composed` holds that and its test, since `draw` is shared with the grid's rows.
29 changes: 29 additions & 0 deletions src/term/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ impl MouseMode {
}
}

/// What a wheel event sends: the tracking and format the reports go in.
pub(super) fn asked(hidden: bool, tracking: Tracking, format: Format) -> (Tracking, Format) {
if hidden {
(Tracking::Button, Format::Sgr)
} else {
(tracking, format)
}
}

/// The bytes `report` sends; none when unasked for or past what the format holds.
pub fn encode(report: &Report, mode: MouseMode) -> Option<Vec<u8>> {
let clicked = matches!(
Expand Down Expand Up @@ -259,4 +268,24 @@ mod tests {
let far = report(LEFT, Gesture::Press, (2015, 0));
assert_eq!(encode(&far, utf8), None);
}

#[test]
fn a_hidden_mouse_mode_asks_for_the_wheel_in_sgr() {
// ConPTY drops a program's DECSET, so the tap never learned it: the wheel goes as an SGR report, which ConPTY translates for the program.
assert_eq!(
asked(true, Tracking::Off, Format::X10),
(Tracking::Button, Format::Sgr)
);
// A mode the tap did read holds, whatever it asked for.
let seen = mode(Tracking::Normal, Format::Utf8);
assert_eq!(
asked(false, seen.tracking, seen.format),
(seen.tracking, seen.format)
);
// Shift holds the mouse for selecting, so the wheel stays the terminal's.
assert_eq!(
asked(false, Tracking::Off, Format::Sgr),
(Tracking::Off, Format::Sgr)
);
}
}
23 changes: 20 additions & 3 deletions src/term/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::{
frame::{Cursor, Frame, Style, Underline},
view::TerminalView,
};
use crate::sessions;

/// How the grid paints: font, cell, metrics and the cursor's colors.
#[derive(Clone)]
Expand Down Expand Up @@ -106,6 +107,8 @@ fn paint_preedit(
look: &Look,
window: &mut Window,
) {
// gpui shapes no newline in a line of text, and a composition may hold one.
let text = composed(text);
let cell = look.cell;
let corner = origin + point(cell.width * column as f32, cell.height * row as f32);
let style = Style {
Expand All @@ -117,14 +120,14 @@ fn paint_preedit(
underline_color: look.fg,
strike: false,
};
let runs = runs(text, &style, look.fg, look, window);
let runs = runs(&text, &style, look.fg, look, window);
let width = window
.text_system()
.shape_line(text.to_string().into(), look.size, &runs, None)
.shape_line(text.as_str().into(), look.size, &runs, None)
.width
.max(cell.width);
window.paint_quad(fill(Bounds::new(corner, size(width, cell.height)), look.bg));
draw(text, &runs, corner, None, look, window);
draw(&text, &runs, corner, None, look, window);
decorate(corner, width, &style, look, window);
}

Expand Down Expand Up @@ -230,6 +233,11 @@ fn text(
draw(content, &runs, origin, None, look, window);
}

/// A composition on one line, as gpui shapes text: a newline becomes its picture.
fn composed(text: &str) -> String {
sessions::one_line(text)
}

/// Shapes `content` and paints each glyph on the cell's baseline below `top`; `force` sets every advance.
fn draw(
content: &str,
Expand Down Expand Up @@ -487,4 +495,13 @@ mod tests {
assert!(!private('a'));
assert!(!private('中'));
}

#[test]
fn a_composition_holds_no_newline_gpui_would_shape_as_lines() {
// gpui's shape_line asserts its text has no newline, so a composition
// with one used to panic the app while a Chinese IME was composing.
assert_eq!(composed("中文"), "中文");
assert_eq!(composed("a\nb"), "a␊b");
assert!(!composed("line\r\nbreak").contains('\n'));
}
}
76 changes: 67 additions & 9 deletions src/term/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use gpui::{
use super::{
keys,
links::link_at,
mouse::{self, Button, Gesture, MouseMode, Report, Tracking},
mouse::{self, Button, Format, Gesture, MouseMode, Report, Tracking},
view::TerminalView,
wheel,
};
Expand Down Expand Up @@ -72,13 +72,26 @@ impl TerminalView {
}
}

/// The tracking and format a report goes in, over the alternate screen, when
/// ConPTY hid the program's mouse mode: it still takes the mouse, and ConPTY
/// translates an SGR report for it whether or not its DECSET survived.
fn conpty(&self, tracking: Tracking) -> (Tracking, Format, bool) {
let hidden = cfg!(windows)
&& tracking == Tracking::Off
&& !self.saw_mouse
&& self.pty.term.lock().mode().contains(TermMode::ALT_SCREEN);
let (tracking, format) = mouse::asked(hidden, tracking, self.mouse.format);
(tracking, format, hidden)
}

fn report(
&mut self,
button: Option<Button>,
gesture: Gesture,
cell: (usize, usize),
modifiers: &Modifiers,
tracking: Tracking,
format: Format,
) -> bool {
let wheel = matches!(button, Some(Button::WheelUp | Button::WheelDown));
// herdr's link key is Ctrl; on macOS Cmd stands for it, the wheel aside.
Expand All @@ -91,7 +104,6 @@ impl TerminalView {
alt: modifiers.alt,
ctrl: modifiers.control || link,
};
let format = self.mouse.format;
let Some(bytes) = mouse::encode(&report, MouseMode { tracking, format }) else {
return false;
};
Expand All @@ -115,6 +127,7 @@ impl TerminalView {
event.modifiers.control
};
let tracking = self.tracking(&event.modifiers);
let (tracking, format, hidden) = self.conpty(tracking);
// herdr opens its panes' links itself, whole where its drawing wraps them.
let herdr = self.herdr && tracking != Tracking::Off;
if event.button == MouseButton::Left && opens && herdr {
Expand All @@ -140,10 +153,17 @@ impl TerminalView {
cell,
&event.modifiers,
tracking,
format,
) && !self.pointer.pressed.contains(&pressed)
{
self.pointer.pressed.push(pressed);
}
if hidden {
log::debug!(
"terminal {}: ConPTY hides the mouse mode, so a press reports at {cell:?}",
self.pty.pid
);
}
return;
}
if event.button != MouseButton::Left {
Expand Down Expand Up @@ -196,11 +216,19 @@ impl TerminalView {
return;
}
let tracking = self.tracking(&event.modifiers);
let (tracking, format, _) = self.conpty(tracking);
if tracking != Tracking::Off && self.pointer.last != Some(cell) {
let held = [Button::Left, Button::Right, Button::Middle]
.into_iter()
.find(|button| self.pointer.pressed.contains(button));
self.report(held, Gesture::Motion, cell, &event.modifiers, tracking);
self.report(
held,
Gesture::Motion,
cell,
&event.modifiers,
tracking,
format,
);
}
}

Expand Down Expand Up @@ -263,7 +291,15 @@ impl TerminalView {
if self.pointer.pressed.contains(&released) {
self.pointer.pressed.retain(|held| *held != released);
let tracking = self.mouse.tracking;
self.report(Some(released), Gesture::Release, cell, modifiers, tracking);
let (tracking, format, _) = self.conpty(tracking);
self.report(
Some(released),
Gesture::Release,
cell,
modifiers,
tracking,
format,
);
}
}

Expand Down Expand Up @@ -297,19 +333,41 @@ impl TerminalView {
event.delta
);
let (cell, ..) = self.cell_at(event.position);
let tracking = self.tracking(&event.modifiers);
let mode = *self.pty.term.lock().mode();
let held = self.tracking(&event.modifiers);
let (tracking, format, hidden) = self.conpty(held);
if tracking != Tracking::Off {
let turn = if lines > 0 {
Button::WheelUp
} else {
Button::WheelDown
};
for _ in 0..lines.unsigned_abs() {
self.report(Some(turn), Gesture::Press, cell, &event.modifiers, tracking);
self.report(
Some(turn),
Gesture::Press,
cell,
&event.modifiers,
tracking,
format,
);
}
} else if mode.contains(TermMode::ALT_SCREEN | TermMode::ALTERNATE_SCROLL) {
let arrow: &[u8] = match (lines > 0, mode.contains(TermMode::APP_CURSOR)) {
if hidden {
log::debug!(
"terminal {}: ConPTY hides the mouse mode, so the wheel reports {lines} lines",
self.pty.pid
);
}
} else if self
.pty
.term
.lock()
.mode()
.contains(TermMode::ALT_SCREEN | TermMode::ALTERNATE_SCROLL)
{
let arrow: &[u8] = match (
lines > 0,
self.pty.term.lock().mode().contains(TermMode::APP_CURSOR),
) {
(true, true) => b"\x1bOA",
(true, false) => b"\x1b[A",
(false, true) => b"\x1bOB",
Expand Down
9 changes: 8 additions & 1 deletion src/term/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub struct TerminalView {
pub(super) pointer: Pointer,
/// The mouse mode, as the tap follows it.
pub(super) mouse: MouseMode,
/// Whether the tap has ever read a mouse mode, so ConPTY is not hiding it.
pub(super) saw_mouse: bool,
/// Keys go as Windows' records, as ConPTY asks.
#[cfg(windows)]
pub(super) win32: bool,
Expand Down Expand Up @@ -138,6 +140,7 @@ impl TerminalView {
caret: Bounds::default(),
pointer: Pointer::default(),
mouse: MouseMode::default(),
saw_mouse: false,
#[cfg(windows)]
win32: false,
herdr: false,
Expand Down Expand Up @@ -275,7 +278,10 @@ impl TerminalView {
cx.emit(TerminalEvent::Folder(folder));
}
PtyEvent::Term(event) => self.term_event(event, cx),
PtyEvent::Mouse(mode) => self.mouse = mode,
PtyEvent::Mouse(mode) => {
self.mouse = mode;
self.saw_mouse = true;
}
#[cfg(windows)]
PtyEvent::Win32(on) => self.win32 = on,
PtyEvent::Mark(Mark::Done(status), _) => self.finished(status, cx),
Expand Down Expand Up @@ -303,6 +309,7 @@ impl TerminalView {
PtyEvent::Reset => {
self.records.reset();
self.title.clear();
self.saw_mouse = false;
cx.emit(TerminalEvent::Title(String::new()));
self.restate(cx);
}
Expand Down