summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 02:31:20 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitf749eb712d990a9b03f1db372d5311e77bd32edd (patch)
treeee4d9966f1eb293054b7ed865c9d4d6eb49e432b /src/exec.zig
parent8f6621f9f70db86d56266a59b56dfb92b324b0d9 (diff)
parentb3d32656413734952bc918c2d4cfd12fede6c214 (diff)
downloadpardes-f749eb712d990a9b03f1db372d5311e77bd32edd.tar.gz
pardes-f749eb712d990a9b03f1db372d5311e77bd32edd.zip
integration: the terminal behind src/Term.zig, with the diff viewer and the plumber's first phase
A merge of term-phase0 and pardes-next. File.zig's recolorSyntax keeps the theme's grounds and names Term.Filter and Term.Span; the changelog keeps both sides' entries, the palette sentence in the place of the entry the terminal work cut down. core-test 985/985 on tui; the diff, pager and tree process cases pass, goldens unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/exec.zig b/src/exec.zig
index 3593bb72..b4c20f45 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -165,44 +165,30 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l
return result;
}
}
- // In a diff, a file or hunk header, and a hunk line pointed at on its
- // `+`/`-`/` ` prefix, expand to the whole line (the hover shows it) and
- // the look is of the address it names (look.diffAddress), a regular
- // look from there. A hunk line's code is words, looked at as ever:
- // the code's, the prefix never one of them.
- // A query pane's row pointed at on its gutter (its line number): the
- // look is of the row's address (Query.rowAddress), as a +Diff line's
- // prefix is its place; the row's code is words, looked at as ever.
- if (for_look and pane.query != null and clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0 and col >= 0) gutter: {
- var address_buf: [4096 + 32]u8 = undefined;
- const address = panes.Query.rowAddress(pane, @intCast(row), @intCast(col), &address_buf) orelse break :gutter;
- const meta = pane.file.?.location_rows[@intCast(row)];
- result.text = p.scratch.allocator().dupe(u8, address) catch break :gutter;
- result.file_word = .{ .row = row, .lo = 0, .hi = @intCast(meta.location_end) };
- const expanded = fileWordCells(pane, clicked, row, 0, @intCast(meta.location_end)) orelse return result;
- result.preview = expanded;
- result.expanded = expanded;
- return result;
- }
+ // A row that names an address (look.rowAddressAt), pointed at on it: a
+ // query pane's row on its address (its gutter), a diff's file or hunk
+ // header anywhere, a hunk line on its `+`/`-`/` ` prefix. It expands
+ // to the address's text (the hover shows it) and the look is of the
+ // address, a regular look from there. A row's code is words, looked at
+ // as ever: the code's, the prefix never one of them. A click left of a
+ // query pane's text is no part of its row.
var word_from: usize = 0;
- if (for_look and clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0) diff: {
+ if (for_look and clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0 and (col >= 0 or pane.query == null)) row_address: {
var address_buf: [4096 + 32]u8 = undefined;
- const at: usize = @intCast(row);
- const click = look.diffClick(p, pane, at, @intCast(@max(0, col)), &address_buf) orelse break :diff;
- const address = click.address orelse {
- word_from = click.word_from;
- break :diff;
+ const got = look.rowAddressAt(p, pane, @intCast(row), @intCast(@max(0, col)), &address_buf) orelse break :row_address;
+ const address = got.address orelse {
+ word_from = got.word_from;
+ break :row_address;
};
- const line = (look.diffLines(p, pane) orelse break :diff)[at];
- result.text = p.scratch.allocator().dupe(u8, address) catch break :diff;
- const hi = std.math.cast(i32, line.len) orelse return result;
+ result.text = p.scratch.allocator().dupe(u8, address) catch break :row_address;
+ const hi = std.math.cast(i32, got.end) orelse return result;
if (hi == 0) return result;
var expanded = clicked;
if (pane.file != null) {
result.file_word = .{ .row = row, .lo = 0, .hi = hi };
expanded = fileWordCells(pane, clicked, row, 0, hi) orelse return result;
} else {
- const shown = if (raw) raw_line else line;
+ const shown = if (raw) raw_line else got.line;
expanded.c0 = 0;
expanded.c1 = @as(i32, @intCast(panes.File.rawDisplayCol(shown, shown.len))) - 1;
}
@@ -737,7 +723,7 @@ pub fn executeFrom(p: *Pardes, id: usize, txt: []const u8, from_body: bool) ?usi
/// is done, else a new one, placed as layout.placeNew places a command pane.
/// A pane reused keeps what it showed: the new command runs below a line
/// naming it, as acme appends to +Errors and never clears it (util.c:213).
-fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
+pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
if (line.len > command_max) {
p.reportFailure(from, "exec: a command line is at most 1024 bytes");
return null;
@@ -760,7 +746,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
// Nor one leased: an open that was answered its serial and is still
// open reads that pane's output, which another client's command must
// not replace; a new pane runs it instead.
- const reuse: ?usize = if (!p.exec_header and p.exec_column == null and src != null and src.?.command != null and src.?.command_done and !src.?.command_pty and !leased(p, src.?.serial)) from else for (p.panes, 0..) |slot, i| {
+ const reuse: ?usize = if (!p.exec_header and p.exec_column == null and p.exec_dir == null and src != null and src.?.command != null and src.?.command_done and !src.?.command_pty and !leased(p, src.?.serial)) from else for (p.panes, 0..) |slot, i| {
const other = slot orelse continue;
if (p.exec_column) |c| if (if (layout.findPane(p, i)) |f| f.col != c else true) continue;
if (other.command != null and other.command_done and !other.command_pty and std.mem.eql(u8, other.cwdSlice(), dir) and !leased(p, other.serial)) break i;