summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--next-steps.txt2
-rw-r--r--src/pardes.zig42
-rw-r--r--test/snapshots/doccol.golden155
-rw-r--r--test/snapshots/doccol.snap43
-rw-r--r--test/snapshots/lookpanes.golden36
5 files changed, 254 insertions, 24 deletions
diff --git a/next-steps.txt b/next-steps.txt
index 2718848e..3b00d67d 100644
--- a/next-steps.txt
+++ b/next-steps.txt
@@ -1,6 +1,6 @@
+ All syntatic choices must be centralized in single .zig file: keybindings, syntax for Look, etc; the motivation for this is that those can easilly be changed and tweaked if they're centralized like this and in the process we may cut down some repetition of logic.
+ Carve out and isolate the Output pane as its own semantic entity, right now we are doing specific stuff on the output pane based on the command that opened it, let's make this part of the data structure that represents it, the heuristics for special handling of the output panes will be done by reading the Command that originated it field from itself. Make this centralized on the code so its clear to see and tweak those heuristics.
-- File panes need to split the latest column which a file pane was being used.
++ File panes need to split the latest column which a file pane was being used.
- Add multiple cursor support, and Ctrl-c auto comments. Use the same methodology of running helix in a harness as the oracle for differential testing. Also add regex interactive selection like on helix and the more specific selection semantics, use https://github.com/mnemnion/mvzr for regexes, add it using zig fetch.
+ Add a new builtin that will list all builtins and their respective shortcuts if they have any (note that shortcuts may be spc+... or just keyboard or mouse chords/movements)
- Scrolling on a touchpad moves horizontally accidentally way too much, add some heuristics to prioritize vertical scrolling and make horizontal scrolling work only when the user is a bit more explicit about it - for example by measuring if there was recent high-enough vertical movement, etc.
diff --git a/src/pardes.zig b/src/pardes.zig
index 47892108..cd01187b 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -5227,17 +5227,49 @@ pub const Pardes = struct {
/// lands right below `from_id`, be that a shell, a file or another list,
/// and `from_id` alone pays the rows (several lists just stack there).
/// A real doc joins the docs: any doc already open is the split parent (the
- /// source if it IS one, else the first found) and the newcomer lands right
- /// below it, so all docs share one column. The FIRST doc of the session
- /// instead gets a column of its own on the left (acme: files left, shells
- /// right) — nothing is displaced, the other columns just narrow. A full
- /// column bar, or a result list whose source died, stacks into the leftmost.
+ /// source if it IS one, else the one most recently worked in) and the
+ /// newcomer lands right below it, so docs share a column. The FIRST doc of
+ /// the session instead gets a column of its own on the left (acme: files
+ /// left, shells right) — nothing is displaced, the other columns just
+ /// narrow. A full column bar, or a result list whose source died, stacks
+ /// into the leftmost.
pub fn placeDoc(p: *Pardes, from_id: usize, free: usize, nt: *Pane) void {
const doc = if (nt.file) |f| output_pane.fileTraits(f.output).doc else true; // an image is a doc
var src_id: ?usize = null;
if (p.panes[from_id]) |src| if (if (src.file) |f| output_pane.fileTraits(f.output).doc else src.image != null) {
src_id = from_id;
};
+ // Opened from somewhere that is NOT a doc (a shell, a results list):
+ // the file joins the column it was last being READ in, which is the
+ // newest doc on the jump stack. The stack already IS that record — it
+ // is where the keyboard has been — so nothing new is remembered here;
+ // asking it is the whole change. What this replaces was the first doc
+ // in slot order, i.e. pane-id ALLOCATION order, so which column your
+ // file landed in depended on how the session had handed out ids rather
+ // than on where you were working.
+ //
+ // The answer wanted is the COLUMN, and it stays right once the pane
+ // itself is closed: trackJump compacts dead entries out, so the walk
+ // falls through to the next doc remembered in that same column. The
+ // serial test is the one trackJump uses — slots are reused, so an entry
+ // whose pane has been replaced names a pane that is gone, not the
+ // newcomer sitting in its slot (`free`, this very pane, among them).
+ if (doc and src_id == null) {
+ var n = p.njumps;
+ while (n > 0) : (n -= 1) {
+ const j = p.jumps[n - 1];
+ const pp = p.panes[j.pane] orelse continue;
+ if (pp.serial != j.serial) continue;
+ if (if (pp.file) |f| output_pane.fileTraits(f.output).doc else pp.image != null) {
+ src_id = j.pane;
+ break;
+ }
+ }
+ }
+ // A doc no jump remembers is still a doc: a restored session focuses
+ // one pane, not each, and the stack is finite. The rule that a second
+ // doc never claims a second column outranks knowing where you were, so
+ // the old slot-order scan stays as the fallback.
if (doc and src_id == null) for (p.panes, 0..) |sl, i| {
if (sl) |pp| if (i != free and (if (pp.file) |f| output_pane.fileTraits(f.output).doc else pp.image != null)) {
src_id = i;
diff --git a/test/snapshots/doccol.golden b/test/snapshots/doccol.golden
new file mode 100644
index 00000000..a1508b9f
--- /dev/null
+++ b/test/snapshots/doccol.golden
@@ -0,0 +1,155 @@
+== snap boot grid=100x30 cursor=7,2
+|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
+| NOR /tmp/pardes-snap/doccol/cwd/a.txt Save Del NOR /tmp/pardes-snap/doccol/cwd Del
+| 1 AAA
+| a.txt b.txt c.txt
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+== snap two-docs grid=100x30 cursor=7,17
+|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
+| NOR /tmp/pardes-snap/doccol/cwd/a.txt Save Del NOR /tmp/pardes-snap/doccol/cwd Del
+| 1 AAA
+| a.txt b.txt c.txt
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+| NOR /tmp/pardes-snap/doccol/cwd/b.txt Save Del
+| 1 BBB
+| 2 B-TWO
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+== snap moved grid=100x30 cursor=57,20
+|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
+| NOR /tmp/pardes-snap/doccol/cwd/a.txt Save Del NOR /tmp/pardes-snap/doccol/cwd Del
+| 1 AAA
+| a.txt b.txt c.txt
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+| NOR /tmp/pardes-snap/doccol/cwd/b.txt Save Del
+| 1 BBB
+| 2 B-TWO
+|
+|
+|
+|
+|
+|
+|
+|
+== snap worked grid=100x30 cursor=59,21
+|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
+| NOR /tmp/pardes-snap/doccol/cwd/a.txt Save Del NOR /tmp/pardes-snap/doccol/cwd Del
+| 1 AAA
+| a.txt b.txt c.txt
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+| NOR /tmp/pardes-snap/doccol/cwd/b.txt Save Del
+| 1 BBB
+| 2 B-TWO
+|
+|
+|
+|
+|
+|
+|
+|
+== snap third grid=100x30 cursor=57,26
+|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
+| NOR /tmp/pardes-snap/doccol/cwd/a.txt Save Del NOR /tmp/pardes-snap/doccol/cwd Del
+| 1 AAA
+| a.txt b.txt c.txt
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+| NOR /tmp/pardes-snap/doccol/cwd/b.txt Save Del
+| 1 BBB
+| 2 B-TWO
+|
+|
+|
+| NOR /tmp/pardes-snap/doccol/cwd/c.txt Save Del
+| 1 CCC
+|
+|
+|
diff --git a/test/snapshots/doccol.snap b/test/snapshots/doccol.snap
new file mode 100644
index 00000000..80133c38
--- /dev/null
+++ b/test/snapshots/doccol.snap
@@ -0,0 +1,43 @@
+# A file opened from a terminal joins the column a FILE PANE was last used in.
+# a.txt boots on the left and b.txt joins it there; b.txt is then dragged into
+# the RIGHT column and worked in, so that column is the newest one a doc was
+# read in while a.txt keeps the lowest pane id. The c.txt look then comes from
+# the right shell and must land under b.txt. Slot order — the rule this
+# replaces — would have answered a.txt (pane 0) and put c.txt back on the left.
+file a.txt AAA
+file b.txt BBB\nB-TWO
+file c.txt CCC
+start 30 100 -n 2 a.txt
+wait 8000 c.txt
+stable 700 20000
+snap boot
+# look b.txt in the shell's ls output: the second doc splits the first, so
+# both docs are in the left column and a.txt is the lower-numbered pane
+press right 60 4
+release right 60 4
+wait 10000 BBB
+stable 700 20000
+snap two-docs
+# drag b.txt's layout box (the gutter cells of its tag row) into the right
+# column, below the shell
+press left 1 17
+drag left 75 20
+release left 75 20
+stable 700 15000
+snap moved
+# use a.txt, then b.txt: what counts is the doc last USED, so a.txt being the
+# most recent for a moment must not survive the click into b.txt
+press left 5 3
+release left 5 3
+stable 400 5000
+press left 60 21
+release left 60 21
+key j
+stable 400 5000
+snap worked
+# look c.txt from the shell: below b.txt, in the right column
+press right 67 4
+release right 67 4
+wait 10000 CCC
+stable 700 20000
+snap third
diff --git a/test/snapshots/lookpanes.golden b/test/snapshots/lookpanes.golden
index 93a940c5..03264841 100644
--- a/test/snapshots/lookpanes.golden
+++ b/test/snapshots/lookpanes.golden
@@ -151,7 +151,7 @@
|
|
|
-== snap mru-alpha grid=130x50 cursor=7,9
+== snap mru-alpha grid=130x50 cursor=7,21
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| NOR /tmp/pardes-snap/lookpanes/cwd/beta/bmark.txt Save Del NOR /tmp/pardes-snap/lookpanes/cwd Del
| 1 both.txt
@@ -160,20 +160,20 @@
| NOR /tmp/pardes-snap/lookpanes/cwd/alpha Del
|
| amark.txt both.txt pick.txt twin.txt zqonly.txt
-| NOR /tmp/pardes-snap/lookpanes/cwd/alpha/pick.txt Save Del
-| 1 PICK-FROM-ALPHA
|
|
|
|
-| NOR /tmp/pardes-snap/lookpanes/cwd/beta/both.txt Save Del
-| 1 BOTH-FROM-BETA
|
|
+| NOR /tmp/pardes-snap/lookpanes/cwd/beta/both.txt Save Del
+| 1 BOTH-FROM-BETA
|
|
|
|
+| NOR /tmp/pardes-snap/lookpanes/cwd/alpha/pick.txt Save Del
+| 1 PICK-FROM-ALPHA
|
|
|
@@ -202,17 +202,17 @@
|
|
|
-== snap mru-beta grid=130x50 cursor=7,5
+== snap mru-beta grid=130x50 cursor=7,9
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| NOR /tmp/pardes-snap/lookpanes/cwd/beta/bmark.txt Save Del NOR /tmp/pardes-snap/lookpanes/cwd Del
| 1 both.txt
| 2 b-marker alpha beta zzboot.txt zqonly.txt pick.txt twin.txt
-| NOR /tmp/pardes-snap/lookpanes/cwd/beta/twin.txt Save Del
-| 1 TWIN-FROM-BETA NOR /tmp/pardes-snap/lookpanes/cwd/alpha Del
+|
+| NOR /tmp/pardes-snap/lookpanes/cwd/alpha Del
|
| amark.txt both.txt pick.txt twin.txt zqonly.txt
-| NOR /tmp/pardes-snap/lookpanes/cwd/alpha/pick.txt Save Del
-| 1 PICK-FROM-ALPHA
+| NOR /tmp/pardes-snap/lookpanes/cwd/beta/twin.txt Save Del
+| 1 TWIN-FROM-BETA
|
|
|
@@ -223,8 +223,8 @@
|
|
|
-|
-|
+| NOR /tmp/pardes-snap/lookpanes/cwd/alpha/pick.txt Save Del
+| 1 PICK-FROM-ALPHA
|
|
|
@@ -258,12 +258,12 @@
|1: 0-1 d,#262626, 2-59 #949494,#121212, 60-64 d,#121212, 65-66 d,#262626, 67-104 #949494,#121212, 105-129 d,#121212,
|2: 0-1 d,#444444, 2-6 #626262,#080808, 7-14 #bdbdbd,#080808, 15-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|3: 0-1 d,#444444, 2-6 #626262,#080808, 7-14 #bdbdbd,#080808, 15-64 d,#080808, 65-66 d,#444444, 67-121 #bdbdbd,#080808, 122-129 d,#080808,
-|4: 0-1 d,#626262, 2-58 #949494,#121212, 59-64 d,#121212, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
-|5: 0-1 d,#444444, 2-6 #949494,#121212, 7-20 #bdbdbd,#080808, 21-64 d,#080808, 65-66 d,#262626, 67-110 #949494,#121212, 111-129 d,#121212,
+|4: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
+|5: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#262626, 67-110 #949494,#121212, 111-129 d,#121212,
|6: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|7: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
-|8: 0-1 d,#262626, 2-59 #949494,#121212, 60-64 d,#121212, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
-|9: 0-1 d,#444444, 2-6 #626262,#080808, 7-21 #bdbdbd,#080808, 22-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
+|8: 0-1 d,#626262, 2-58 #949494,#121212, 59-64 d,#121212, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
+|9: 0-1 d,#444444, 2-6 #949494,#121212, 7-20 #bdbdbd,#080808, 21-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|10: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|11: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|12: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
@@ -274,8 +274,8 @@
|17: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|18: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|19: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
-|20: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
-|21: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
+|20: 0-1 d,#262626, 2-59 #949494,#121212, 60-64 d,#121212, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
+|21: 0-1 d,#444444, 2-6 #626262,#080808, 7-21 #bdbdbd,#080808, 22-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|22: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|23: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,
|24: 0-1 d,#444444, 2-6 #626262,#080808, 7-64 d,#080808, 65-66 d,#444444, 67-129 #bdbdbd,#080808,