diff options
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/exec.zig b/src/exec.zig index 104e3b4d..47484105 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -176,21 +176,14 @@ pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand // the code's, the prefix never one of them. var word_from: usize = 0; if (clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0) diff: { - const lines = look.diffLines(p, pane) orelse break :diff; - const at: usize = @intCast(row); - if (at >= lines.len) break :diff; - const line = lines[at]; var address_buf: [4096 + 32]u8 = undefined; - const address = look.diffAddress(pane, lines, at, &address_buf) orelse break :diff; - const target = @import("diff.zig").targetAt(lines, at, pane.file == null).?; - const on_prefix = col == 0 and line.len > 0 and std.mem.indexOfScalar(u8, "+- ", line[0]) != null; - switch (target.kind) { - .context, .added, .removed => if (!on_prefix) { - word_from = @intFromBool(line.len > 0 and std.mem.indexOfScalar(u8, "+- ", line[0]) != null); - break :diff; - }, - else => {}, - } + 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 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; if (hi == 0) return result; @@ -799,6 +792,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { if (panes.terminal.onAlternateScreen(pane)) panes.terminal.feedOutput(p, pane, "\x1b[?1049l"); panes.terminal.feedOutput(p, pane, "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?2004l\x1b[?25h\x1b[0m"); echoCommand(p, pane, line); + pane.command_from = winid(p, src); p.emitSpawn(id, pane.serial, pane.cwdSlice()); noteRun(p, pane, "run", line); return id; @@ -811,12 +805,20 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { p.reportError(from, "exec", err); return null; }; + pane.command_from = winid(p, src); echoCommand(p, pane, line); placeNew(p, from, from, free, .command); noteRun(p, pane, "run", line); return free; } +/// The serial a command's `$winid` names: the pane it was run from, none +/// (0) from a column's or the workspace's tag. +fn winid(p: *const Pardes, src: ?*Pane) u32 { + if (p.exec_header) return 0; + return if (src) |s| s.serial else 0; +} + /// `% line` above a command's output, every command, as a shell echoes /// what it was given; its newlines the terminal's, so a multi-line command /// does not staircase. |
