summaryrefslogtreecommitdiff
path: root/core/term
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 18:35:03 -0300
committerGabriel Schneider <[email protected]>2026-11-27 12:56:41 -0300
commit7583f9a1d8342c6d779ef32cd40fa2cde5cf8977 (patch)
treecdc994a37e0a9e61cd246c738e5257486bb156c8 /core/term
parent9890f44e4a18f08b6dcc62a69484b8e93640e1e6 (diff)
downloadpardes-7583f9a1d8342c6d779ef32cd40fa2cde5cf8977.tar.gz
pardes-7583f9a1d8342c6d779ef32cd40fa2cde5cf8977.zip
Panes say they are Ghostty (TERM_PROGRAM=ghostty, TERM_PROGRAM_VERSION=1.4.0, the pinned ghostty whose VT every pane runs), and a Look on a link (OSC 8) in a terminal takes its URI: the user's report of 2026-11-27 ("the terminal applications aren't detecting that we have kitty graphics support (codex for example)") and ruling ("Posing as ghostty is fine by me, it's a good measure for us to have feature parity with it anyways"); THE CAUSE: codex 0.172 decides on kitty images from the environment alone (a terminal-name list, TERM/TERM_PROGRAM substrings, KITTY_WINDOW_ID, WEZTERM_*; its kitty query only for TERM_PROGRAM=herdr; pets never ask), and panes said TERM_PROGRAM=pardes and inherited the launcher's TERM_PROGRAM_VERSION (rex's under rex); pardes answers codex's own probe (`\e_Gi=31;OK\e\\` before DA1) and draws its `a=T,f=100,c,r,C=1` image (.scratch/kp/run.py, run_img.py); WHY THE LINK: a program that knows it is in Ghostty shows a link's label alone (codex's web_link_display), and pardes kept OSC 8 only in the dump: the URL would be nowhere to Look at; THE CHANGE: config.child_term_program "ghostty", child_term_program_version "1.4.0" (host_io.ChildEnv writes it over the inherited one); Term op `link` (abi/term.zig, replicated as textRows is: READ, NOT COVERED, core/Term.zig's S1 row exec.zig:1): the URI of cell x of a row (from the top of the history) and its run's cells on that row, counted in the text with the prompt cut when out of tty mode; exec.operandAt (every entry point: B3, hover, Enter in normal mode, a bare Look): a look at a link takes its URI, a `file://` one its path (the host dropped, %XX decoded), expanded to the label's cells; an exec takes the label's word as before; docs/macos.md's identity paragraph; NOT DONE (Ghostty parity, listed for later): OSC 9/777 notifications, OSC 9;4 progress, OSC 22 pointer shapes, OSC 10/11 colour answers (the `dark` theme takes the host terminal's colours and views differ per client: a design first); RUN (TEST FIRST): exec.zig "a look at a link (OSC 8) in a terminal takes its URI, a file:// one its path, and expands to the label; out of tty mode too" (an https link and a file://box/tmp/a%20b.txt one, in tty and normal mode; off the link `see`, an exec `docs`): fails with the branch off (`the` for `https://ziglang.org`), passes now; REAL CHECK (.scratch/kp/link_e2e.py: this tree's Debug pardes --tty in a pty, TERM_PROGRAM=rex and TERM_PROGRAM_VERSION=9.9.9-outer outside): the shell pane printed `TP=ghostty TPV=1.4.0`; an SGR B3 on plain text beside the link opened nothing; on the label (file://somehost/…/target%20dir/linked.txt) it opened `target dir/linked.txt`; GATES (Debug tui): core-test 1165/1343 (178 skipped), shell-test 1392/1395 (3 skipped), term-test 17/17, kitty-test 45/45, process-test rc 0, behaviour-test 293/293
Diffstat (limited to 'core/term')
-rw-r--r--core/term/term.zig1
-rw-r--r--core/term/terminal.zig30
2 files changed, 31 insertions, 0 deletions
diff --git a/core/term/term.zig b/core/term/term.zig
index 025f7239..e6250aae 100644
--- a/core/term/term.zig
+++ b/core/term/term.zig
@@ -51,6 +51,7 @@ pub const ops: iface.Ops = .{
.editRows = cast(iface.Ops, "editRows", terminal_.editRows),
.promptCut = cast(iface.Ops, "promptCut", terminal_.promptCutAt),
.echoCell = cast(iface.Ops, "echoCell", terminal_.echoCell),
+ .link = cast(iface.Ops, "link", terminal_.link),
.page = pager.parse,
.filter = terminal_.pagerFilter,
.spanColor = terminal_.spanColor,
diff --git a/core/term/terminal.zig b/core/term/terminal.zig
index 12306957..d31545f5 100644
--- a/core/term/terminal.zig
+++ b/core/term/terminal.zig
@@ -1122,6 +1122,36 @@ pub fn echoCell(state: *const State, x: u16, y: u16) ?Term.EchoCell {
return .{ .cp = ci.cell.codepoint(), .input = ci.cell.semantic_content == .input, .style = ci.cell.style_id };
}
+/// The link (OSC 8) cell `x` of row `row` (from the top of the history)
+/// carries, and the cells its run takes on that row; `cut`: counted in the
+/// row's text, its prompt's own cells cut off (promptCut).
+pub fn link(state: *State, row: i32, x: u16, cut: bool) ?Term.Link {
+ if (row < 0) return null;
+ const pin = state.vt.screens.active.pages.pin(.{ .screen = .{ .x = 0, .y = @intCast(row) } }) orelse return null;
+ const shift: usize = if (!cut or pin.rowAndCell().row.semantic_prompt == .none) 0 else switch (promptCut(pin)) {
+ .keep => 0,
+ .blank => return null,
+ .cut => |n| n,
+ };
+ const cells = pin.cells(.all);
+ const at = @as(usize, x) + shift;
+ if (at >= cells.len) return null;
+ const page = pin.node.page();
+ if (!cells[at].hyperlink) return null;
+ const id = page.lookupHyperlink(&cells[at]) orelse return null;
+ var lo = at;
+ while (lo > shift and sameLink(page, &cells[lo - 1], id)) lo -= 1;
+ var hi = at + 1;
+ while (hi < cells.len and sameLink(page, &cells[hi], id)) hi += 1;
+ const uri = page.hyperlink_set.get(page.memory, id).uri.slice(page.memory);
+ return .{ .uri = uri, .lo = @intCast(lo - shift), .hi = @intCast(hi - shift) };
+}
+
+fn sameLink(page: *const ghostty_vt.page.Page, cell: *const ghostty_vt.page.Cell, id: anytype) bool {
+ if (!cell.hyperlink) return false;
+ return (page.lookupHyperlink(cell) orelse return false) == id;
+}
+
fn promptRow(pin: ghostty_vt.Pin, raw: []const u8) []const u8 {
const cols = switch (promptCut(pin)) {
.keep => return raw,