summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pardes.zig34
-rw-r--r--test/snapshots/ttylook.golden279
-rw-r--r--test/snapshots/ttylook.snap77
3 files changed, 390 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 88b10374..ac543aeb 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -1545,6 +1545,9 @@ pub const Pardes = struct {
if (pane.file != null and is(key, '/')) return p.startSearch(pane);
if (pane.file != null and is(key, 'n')) return p.searchStep(pane, 1);
if (pane.file != null and is(key, 'N')) return p.searchStep(pane, -1);
+ // terminal n/N: look the next/previous output row that looks somewhere
+ if (pane.isTerminal() and is(key, 'n')) return p.lookStep(pane, pl, 1);
+ if (pane.isTerminal() and is(key, 'N')) return p.lookStep(pane, pl, -1);
}
// ---- file search (`/` + n/N): grep into a shell pane, look the results ----
@@ -1632,6 +1635,37 @@ pub const Pardes = struct {
// no result that way (or none at all): nowhere to go, stay put
}
+ /// n/N on a terminal pane (normal mode): select the next/previous output
+ /// row whose leading file-ish word looks somewhere — resolves to a
+ /// file/dir/path:NNN exactly as a right click would — and look it. The
+ /// scan only resolves (realpath, no pane opens, no scrolls); the one
+ /// chosen row gets the real look. The modal cursor is the position, so
+ /// the walk continues from wherever j/k left it. The look may focus what
+ /// it opened; focus comes back here so the next n keeps stepping.
+ fn lookStep(p: *Pardes, pane: *Pane, pl: PaneLines, delta: i32) void {
+ const id = p.active;
+ const nrows: i32 = @intCast(pl.lines.len);
+ var realbuf: [4096]u8 = undefined;
+ var r = pane.cur_row + delta;
+ while (r >= 0 and r < nrows) : (r += delta) {
+ const ln = pl.lines[@intCast(r)];
+ var hi: usize = 0;
+ while (hi < ln.len and look.isFileChar(ln[hi])) hi += 1;
+ if (hi == 0 or look.resolve(ln[0..hi], pane.cwdSlice(), &realbuf) == .none) continue;
+ pane.msel = .{ .active = true, .r0 = r, .r1 = r };
+ pane.vsel.active = false;
+ pane.cur_row = r;
+ pane.cur_col = 0;
+ pane.cur_off = 0;
+ pane.cur_pinned = true;
+ pane.ensureCursorVisible();
+ p.actOnSelection(.right, id, ln[0..hi], null);
+ p.active = id;
+ return;
+ }
+ // nothing lookable that way: stay put
+ }
+
const InsertAt = enum { at, append, line_start, line_end, open_below, open_above };
fn enterInsert(p: *Pardes, pane: *Pane, where: InsertAt) void {
diff --git a/test/snapshots/ttylook.golden b/test/snapshots/ttylook.golden
new file mode 100644
index 00000000..ce42d94f
--- /dev/null
+++ b/test/snapshots/ttylook.golden
@@ -0,0 +1,279 @@
+== snap lsrow grid=120x30 cursor=2,2
+|Kill Newcol Tutor Debug Colors NextColor Dump
+| nm /tmp/pardes-snap/ttylook/cwd/big.txt Save Del nm /tmp/pardes-snap/ttylook/cwd Del
+| 1 line 1
+| 2 line 2 big.txt plain.txt sub
+| 3 line 3
+| 4 line 4
+| 5 line 5
+| 6 line 6
+| 7 line 7
+| 8 line 8
+| 9 line 9
+| nm /tmp/pardes-snap/ttylook/cwd Del
+| big.txt:20
+| ww
+|
+| plain.txt
+| big.txt:33
+| zz
+|
+| DONE
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+|
+| big.txt plain.txt sub
+|
+|
+|
+|
+|
+|
+== style lsrow
+|0: 0-44 #969696,#2c2a3e, 45-119 d,#2c2a3e,
+|1: 0-1 d,#383c54, 2-49 #969696,#2c2a3e, 50-59 d,#2c2a3e, 60-61 d,#383c54, 62-96 #969696,#2c2a3e, 97-119 d,#2c2a3e,
+|2: 0-1 d,#525252, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|3: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|4: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|5: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|6: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|7: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|8: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|9: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|10: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|11: 0-1 d,#6e4fd0, 2-36 #969696,#2c2a3e, 37-59 d,#2c2a3e, 60-61 d,#525252, 62-119 d,d,
+|12: 0-1 d,#2a2a2a, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|13: 0-1 d,#2a2a2a, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|14: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|15: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|16: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|17: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|18: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|19: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|20: 0-1 d,#2a2a2a, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|21: 0-1 d,#383c54, 2-36 #969696,#2c2a3e, 37-59 d,#2c2a3e, 60-61 d,#525252, 62-119 d,d,
+|22: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|23: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|24: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|25: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|26: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|27: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|28: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|29: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+== snap line20 grid=120x30 cursor=2,12
+|Kill Newcol Tutor Debug Colors NextColor Dump
+| nm /tmp/pardes-snap/ttylook/cwd/big.txt Save Del nm /tmp/pardes-snap/ttylook/cwd Del
+| 20 line 20
+| 21 line 21 big.txt plain.txt sub
+| 22 line 22
+| 23 line 23
+| 24 line 24
+| 25 line 25
+| 26 line 26
+| 27 line 27
+| 28 line 28
+| nm /tmp/pardes-snap/ttylook/cwd Del
+| big.txt:20
+| ww
+|
+| plain.txt
+| big.txt:33
+| zz
+|
+| DONE
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+|
+| big.txt plain.txt sub
+|
+|
+|
+|
+|
+|
+== snap plain grid=120x30 cursor=2,15
+|Kill Newcol Tutor Debug Colors NextColor Dump
+| nm /tmp/pardes-snap/ttylook/cwd/big.txt Save Del nm /tmp/pardes-snap/ttylook/cwd Del
+| 20 line 20
+| 21 line 21 big.txt plain.txt sub
+| 22 line 22
+| 23 line 23
+| nm /tmp/pardes-snap/ttylook/cwd/plain.txt Save Del
+| 1 just text
+|
+|
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+| big.txt:20
+| ww
+|
+| plain.txt
+| big.txt:33
+| zz
+|
+| DONE
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+|
+| big.txt plain.txt sub
+|
+|
+|
+|
+|
+|
+== snap line33 grid=120x30 cursor=2,16
+|Kill Newcol Tutor Debug Colors NextColor Dump
+| nm /tmp/pardes-snap/ttylook/cwd/big.txt Save Del nm /tmp/pardes-snap/ttylook/cwd Del
+| 33 line 33
+| 34 line 34 big.txt plain.txt sub
+| 35 line 35
+| 36 line 36
+| nm /tmp/pardes-snap/ttylook/cwd/plain.txt Save Del
+| 1 just text
+|
+|
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+| big.txt:20
+| ww
+|
+| plain.txt
+| big.txt:33
+| zz
+|
+| DONE
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+|
+| big.txt plain.txt sub
+|
+|
+|
+|
+|
+|
+== snap back grid=120x30 cursor=2,15
+|Kill Newcol Tutor Debug Colors NextColor Dump
+| nm /tmp/pardes-snap/ttylook/cwd/big.txt Save Del nm /tmp/pardes-snap/ttylook/cwd Del
+| 33 line 33
+| 34 line 34 big.txt plain.txt sub
+| 35 line 35
+| 36 line 36
+| nm /tmp/pardes-snap/ttylook/cwd/plain.txt Save Del
+| 1 just text
+|
+|
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+| big.txt:20
+| ww
+|
+| plain.txt
+| big.txt:33
+| zz
+|
+| DONE
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+|
+| big.txt plain.txt sub
+|
+|
+|
+|
+|
+|
+== style back
+|0: 0-44 #969696,#2c2a3e, 45-119 d,#2c2a3e,
+|1: 0-1 d,#383c54, 2-49 #969696,#2c2a3e, 50-59 d,#2c2a3e, 60-61 d,#383c54, 62-96 #969696,#2c2a3e, 97-119 d,#2c2a3e,
+|2: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|3: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|4: 0-1 d,#2a2a2a, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|5: 0-1 d,#525252, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|6: 0-1 d,#383c54, 2-51 #969696,#2c2a3e, 52-59 d,#2c2a3e, 60-61 d,#525252, 62-119 d,d,
+|7: 0-1 d,#525252, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|8: 0-1 d,#525252, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|9: 0-1 d,#525252, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|10: 0-1 d,#525252, 2-6 #5a5a5a,d, 7-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|11: 0-1 d,#6e4fd0, 2-36 #969696,#2c2a3e, 37-59 d,#2c2a3e, 60-61 d,#525252, 62-119 d,d,
+|12: 0-1 d,#2a2a2a, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|13: 0-1 d,#2a2a2a, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|14: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|15: 0-1 d,#525252, 2-59 #d8c8a8,#4a3a1e, 60-61 d,#525252, 62-119 d,d,
+|16: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|17: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|18: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|19: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|20: 0-1 d,#2a2a2a, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|21: 0-1 d,#383c54, 2-36 #969696,#2c2a3e, 37-59 d,#2c2a3e, 60-61 d,#525252, 62-119 d,d,
+|22: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|23: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|24: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|25: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|26: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|27: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|28: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+|29: 0-1 d,#525252, 2-59 d,d, 60-61 d,#525252, 62-119 d,d,
+== snap insert grid=120x30 cursor=2,15
+|Kill Newcol Tutor Debug Colors NextColor Dump
+| nm /tmp/pardes-snap/ttylook/cwd/big.txt Save Del nm /tmp/pardes-snap/ttylook/cwd Del
+| 33 line 33
+| 34 line 34 big.txt plain.txt sub
+| 35 line 35
+| 36 line 36
+| nm /tmp/pardes-snap/ttylook/cwd/plain.txt Save Del
+| 1 just text
+|
+|
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+| big.txt:20
+| ww
+|
+| nnplain.txt
+| big.txt:33
+| zz
+|
+| DONE
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+|
+| big.txt plain.txt sub
+|
+|
+|
+|
+|
+|
+== snap noop grid=120x30 cursor=2,17
+|Kill Newcol Tutor Debug Colors NextColor Dump
+| nm /tmp/pardes-snap/ttylook/cwd/big.txt Save Del nm /tmp/pardes-snap/ttylook/cwd Del
+| 33 line 33
+| 34 line 34 big.txt plain.txt sub
+| 35 line 35
+| nm /tmp/pardes-snap/ttylook/cwd/plain.txt Save Del
+| 1 just text
+|
+|
+| nm /tmp/pardes-snap/ttylook/cwd Del
+| plain.txt
+| big.txt:33
+| zz
+|
+| DONE
+|
+| nm /tmp/pardes-snap/ttylook/cwd/sub Del
+|
+| big.txt plain.txt sub
+|
+|
+| qq
+| rr
+| nm /tmp/pardes-snap/ttylook/cwd Del
+|
+| big.txt plain.txt sub
+|
+|
+|
+|
diff --git a/test/snapshots/ttylook.snap b/test/snapshots/ttylook.snap
new file mode 100644
index 00000000..648dcd42
--- /dev/null
+++ b/test/snapshots/ttylook.snap
@@ -0,0 +1,77 @@
+# tty n/N look-motion (normal mode only): n selects the next output row of
+# the terminal whose leading file-ish word looks somewhere (file, path:NNN —
+# resolved by the look machinery, prompt/echo rows blanked via the OSC 133
+# marks) and looks it; plain rows are skipped; N steps back up. Insert-mode
+# n still types (run splice); with nothing lookable n is a no-op.
+lines big.txt 40
+file plain.txt just text
+dirmk sub
+start 30 120
+wait 8000 big.txt
+stable 700 20000
+# real shell output mixing lookable and plain rows (two short printfs so the
+# echoes never wrap; echo rows are prompt-marked and invisible to the walk)
+key c-b
+stable 600 8000
+text printf 'zz\nbig.txt:20\nww\n'
+key enter
+text printf 'plain.txt\nbig.txt:33\nzz\n'
+key enter
+text echo DO''NE
+key enter
+wait 8000 DONE
+stable 700 15000
+key c-b
+stable 600 8000
+# from the top: n skips nothing-rows, lands on the ls row (big.txt ...) first
+key g g
+stable 400 5000
+key n
+stable 700 15000
+snap lsrow
+snapstyle lsrow
+# next hits: big.txt:20 (file pane scrolls there), plain.txt, big.txt:33
+key n
+stable 700 15000
+snap line20
+key n
+stable 700 15000
+snap plain
+key n
+stable 700 15000
+snap line33
+# N walks back up to the plain.txt row
+key N
+stable 700 15000
+snap back
+snapstyle back
+# insert mode: n types (a run splice), it does not step
+key i
+text nn
+key esc
+settle 700
+stable 400 5000
+snap insert
+key u
+stable 400 5000
+# a shell with nothing lookable: cd into the empty subdir (the old ls row no
+# longer resolves from there), print plain rows — n has nowhere to go
+key a-n
+stable 700 15000
+key c-b
+stable 600 8000
+text cd sub
+key enter
+text printf 'qq\nrr\n'
+key enter
+text echo O''VER
+key enter
+wait 8000 OVER
+stable 700 15000
+key c-b
+stable 600 8000
+key g g
+stable 400 5000
+key n
+stable 400 5000
+snap noop