From c8f0c25a854b8e169db08a84d1fdcd915a70aaa0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 22:49:49 -0300 Subject: Point docs and comments at the files code moved to Documentation only, no code change: README's reading order and layout, docs/design.typ's paragraph on where pane kinds and editor parts live, docs/helix-keys.md's code map (normalInput and the executors now in normal.zig and edit.zig, insertTab in edit.zig), docs/open-questions.md (execute and ttyForDir in exec.zig), and the comments that named pardes.zig for fold, Cell, takesCommandLine and runBuiltin (tools/gen_themes.zig, themes/helix.zig, detached/wire.zig, host_io.zig, lsp_zls.zig). docs/design.pdf is a retained fixture and is not regenerated. Co-Authored-By: Claude Opus 5.5 --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6225bbdb..8899d68a 100644 --- a/README.md +++ b/README.md @@ -216,8 +216,10 @@ steps use `-Dhelix-harness=`, `HX_HARNESS`, or `hx-harness` on PATH. ## Documentation -Start with `src/panes.zig`, `src/layout.zig`, and `src/fs.zig` for ownership and -operations, and `src/pardes.zig` for input. `docs/design.typ` is the architecture +Start with `src/panes.zig` (and the pane kinds it names, `src/File.zig`, +`src/Terminal.zig`, ...), `src/layout.zig`, and `src/fs.zig` for ownership and +operations, and `src/pardes.zig` for input, with one file per thing beside it +(`edit.zig`, `normal.zig`, `look.zig`, `exec.zig`, `mouse.zig`, ...). `docs/design.typ` is the architecture sketch; `docs/design.pdf` is a retained rendering/search fixture and may lag it. | file | subject | @@ -242,7 +244,7 @@ says which waiver proves it is still open. ## Layout ``` -src/ core events (pardes.zig), panes, layout, fs, syntax +src/ core events (pardes.zig), panes, edit, look, exec, layout, fs, syntax src/detached/ the wire, the detached core, the frontend client src/lsp/ ZLS and external language-server backends test/ harnesses, snapshot goldens, helix cases -- cgit v1.3 From 05ca060fc91930f0e931f39dcf56729ec71543dd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 15:26:39 -0300 Subject: Every helix-golf example is a differential case, one per step of its walkthrough The ten examples on helix-golf are imported as 118 cases: each numbered step of an example's walkthrough is the case whose keys are the command up to and including that step, so the first mismatch names the step where pardes and helix part. Six more restart at a step that begins with %, from helix's own text there, so a later step is tested even when an earlier one misses. zig build hxgolf compares all 124 with goldens from hx-harness. Co-Authored-By: Claude Opus 5.5 --- README.md | 1 + build.zig | 7 +++ docs/helix-keys.md | 13 +++++ test/hxcases/golf-goldens.jsonl | 124 ++++++++++++++++++++++++++++++++++++++++ test/hxcases/golf.jsonl | 124 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 269 insertions(+) create mode 100644 test/hxcases/golf-goldens.jsonl create mode 100644 test/hxcases/golf.jsonl (limited to 'README.md') diff --git a/README.md b/README.md index 8899d68a..c82bd310 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ zig build hxdiff-test comparator, allocation and CLI regression checks zig build hxdiff-live compare against a freshly run hx-harness zig build hxdiff-update update reference results only after comparison passes zig build hxparity file-pane vs pty-pane editing parity +zig build hxgolf every helix-golf example, step by step, against helix zig build mupdf-check compile, link, render and search docs/design.pdf zig build web-snap browser highlighting and touch interactions zig build web-driver-test browser driver timeouts and cleanup diff --git a/build.zig b/build.zig index 666e792d..334d3705 100644 --- a/build.zig +++ b/build.zig @@ -1097,6 +1097,13 @@ pub fn build(b: *std.Build) void { const hxparity_step = b.step("hxparity", "run the file-vs-pty editing parity suite (-- [--waivers w.jsonl] ...)"); hxparity_step.dependOn(&run_hxparity.step); + // every helix-golf example, one case per step of its walkthrough + const run_hxgolf = b.addRunArtifact(hxdiff); + run_hxgolf.has_side_effects = true; + run_hxgolf.addArgs(&.{ "--strict", "test/hxcases/golf.jsonl", "test/hxcases/golf-goldens.jsonl" }); + run_hxgolf.setCwd(b.path(".")); + b.step("hxgolf", "compare the helix-golf examples against their Helix results").dependOn(&run_hxgolf.step); + const lspbench = b.addExecutable(.{ .name = "pardes-lspbench", .root_module = b.createModule(.{ diff --git a/docs/helix-keys.md b/docs/helix-keys.md index 41f9b364..84ee5124 100644 --- a/docs/helix-keys.md +++ b/docs/helix-keys.md @@ -404,6 +404,19 @@ Files (all in `test/hxcases/`): scrolloff band — no text differs), and four case texts a pty cannot hold verbatim (a literal TAB the emulator expands, a file with no trailing newline, an all-whitespace last row the dump trims). +- `golf.jsonl` + `golf-goldens.jsonl` — every example on helix-golf + (github.com/nik-rev/helix-golf, imported at d78c18c): one case per numbered + step of each walkthrough, its keys being the command up to and including + that step, so the first failing case names the step that diverges. A + step that starts over with `%` also gets `-fromNN` cases replaying the rest + of the command from helix's own text there, so a later step is still + tested when an earlier one misses. The goldens are + `hx-harness test/hxcases/golf.jsonl`; `zig build hxgolf` runs them. All ten examples reproduce their published result in hx 25.07.1 under + the site's own conditions (a file of the example's language, auto-pairs + on). Under the harness pins two do not: `csv_to_sql` needs auto-pairs to + close its `VALUES (`, and `invert_dictionary_2` needs 25.07's + `Alt-(` (rotate within groups of count) where the harness's newer + helix rotates by count. - `smoke.jsonl` — 20 cases referenced by nothing in the tree: no build step, no script. Either wire it up or delete it. diff --git a/test/hxcases/golf-goldens.jsonl b/test/hxcases/golf-goldens.jsonl new file mode 100644 index 00000000..d2d77302 --- /dev/null +++ b/test/hxcases/golf-goldens.jsonl @@ -0,0 +1,124 @@ +{"name":"golf-csv-to-sql-01","text":"id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n","mode":"normal","cursor":{"row":2,"col":33},"anchor":{"row":0,"col":0}} +{"name":"golf-csv-to-sql-02","text":"id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n","mode":"normal","cursor":{"row":0,"col":28},"anchor":{"row":0,"col":0},"sels":[{"cursor":{"row":0,"col":28},"anchor":{"row":0,"col":0}},{"cursor":{"row":1,"col":28},"anchor":{"row":1,"col":0}},{"cursor":{"row":2,"col":32},"anchor":{"row":2,"col":0}}],"primary":0} +{"name":"golf-csv-to-sql-03","text":"id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n","mode":"normal","cursor":{"row":0,"col":28},"anchor":{"row":0,"col":0},"sels":[{"cursor":{"row":0,"col":28},"anchor":{"row":0,"col":0}},{"cursor":{"row":1,"col":28},"anchor":{"row":1,"col":0}},{"cursor":{"row":2,"col":32},"anchor":{"row":2,"col":0}}],"primary":0} +{"name":"golf-csv-to-sql-04","text":"id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n","mode":"normal","cursor":{"row":0,"col":3},"anchor":{"row":0,"col":3},"sels":[{"cursor":{"row":0,"col":3},"anchor":{"row":0,"col":3}},{"cursor":{"row":0,"col":10},"anchor":{"row":0,"col":10}},{"cursor":{"row":0,"col":17},"anchor":{"row":0,"col":17}},{"cursor":{"row":0,"col":28},"anchor":{"row":0,"col":28}},{"cursor":{"row":1,"col":3},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":10},"anchor":{"row":1,"col":10}},{"cursor":{"row":1,"col":17},"anchor":{"row":1,"col":17}},{"cursor":{"row":1,"col":28},"anchor":{"row":1,"col":28}},{"cursor":{"row":2,"col":3},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":4},"anchor":{"row":2,"col":4}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":11}},{"cursor":{"row":2,"col":12},"anchor":{"row":2,"col":12}},{"cursor":{"row":2,"col":19},"anchor":{"row":2,"col":19}},{"cursor":{"row":2,"col":20},"anchor":{"row":2,"col":20}},{"cursor":{"row":2,"col":31},"anchor":{"row":2,"col":31}},{"cursor":{"row":2,"col":32},"anchor":{"row":2,"col":32}}],"primary":0} +{"name":"golf-csv-to-sql-05","text":"id ,Item ,cost ,location \nid ,Item ,cost ,location \nid ,Item ,cost ,location \n","mode":"normal","cursor":{"row":0,"col":3},"anchor":{"row":0,"col":3},"sels":[{"cursor":{"row":0,"col":3},"anchor":{"row":0,"col":3}},{"cursor":{"row":0,"col":9},"anchor":{"row":0,"col":9}},{"cursor":{"row":0,"col":15},"anchor":{"row":0,"col":15}},{"cursor":{"row":0,"col":25},"anchor":{"row":0,"col":25}},{"cursor":{"row":1,"col":3},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9}},{"cursor":{"row":1,"col":15},"anchor":{"row":1,"col":15}},{"cursor":{"row":1,"col":25},"anchor":{"row":1,"col":25}},{"cursor":{"row":2,"col":3},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":9},"anchor":{"row":2,"col":9}},{"cursor":{"row":2,"col":15},"anchor":{"row":2,"col":15}},{"cursor":{"row":2,"col":25},"anchor":{"row":2,"col":25}}],"primary":0} +{"name":"golf-csv-to-sql-06","text":"id ,Item ,cost ,location \nid ,Item ,cost ,location \nid ,Item ,cost ,location \n","mode":"normal","cursor":{"row":0,"col":1},"anchor":{"row":0,"col":1},"sels":[{"cursor":{"row":0,"col":1},"anchor":{"row":0,"col":1}},{"cursor":{"row":0,"col":7},"anchor":{"row":0,"col":7}},{"cursor":{"row":0,"col":13},"anchor":{"row":0,"col":13}},{"cursor":{"row":0,"col":23},"anchor":{"row":0,"col":23}},{"cursor":{"row":1,"col":1},"anchor":{"row":1,"col":1}},{"cursor":{"row":1,"col":7},"anchor":{"row":1,"col":7}},{"cursor":{"row":1,"col":13},"anchor":{"row":1,"col":13}},{"cursor":{"row":1,"col":23},"anchor":{"row":1,"col":23}},{"cursor":{"row":2,"col":1},"anchor":{"row":2,"col":1}},{"cursor":{"row":2,"col":7},"anchor":{"row":2,"col":7}},{"cursor":{"row":2,"col":13},"anchor":{"row":2,"col":13}},{"cursor":{"row":2,"col":23},"anchor":{"row":2,"col":23}}],"primary":0} +{"name":"golf-csv-to-sql-07","text":"id ,Item ,cost ,location \nid ,Item ,cost ,location \nid ,Item ,cost ,location \n","mode":"normal","cursor":{"row":0,"col":0},"anchor":{"row":0,"col":1},"sels":[{"cursor":{"row":0,"col":0},"anchor":{"row":0,"col":1}},{"cursor":{"row":0,"col":4},"anchor":{"row":0,"col":7}},{"cursor":{"row":0,"col":10},"anchor":{"row":0,"col":13}},{"cursor":{"row":0,"col":16},"anchor":{"row":0,"col":23}},{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":1}},{"cursor":{"row":1,"col":4},"anchor":{"row":1,"col":7}},{"cursor":{"row":1,"col":10},"anchor":{"row":1,"col":13}},{"cursor":{"row":1,"col":16},"anchor":{"row":1,"col":23}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":1}},{"cursor":{"row":2,"col":4},"anchor":{"row":2,"col":7}},{"cursor":{"row":2,"col":10},"anchor":{"row":2,"col":13}},{"cursor":{"row":2,"col":16},"anchor":{"row":2,"col":23}}],"primary":0} +{"name":"golf-csv-to-sql-08","text":"`id` ,`Item` ,`cost` ,`location` \n`id` ,`Item` ,`cost` ,`location` \n`id` ,`Item` ,`cost` ,`location` \n","mode":"normal","cursor":{"row":0,"col":0},"anchor":{"row":0,"col":3},"sels":[{"cursor":{"row":0,"col":0},"anchor":{"row":0,"col":3}},{"cursor":{"row":0,"col":6},"anchor":{"row":0,"col":11}},{"cursor":{"row":0,"col":14},"anchor":{"row":0,"col":19}},{"cursor":{"row":0,"col":22},"anchor":{"row":0,"col":31}},{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":6},"anchor":{"row":1,"col":11}},{"cursor":{"row":1,"col":14},"anchor":{"row":1,"col":19}},{"cursor":{"row":1,"col":22},"anchor":{"row":1,"col":31}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":6},"anchor":{"row":2,"col":11}},{"cursor":{"row":2,"col":14},"anchor":{"row":2,"col":19}},{"cursor":{"row":2,"col":22},"anchor":{"row":2,"col":31}}],"primary":0} +{"name":"golf-csv-to-sql-09","text":"`id` ,`item` ,`cost` ,`location` \n`id` ,`item` ,`cost` ,`location` \n`id` ,`item` ,`cost` ,`location` \n","mode":"normal","cursor":{"row":0,"col":0},"anchor":{"row":0,"col":3},"sels":[{"cursor":{"row":0,"col":0},"anchor":{"row":0,"col":3}},{"cursor":{"row":0,"col":6},"anchor":{"row":0,"col":11}},{"cursor":{"row":0,"col":14},"anchor":{"row":0,"col":19}},{"cursor":{"row":0,"col":22},"anchor":{"row":0,"col":31}},{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":6},"anchor":{"row":1,"col":11}},{"cursor":{"row":1,"col":14},"anchor":{"row":1,"col":19}},{"cursor":{"row":1,"col":22},"anchor":{"row":1,"col":31}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":6},"anchor":{"row":2,"col":11}},{"cursor":{"row":2,"col":14},"anchor":{"row":2,"col":19}},{"cursor":{"row":2,"col":22},"anchor":{"row":2,"col":31}}],"primary":0} +{"name":"golf-csv-to-sql-10","text":"`id` ,`item` ,`cost` ,`location` \n`id` ,`item` ,`cost` ,`location` \n`id` ,`item` ,`cost` ,`location` \n","mode":"normal","cursor":{"row":0,"col":31},"anchor":{"row":0,"col":0},"sels":[{"cursor":{"row":0,"col":31},"anchor":{"row":0,"col":0}},{"cursor":{"row":1,"col":31},"anchor":{"row":1,"col":0}},{"cursor":{"row":2,"col":31},"anchor":{"row":2,"col":0}}],"primary":0} +{"name":"golf-csv-to-sql-11","text":"(`id` ,`item` ,`cost` ,`location`) \n(`id` ,`item` ,`cost` ,`location`) \n(`id` ,`item` ,`cost` ,`location`) \n","mode":"normal","cursor":{"row":0,"col":33},"anchor":{"row":0,"col":0},"sels":[{"cursor":{"row":0,"col":33},"anchor":{"row":0,"col":0}},{"cursor":{"row":1,"col":33},"anchor":{"row":1,"col":0}},{"cursor":{"row":2,"col":33},"anchor":{"row":2,"col":0}}],"primary":0} +{"name":"golf-csv-to-sql-12","text":"(`id` ,`item` ,`cost` ,`location`) \n(`id` ,`item` ,`cost` ,`location`) \n(`id` ,`item` ,`cost` ,`location`) \n","mode":"insert","cursor":{"row":0,"col":0},"anchor":{"row":0,"col":0},"sels":[{"cursor":{"row":0,"col":0},"anchor":{"row":0,"col":0}},{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":0}}],"primary":0} +{"name":"golf-csv-to-sql-13","text":"INSERT INTO `database(`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(`id` ,`item` ,`cost` ,`location`) \n","mode":"insert","cursor":{"row":0,"col":21},"anchor":{"row":0,"col":21},"sels":[{"cursor":{"row":0,"col":21},"anchor":{"row":0,"col":21}},{"cursor":{"row":1,"col":21},"anchor":{"row":1,"col":21}},{"cursor":{"row":2,"col":21},"anchor":{"row":2,"col":21}}],"primary":0} +{"name":"golf-csv-to-sql-14","text":"INSERT INTO `database(`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(`id` ,`item` ,`cost` ,`location`) \n","mode":"normal","cursor":{"row":0,"col":21},"anchor":{"row":0,"col":21},"sels":[{"cursor":{"row":0,"col":21},"anchor":{"row":0,"col":21}},{"cursor":{"row":1,"col":21},"anchor":{"row":1,"col":21}},{"cursor":{"row":2,"col":21},"anchor":{"row":2,"col":21}}],"primary":0} +{"name":"golf-csv-to-sql-15","text":"INSERT INTO `database(.`table`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(.`table`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(.`table`id` ,`item` ,`cost` ,`location`) \n","mode":"insert","cursor":{"row":0,"col":29},"anchor":{"row":0,"col":21},"sels":[{"cursor":{"row":0,"col":29},"anchor":{"row":0,"col":21}},{"cursor":{"row":1,"col":29},"anchor":{"row":1,"col":21}},{"cursor":{"row":2,"col":29},"anchor":{"row":2,"col":21}}],"primary":0} +{"name":"golf-csv-to-sql-16","text":"INSERT INTO `database(.`table`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(.`table`id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(.`table`id` ,`item` ,`cost` ,`location`) \n","mode":"insert","cursor":{"row":0,"col":30},"anchor":{"row":0,"col":29},"sels":[{"cursor":{"row":0,"col":30},"anchor":{"row":0,"col":29}},{"cursor":{"row":1,"col":30},"anchor":{"row":1,"col":29}},{"cursor":{"row":2,"col":30},"anchor":{"row":2,"col":29}}],"primary":0} +{"name":"golf-csv-to-sql-17","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) \nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) \n","mode":"normal","cursor":{"row":0,"col":30},"anchor":{"row":0,"col":29},"sels":[{"cursor":{"row":0,"col":30},"anchor":{"row":0,"col":29}},{"cursor":{"row":1,"col":30},"anchor":{"row":1,"col":29}},{"cursor":{"row":2,"col":30},"anchor":{"row":2,"col":29}}],"primary":0} +{"name":"golf-csv-to-sql-18","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (\n","mode":"insert","cursor":{"row":0,"col":72},"anchor":{"row":0,"col":72},"sels":[{"cursor":{"row":0,"col":72},"anchor":{"row":0,"col":72}},{"cursor":{"row":1,"col":72},"anchor":{"row":1,"col":72}},{"cursor":{"row":2,"col":72},"anchor":{"row":2,"col":72}}],"primary":0} +{"name":"golf-csv-to-sql-19","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (\n","mode":"normal","cursor":{"row":0,"col":72},"anchor":{"row":0,"col":72},"sels":[{"cursor":{"row":0,"col":72},"anchor":{"row":0,"col":72}},{"cursor":{"row":1,"col":72},"anchor":{"row":1,"col":72}},{"cursor":{"row":2,"col":72},"anchor":{"row":2,"col":72}}],"primary":0} +{"name":"golf-csv-to-sql-20","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (id 1,Item 1,cost 1,location 1\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (id 2,Item 2,cost 2,location 2\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (id 10,Item 10,cost 10,location 10\n","mode":"normal","cursor":{"row":0,"col":100},"anchor":{"row":0,"col":72},"sels":[{"cursor":{"row":0,"col":100},"anchor":{"row":0,"col":72}},{"cursor":{"row":1,"col":100},"anchor":{"row":1,"col":72}},{"cursor":{"row":2,"col":104},"anchor":{"row":2,"col":72}}],"primary":0} +{"name":"golf-csv-to-sql-21","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (id 1,Item 1,cost 1,location 1\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (id 2,Item 2,cost 2,location 2\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES (id 10,Item 10,cost 10,location 10\n","mode":"normal","cursor":{"row":0,"col":75},"anchor":{"row":0,"col":72},"sels":[{"cursor":{"row":0,"col":75},"anchor":{"row":0,"col":72}},{"cursor":{"row":0,"col":82},"anchor":{"row":0,"col":77}},{"cursor":{"row":0,"col":89},"anchor":{"row":0,"col":84}},{"cursor":{"row":0,"col":100},"anchor":{"row":0,"col":91}},{"cursor":{"row":1,"col":75},"anchor":{"row":1,"col":72}},{"cursor":{"row":1,"col":82},"anchor":{"row":1,"col":77}},{"cursor":{"row":1,"col":89},"anchor":{"row":1,"col":84}},{"cursor":{"row":1,"col":100},"anchor":{"row":1,"col":91}},{"cursor":{"row":2,"col":76},"anchor":{"row":2,"col":72}},{"cursor":{"row":2,"col":84},"anchor":{"row":2,"col":78}},{"cursor":{"row":2,"col":92},"anchor":{"row":2,"col":86}},{"cursor":{"row":2,"col":104},"anchor":{"row":2,"col":94}}],"primary":0} +{"name":"golf-csv-to-sql-22","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 1','Item 1','cost 1','location 1'\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 2','Item 2','cost 2','location 2'\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 10','Item 10','cost 10','location 10'\n","mode":"normal","cursor":{"row":0,"col":77},"anchor":{"row":0,"col":72},"sels":[{"cursor":{"row":0,"col":77},"anchor":{"row":0,"col":72}},{"cursor":{"row":0,"col":86},"anchor":{"row":0,"col":79}},{"cursor":{"row":0,"col":95},"anchor":{"row":0,"col":88}},{"cursor":{"row":0,"col":108},"anchor":{"row":0,"col":97}},{"cursor":{"row":1,"col":77},"anchor":{"row":1,"col":72}},{"cursor":{"row":1,"col":86},"anchor":{"row":1,"col":79}},{"cursor":{"row":1,"col":95},"anchor":{"row":1,"col":88}},{"cursor":{"row":1,"col":108},"anchor":{"row":1,"col":97}},{"cursor":{"row":2,"col":78},"anchor":{"row":2,"col":72}},{"cursor":{"row":2,"col":88},"anchor":{"row":2,"col":80}},{"cursor":{"row":2,"col":98},"anchor":{"row":2,"col":90}},{"cursor":{"row":2,"col":112},"anchor":{"row":2,"col":100}}],"primary":0} +{"name":"golf-csv-to-sql-23","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 1','Item 1','cost 1','location 1';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 2','Item 2','cost 2','location 2';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 10','Item 10','cost 10','location 10';\n","mode":"insert","cursor":{"row":0,"col":110},"anchor":{"row":0,"col":110},"sels":[{"cursor":{"row":0,"col":110},"anchor":{"row":0,"col":110}},{"cursor":{"row":1,"col":110},"anchor":{"row":1,"col":110}},{"cursor":{"row":2,"col":114},"anchor":{"row":2,"col":114}}],"primary":0} +{"name":"golf-csv-to-sql-24","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 1','Item 1','cost 1','location 1';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 2','Item 2','cost 2','location 2';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 10','Item 10','cost 10','location 10';\n","mode":"normal","cursor":{"row":0,"col":98},"anchor":{"row":0,"col":110},"sels":[{"cursor":{"row":0,"col":98},"anchor":{"row":0,"col":110}},{"cursor":{"row":1,"col":98},"anchor":{"row":1,"col":110}},{"cursor":{"row":2,"col":101},"anchor":{"row":2,"col":114}}],"primary":0} +{"name":"golf-csv-to-sql-25","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 1','Item 1','cost 1','location 1';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 2','Item 2','cost 2','location 2';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 10','Item 10','cost 10','location 10';\n","mode":"normal","cursor":{"row":0,"col":98},"anchor":{"row":0,"col":98},"sels":[{"cursor":{"row":0,"col":98},"anchor":{"row":0,"col":98}},{"cursor":{"row":1,"col":98},"anchor":{"row":1,"col":98}},{"cursor":{"row":2,"col":101},"anchor":{"row":2,"col":101}}],"primary":0} +{"name":"golf-csv-to-sql","text":"INSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 1','Item 1','cost 1','Location 1';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 2','Item 2','cost 2','Location 2';\nINSERT INTO `database(.`table` id` ,`item` ,`cost` ,`location`) VALUES ('id 10','Item 10','cost 10','Location 10';\n","mode":"normal","cursor":{"row":0,"col":98},"anchor":{"row":0,"col":98},"sels":[{"cursor":{"row":0,"col":98},"anchor":{"row":0,"col":98}},{"cursor":{"row":1,"col":98},"anchor":{"row":1,"col":98}},{"cursor":{"row":2,"col":101},"anchor":{"row":2,"col":101}}],"primary":0} +{"name":"golf-enumerate-and-align-01","text":"[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":12,"col":2},"anchor":{"row":0,"col":0}} +{"name":"golf-enumerate-and-align-02","text":"[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":12,"col":2},"anchor":{"row":0,"col":0}} +{"name":"golf-enumerate-and-align-03","text":"[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":1,"col":2},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":2},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":2},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":2},"anchor":{"row":3,"col":2}},{"cursor":{"row":4,"col":2},"anchor":{"row":4,"col":2}},{"cursor":{"row":5,"col":2},"anchor":{"row":5,"col":2}},{"cursor":{"row":6,"col":2},"anchor":{"row":6,"col":2}},{"cursor":{"row":7,"col":2},"anchor":{"row":7,"col":2}},{"cursor":{"row":8,"col":2},"anchor":{"row":8,"col":2}},{"cursor":{"row":9,"col":2},"anchor":{"row":9,"col":2}},{"cursor":{"row":10,"col":2},"anchor":{"row":10,"col":2}},{"cursor":{"row":11,"col":2},"anchor":{"row":11,"col":2}}],"primary":0} +{"name":"golf-enumerate-and-align-04","text":"[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n","mode":"insert","cursor":{"row":1,"col":4},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":4},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":4},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":4},"anchor":{"row":3,"col":2}},{"cursor":{"row":4,"col":4},"anchor":{"row":4,"col":2}},{"cursor":{"row":5,"col":4},"anchor":{"row":5,"col":2}},{"cursor":{"row":6,"col":4},"anchor":{"row":6,"col":2}},{"cursor":{"row":7,"col":4},"anchor":{"row":7,"col":2}},{"cursor":{"row":8,"col":4},"anchor":{"row":8,"col":2}},{"cursor":{"row":9,"col":4},"anchor":{"row":9,"col":2}},{"cursor":{"row":10,"col":4},"anchor":{"row":10,"col":2}},{"cursor":{"row":11,"col":4},"anchor":{"row":11,"col":2}}],"primary":0} +{"name":"golf-enumerate-and-align-05","text":"[\n { rank: word: \"a\", count: 2565 },\n { rank: word: \"and\", count: 1777 },\n { rank: word: \"of\", count: 1331 },\n { rank: word: \"that\", count: 1263 },\n { rank: word: \"to\", count: 1030 },\n { rank: word: \"in\", count: 1027 },\n { rank: word: \"it\", count: 754 },\n { rank: word: \"as\", count: 730 },\n { rank: word: \"was\", count: 687 },\n { rank: word: \"you\", count: 652 },\n { rank: word: \"for\", count: 630 },\n];\n","mode":"insert","cursor":{"row":1,"col":10},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":10},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":10},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":10},"anchor":{"row":3,"col":2}},{"cursor":{"row":4,"col":10},"anchor":{"row":4,"col":2}},{"cursor":{"row":5,"col":10},"anchor":{"row":5,"col":2}},{"cursor":{"row":6,"col":10},"anchor":{"row":6,"col":2}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":2}},{"cursor":{"row":8,"col":10},"anchor":{"row":8,"col":2}},{"cursor":{"row":9,"col":10},"anchor":{"row":9,"col":2}},{"cursor":{"row":10,"col":10},"anchor":{"row":10,"col":2}},{"cursor":{"row":11,"col":10},"anchor":{"row":11,"col":2}}],"primary":0} +{"name":"golf-enumerate-and-align-06","text":"[\n { rank: 1 word: \"a\", count: 2565 },\n { rank: 2 word: \"and\", count: 1777 },\n { rank: 3 word: \"of\", count: 1331 },\n { rank: 4 word: \"that\", count: 1263 },\n { rank: 5 word: \"to\", count: 1030 },\n { rank: 6 word: \"in\", count: 1027 },\n { rank: 7 word: \"it\", count: 754 },\n { rank: 8 word: \"as\", count: 730 },\n { rank: 9 word: \"was\", count: 687 },\n { rank: 10 word: \"you\", count: 652 },\n { rank: 11 word: \"for\", count: 630 },\n];\n","mode":"insert","cursor":{"row":1,"col":11},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":11},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":11},"anchor":{"row":3,"col":2}},{"cursor":{"row":4,"col":11},"anchor":{"row":4,"col":2}},{"cursor":{"row":5,"col":11},"anchor":{"row":5,"col":2}},{"cursor":{"row":6,"col":11},"anchor":{"row":6,"col":2}},{"cursor":{"row":7,"col":11},"anchor":{"row":7,"col":2}},{"cursor":{"row":8,"col":11},"anchor":{"row":8,"col":2}},{"cursor":{"row":9,"col":11},"anchor":{"row":9,"col":2}},{"cursor":{"row":10,"col":12},"anchor":{"row":10,"col":2}},{"cursor":{"row":11,"col":12},"anchor":{"row":11,"col":2}}],"primary":0} +{"name":"golf-enumerate-and-align-07","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"insert","cursor":{"row":1,"col":12},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":12},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":12},"anchor":{"row":3,"col":2}},{"cursor":{"row":4,"col":12},"anchor":{"row":4,"col":2}},{"cursor":{"row":5,"col":12},"anchor":{"row":5,"col":2}},{"cursor":{"row":6,"col":12},"anchor":{"row":6,"col":2}},{"cursor":{"row":7,"col":12},"anchor":{"row":7,"col":2}},{"cursor":{"row":8,"col":12},"anchor":{"row":8,"col":2}},{"cursor":{"row":9,"col":12},"anchor":{"row":9,"col":2}},{"cursor":{"row":10,"col":13},"anchor":{"row":10,"col":2}},{"cursor":{"row":11,"col":13},"anchor":{"row":11,"col":2}}],"primary":0} +{"name":"golf-enumerate-and-align-08","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":1,"col":11},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":11},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":11},"anchor":{"row":3,"col":2}},{"cursor":{"row":4,"col":11},"anchor":{"row":4,"col":2}},{"cursor":{"row":5,"col":11},"anchor":{"row":5,"col":2}},{"cursor":{"row":6,"col":11},"anchor":{"row":6,"col":2}},{"cursor":{"row":7,"col":11},"anchor":{"row":7,"col":2}},{"cursor":{"row":8,"col":11},"anchor":{"row":8,"col":2}},{"cursor":{"row":9,"col":11},"anchor":{"row":9,"col":2}},{"cursor":{"row":10,"col":12},"anchor":{"row":10,"col":2}},{"cursor":{"row":11,"col":12},"anchor":{"row":11,"col":2}}],"primary":0} +{"name":"golf-enumerate-and-align-09","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":12,"col":2},"anchor":{"row":0,"col":0}} +{"name":"golf-enumerate-and-align-10","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0},"sels":[{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0}},{"cursor":{"row":1,"col":1},"anchor":{"row":1,"col":1}},{"cursor":{"row":1,"col":3},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9}},{"cursor":{"row":1,"col":10},"anchor":{"row":1,"col":10}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":12}},{"cursor":{"row":1,"col":18},"anchor":{"row":1,"col":18}},{"cursor":{"row":1,"col":23},"anchor":{"row":1,"col":23}},{"cursor":{"row":1,"col":30},"anchor":{"row":1,"col":30}},{"cursor":{"row":1,"col":34},"anchor":{"row":1,"col":31}},{"cursor":{"row":1,"col":35},"anchor":{"row":1,"col":35}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":0}},{"cursor":{"row":2,"col":1},"anchor":{"row":2,"col":1}},{"cursor":{"row":2,"col":3},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":9},"anchor":{"row":2,"col":9}},{"cursor":{"row":2,"col":10},"anchor":{"row":2,"col":10}},{"cursor":{"row":2,"col":12},"anchor":{"row":2,"col":12}},{"cursor":{"row":2,"col":18},"anchor":{"row":2,"col":18}},{"cursor":{"row":2,"col":25},"anchor":{"row":2,"col":25}},{"cursor":{"row":2,"col":32},"anchor":{"row":2,"col":32}},{"cursor":{"row":2,"col":36},"anchor":{"row":2,"col":33}},{"cursor":{"row":2,"col":37},"anchor":{"row":2,"col":37}},{"cursor":{"row":3,"col":0},"anchor":{"row":3,"col":0}},{"cursor":{"row":3,"col":1},"anchor":{"row":3,"col":1}},{"cursor":{"row":3,"col":3},"anchor":{"row":3,"col":3}},{"cursor":{"row":3,"col":9},"anchor":{"row":3,"col":9}},{"cursor":{"row":3,"col":10},"anchor":{"row":3,"col":10}},{"cursor":{"row":3,"col":12},"anchor":{"row":3,"col":12}},{"cursor":{"row":3,"col":18},"anchor":{"row":3,"col":18}},{"cursor":{"row":3,"col":24},"anchor":{"row":3,"col":24}},{"cursor":{"row":3,"col":31},"anchor":{"row":3,"col":31}},{"cursor":{"row":3,"col":35},"anchor":{"row":3,"col":32}},{"cursor":{"row":3,"col":36},"anchor":{"row":3,"col":36}},{"cursor":{"row":4,"col":0},"anchor":{"row":4,"col":0}},{"cursor":{"row":4,"col":1},"anchor":{"row":4,"col":1}},{"cursor":{"row":4,"col":3},"anchor":{"row":4,"col":3}},{"cursor":{"row":4,"col":9},"anchor":{"row":4,"col":9}},{"cursor":{"row":4,"col":10},"anchor":{"row":4,"col":10}},{"cursor":{"row":4,"col":12},"anchor":{"row":4,"col":12}},{"cursor":{"row":4,"col":18},"anchor":{"row":4,"col":18}},{"cursor":{"row":4,"col":26},"anchor":{"row":4,"col":26}},{"cursor":{"row":4,"col":33},"anchor":{"row":4,"col":33}},{"cursor":{"row":4,"col":37},"anchor":{"row":4,"col":34}},{"cursor":{"row":4,"col":38},"anchor":{"row":4,"col":38}},{"cursor":{"row":5,"col":0},"anchor":{"row":5,"col":0}},{"cursor":{"row":5,"col":1},"anchor":{"row":5,"col":1}},{"cursor":{"row":5,"col":3},"anchor":{"row":5,"col":3}},{"cursor":{"row":5,"col":9},"anchor":{"row":5,"col":9}},{"cursor":{"row":5,"col":10},"anchor":{"row":5,"col":10}},{"cursor":{"row":5,"col":12},"anchor":{"row":5,"col":12}},{"cursor":{"row":5,"col":18},"anchor":{"row":5,"col":18}},{"cursor":{"row":5,"col":24},"anchor":{"row":5,"col":24}},{"cursor":{"row":5,"col":31},"anchor":{"row":5,"col":31}},{"cursor":{"row":5,"col":35},"anchor":{"row":5,"col":32}},{"cursor":{"row":5,"col":36},"anchor":{"row":5,"col":36}},{"cursor":{"row":6,"col":0},"anchor":{"row":6,"col":0}},{"cursor":{"row":6,"col":1},"anchor":{"row":6,"col":1}},{"cursor":{"row":6,"col":3},"anchor":{"row":6,"col":3}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":6,"col":10},"anchor":{"row":6,"col":10}},{"cursor":{"row":6,"col":12},"anchor":{"row":6,"col":12}},{"cursor":{"row":6,"col":18},"anchor":{"row":6,"col":18}},{"cursor":{"row":6,"col":24},"anchor":{"row":6,"col":24}},{"cursor":{"row":6,"col":31},"anchor":{"row":6,"col":31}},{"cursor":{"row":6,"col":35},"anchor":{"row":6,"col":32}},{"cursor":{"row":6,"col":36},"anchor":{"row":6,"col":36}},{"cursor":{"row":7,"col":0},"anchor":{"row":7,"col":0}},{"cursor":{"row":7,"col":1},"anchor":{"row":7,"col":1}},{"cursor":{"row":7,"col":3},"anchor":{"row":7,"col":3}},{"cursor":{"row":7,"col":9},"anchor":{"row":7,"col":9}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":10}},{"cursor":{"row":7,"col":12},"anchor":{"row":7,"col":12}},{"cursor":{"row":7,"col":18},"anchor":{"row":7,"col":18}},{"cursor":{"row":7,"col":24},"anchor":{"row":7,"col":24}},{"cursor":{"row":7,"col":31},"anchor":{"row":7,"col":31}},{"cursor":{"row":7,"col":34},"anchor":{"row":7,"col":32}},{"cursor":{"row":7,"col":35},"anchor":{"row":7,"col":35}},{"cursor":{"row":8,"col":0},"anchor":{"row":8,"col":0}},{"cursor":{"row":8,"col":1},"anchor":{"row":8,"col":1}},{"cursor":{"row":8,"col":3},"anchor":{"row":8,"col":3}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":8,"col":10},"anchor":{"row":8,"col":10}},{"cursor":{"row":8,"col":12},"anchor":{"row":8,"col":12}},{"cursor":{"row":8,"col":18},"anchor":{"row":8,"col":18}},{"cursor":{"row":8,"col":24},"anchor":{"row":8,"col":24}},{"cursor":{"row":8,"col":31},"anchor":{"row":8,"col":31}},{"cursor":{"row":8,"col":34},"anchor":{"row":8,"col":32}},{"cursor":{"row":8,"col":35},"anchor":{"row":8,"col":35}},{"cursor":{"row":9,"col":0},"anchor":{"row":9,"col":0}},{"cursor":{"row":9,"col":1},"anchor":{"row":9,"col":1}},{"cursor":{"row":9,"col":3},"anchor":{"row":9,"col":3}},{"cursor":{"row":9,"col":9},"anchor":{"row":9,"col":9}},{"cursor":{"row":9,"col":10},"anchor":{"row":9,"col":10}},{"cursor":{"row":9,"col":12},"anchor":{"row":9,"col":12}},{"cursor":{"row":9,"col":18},"anchor":{"row":9,"col":18}},{"cursor":{"row":9,"col":25},"anchor":{"row":9,"col":25}},{"cursor":{"row":9,"col":32},"anchor":{"row":9,"col":32}},{"cursor":{"row":9,"col":35},"anchor":{"row":9,"col":33}},{"cursor":{"row":9,"col":36},"anchor":{"row":9,"col":36}},{"cursor":{"row":10,"col":0},"anchor":{"row":10,"col":0}},{"cursor":{"row":10,"col":1},"anchor":{"row":10,"col":1}},{"cursor":{"row":10,"col":3},"anchor":{"row":10,"col":3}},{"cursor":{"row":10,"col":9},"anchor":{"row":10,"col":9}},{"cursor":{"row":10,"col":11},"anchor":{"row":10,"col":10}},{"cursor":{"row":10,"col":13},"anchor":{"row":10,"col":13}},{"cursor":{"row":10,"col":19},"anchor":{"row":10,"col":19}},{"cursor":{"row":10,"col":26},"anchor":{"row":10,"col":26}},{"cursor":{"row":10,"col":33},"anchor":{"row":10,"col":33}},{"cursor":{"row":10,"col":36},"anchor":{"row":10,"col":34}},{"cursor":{"row":10,"col":37},"anchor":{"row":10,"col":37}},{"cursor":{"row":11,"col":0},"anchor":{"row":11,"col":0}},{"cursor":{"row":11,"col":1},"anchor":{"row":11,"col":1}},{"cursor":{"row":11,"col":3},"anchor":{"row":11,"col":3}},{"cursor":{"row":11,"col":9},"anchor":{"row":11,"col":9}},{"cursor":{"row":11,"col":11},"anchor":{"row":11,"col":10}},{"cursor":{"row":11,"col":13},"anchor":{"row":11,"col":13}},{"cursor":{"row":11,"col":19},"anchor":{"row":11,"col":19}},{"cursor":{"row":11,"col":26},"anchor":{"row":11,"col":26}},{"cursor":{"row":11,"col":33},"anchor":{"row":11,"col":33}},{"cursor":{"row":11,"col":36},"anchor":{"row":11,"col":34}},{"cursor":{"row":11,"col":37},"anchor":{"row":11,"col":37}}],"primary":0} +{"name":"golf-enumerate-and-align","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0},"sels":[{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0}},{"cursor":{"row":1,"col":1},"anchor":{"row":1,"col":1}},{"cursor":{"row":1,"col":3},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9}},{"cursor":{"row":1,"col":11},"anchor":{"row":1,"col":11}},{"cursor":{"row":1,"col":13},"anchor":{"row":1,"col":13}},{"cursor":{"row":1,"col":19},"anchor":{"row":1,"col":19}},{"cursor":{"row":1,"col":27},"anchor":{"row":1,"col":27}},{"cursor":{"row":1,"col":34},"anchor":{"row":1,"col":34}},{"cursor":{"row":1,"col":38},"anchor":{"row":1,"col":35}},{"cursor":{"row":1,"col":39},"anchor":{"row":1,"col":39}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":0}},{"cursor":{"row":2,"col":1},"anchor":{"row":2,"col":1}},{"cursor":{"row":2,"col":3},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":9},"anchor":{"row":2,"col":9}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":11}},{"cursor":{"row":2,"col":13},"anchor":{"row":2,"col":13}},{"cursor":{"row":2,"col":19},"anchor":{"row":2,"col":19}},{"cursor":{"row":2,"col":27},"anchor":{"row":2,"col":27}},{"cursor":{"row":2,"col":34},"anchor":{"row":2,"col":34}},{"cursor":{"row":2,"col":38},"anchor":{"row":2,"col":35}},{"cursor":{"row":2,"col":39},"anchor":{"row":2,"col":39}},{"cursor":{"row":3,"col":0},"anchor":{"row":3,"col":0}},{"cursor":{"row":3,"col":1},"anchor":{"row":3,"col":1}},{"cursor":{"row":3,"col":3},"anchor":{"row":3,"col":3}},{"cursor":{"row":3,"col":9},"anchor":{"row":3,"col":9}},{"cursor":{"row":3,"col":11},"anchor":{"row":3,"col":11}},{"cursor":{"row":3,"col":13},"anchor":{"row":3,"col":13}},{"cursor":{"row":3,"col":19},"anchor":{"row":3,"col":19}},{"cursor":{"row":3,"col":27},"anchor":{"row":3,"col":27}},{"cursor":{"row":3,"col":34},"anchor":{"row":3,"col":34}},{"cursor":{"row":3,"col":38},"anchor":{"row":3,"col":35}},{"cursor":{"row":3,"col":39},"anchor":{"row":3,"col":39}},{"cursor":{"row":4,"col":0},"anchor":{"row":4,"col":0}},{"cursor":{"row":4,"col":1},"anchor":{"row":4,"col":1}},{"cursor":{"row":4,"col":3},"anchor":{"row":4,"col":3}},{"cursor":{"row":4,"col":9},"anchor":{"row":4,"col":9}},{"cursor":{"row":4,"col":11},"anchor":{"row":4,"col":11}},{"cursor":{"row":4,"col":13},"anchor":{"row":4,"col":13}},{"cursor":{"row":4,"col":19},"anchor":{"row":4,"col":19}},{"cursor":{"row":4,"col":27},"anchor":{"row":4,"col":27}},{"cursor":{"row":4,"col":34},"anchor":{"row":4,"col":34}},{"cursor":{"row":4,"col":38},"anchor":{"row":4,"col":35}},{"cursor":{"row":4,"col":39},"anchor":{"row":4,"col":39}},{"cursor":{"row":5,"col":0},"anchor":{"row":5,"col":0}},{"cursor":{"row":5,"col":1},"anchor":{"row":5,"col":1}},{"cursor":{"row":5,"col":3},"anchor":{"row":5,"col":3}},{"cursor":{"row":5,"col":9},"anchor":{"row":5,"col":9}},{"cursor":{"row":5,"col":11},"anchor":{"row":5,"col":11}},{"cursor":{"row":5,"col":13},"anchor":{"row":5,"col":13}},{"cursor":{"row":5,"col":19},"anchor":{"row":5,"col":19}},{"cursor":{"row":5,"col":27},"anchor":{"row":5,"col":27}},{"cursor":{"row":5,"col":34},"anchor":{"row":5,"col":34}},{"cursor":{"row":5,"col":38},"anchor":{"row":5,"col":35}},{"cursor":{"row":5,"col":39},"anchor":{"row":5,"col":39}},{"cursor":{"row":6,"col":0},"anchor":{"row":6,"col":0}},{"cursor":{"row":6,"col":1},"anchor":{"row":6,"col":1}},{"cursor":{"row":6,"col":3},"anchor":{"row":6,"col":3}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":6,"col":11},"anchor":{"row":6,"col":11}},{"cursor":{"row":6,"col":13},"anchor":{"row":6,"col":13}},{"cursor":{"row":6,"col":19},"anchor":{"row":6,"col":19}},{"cursor":{"row":6,"col":27},"anchor":{"row":6,"col":27}},{"cursor":{"row":6,"col":34},"anchor":{"row":6,"col":34}},{"cursor":{"row":6,"col":38},"anchor":{"row":6,"col":35}},{"cursor":{"row":6,"col":39},"anchor":{"row":6,"col":39}},{"cursor":{"row":7,"col":0},"anchor":{"row":7,"col":0}},{"cursor":{"row":7,"col":1},"anchor":{"row":7,"col":1}},{"cursor":{"row":7,"col":3},"anchor":{"row":7,"col":3}},{"cursor":{"row":7,"col":9},"anchor":{"row":7,"col":9}},{"cursor":{"row":7,"col":11},"anchor":{"row":7,"col":11}},{"cursor":{"row":7,"col":13},"anchor":{"row":7,"col":13}},{"cursor":{"row":7,"col":19},"anchor":{"row":7,"col":19}},{"cursor":{"row":7,"col":27},"anchor":{"row":7,"col":27}},{"cursor":{"row":7,"col":34},"anchor":{"row":7,"col":34}},{"cursor":{"row":7,"col":38},"anchor":{"row":7,"col":36}},{"cursor":{"row":7,"col":39},"anchor":{"row":7,"col":39}},{"cursor":{"row":8,"col":0},"anchor":{"row":8,"col":0}},{"cursor":{"row":8,"col":1},"anchor":{"row":8,"col":1}},{"cursor":{"row":8,"col":3},"anchor":{"row":8,"col":3}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":8,"col":11},"anchor":{"row":8,"col":11}},{"cursor":{"row":8,"col":13},"anchor":{"row":8,"col":13}},{"cursor":{"row":8,"col":19},"anchor":{"row":8,"col":19}},{"cursor":{"row":8,"col":27},"anchor":{"row":8,"col":27}},{"cursor":{"row":8,"col":34},"anchor":{"row":8,"col":34}},{"cursor":{"row":8,"col":38},"anchor":{"row":8,"col":36}},{"cursor":{"row":8,"col":39},"anchor":{"row":8,"col":39}},{"cursor":{"row":9,"col":0},"anchor":{"row":9,"col":0}},{"cursor":{"row":9,"col":1},"anchor":{"row":9,"col":1}},{"cursor":{"row":9,"col":3},"anchor":{"row":9,"col":3}},{"cursor":{"row":9,"col":9},"anchor":{"row":9,"col":9}},{"cursor":{"row":9,"col":11},"anchor":{"row":9,"col":11}},{"cursor":{"row":9,"col":13},"anchor":{"row":9,"col":13}},{"cursor":{"row":9,"col":19},"anchor":{"row":9,"col":19}},{"cursor":{"row":9,"col":27},"anchor":{"row":9,"col":27}},{"cursor":{"row":9,"col":34},"anchor":{"row":9,"col":34}},{"cursor":{"row":9,"col":38},"anchor":{"row":9,"col":36}},{"cursor":{"row":9,"col":39},"anchor":{"row":9,"col":39}},{"cursor":{"row":10,"col":0},"anchor":{"row":10,"col":0}},{"cursor":{"row":10,"col":1},"anchor":{"row":10,"col":1}},{"cursor":{"row":10,"col":3},"anchor":{"row":10,"col":3}},{"cursor":{"row":10,"col":9},"anchor":{"row":10,"col":9}},{"cursor":{"row":10,"col":11},"anchor":{"row":10,"col":10}},{"cursor":{"row":10,"col":13},"anchor":{"row":10,"col":13}},{"cursor":{"row":10,"col":19},"anchor":{"row":10,"col":19}},{"cursor":{"row":10,"col":27},"anchor":{"row":10,"col":27}},{"cursor":{"row":10,"col":34},"anchor":{"row":10,"col":34}},{"cursor":{"row":10,"col":38},"anchor":{"row":10,"col":36}},{"cursor":{"row":10,"col":39},"anchor":{"row":10,"col":39}},{"cursor":{"row":11,"col":0},"anchor":{"row":11,"col":0}},{"cursor":{"row":11,"col":1},"anchor":{"row":11,"col":1}},{"cursor":{"row":11,"col":3},"anchor":{"row":11,"col":3}},{"cursor":{"row":11,"col":9},"anchor":{"row":11,"col":9}},{"cursor":{"row":11,"col":11},"anchor":{"row":11,"col":10}},{"cursor":{"row":11,"col":13},"anchor":{"row":11,"col":13}},{"cursor":{"row":11,"col":19},"anchor":{"row":11,"col":19}},{"cursor":{"row":11,"col":27},"anchor":{"row":11,"col":27}},{"cursor":{"row":11,"col":34},"anchor":{"row":11,"col":34}},{"cursor":{"row":11,"col":38},"anchor":{"row":11,"col":36}},{"cursor":{"row":11,"col":39},"anchor":{"row":11,"col":39}}],"primary":0} +{"name":"golf-enumerate-and-align-from09-09","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":12,"col":2},"anchor":{"row":0,"col":0}} +{"name":"golf-enumerate-and-align-from09-10","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0},"sels":[{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0}},{"cursor":{"row":1,"col":1},"anchor":{"row":1,"col":1}},{"cursor":{"row":1,"col":3},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9}},{"cursor":{"row":1,"col":10},"anchor":{"row":1,"col":10}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":12}},{"cursor":{"row":1,"col":18},"anchor":{"row":1,"col":18}},{"cursor":{"row":1,"col":23},"anchor":{"row":1,"col":23}},{"cursor":{"row":1,"col":30},"anchor":{"row":1,"col":30}},{"cursor":{"row":1,"col":34},"anchor":{"row":1,"col":31}},{"cursor":{"row":1,"col":35},"anchor":{"row":1,"col":35}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":0}},{"cursor":{"row":2,"col":1},"anchor":{"row":2,"col":1}},{"cursor":{"row":2,"col":3},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":9},"anchor":{"row":2,"col":9}},{"cursor":{"row":2,"col":10},"anchor":{"row":2,"col":10}},{"cursor":{"row":2,"col":12},"anchor":{"row":2,"col":12}},{"cursor":{"row":2,"col":18},"anchor":{"row":2,"col":18}},{"cursor":{"row":2,"col":25},"anchor":{"row":2,"col":25}},{"cursor":{"row":2,"col":32},"anchor":{"row":2,"col":32}},{"cursor":{"row":2,"col":36},"anchor":{"row":2,"col":33}},{"cursor":{"row":2,"col":37},"anchor":{"row":2,"col":37}},{"cursor":{"row":3,"col":0},"anchor":{"row":3,"col":0}},{"cursor":{"row":3,"col":1},"anchor":{"row":3,"col":1}},{"cursor":{"row":3,"col":3},"anchor":{"row":3,"col":3}},{"cursor":{"row":3,"col":9},"anchor":{"row":3,"col":9}},{"cursor":{"row":3,"col":10},"anchor":{"row":3,"col":10}},{"cursor":{"row":3,"col":12},"anchor":{"row":3,"col":12}},{"cursor":{"row":3,"col":18},"anchor":{"row":3,"col":18}},{"cursor":{"row":3,"col":24},"anchor":{"row":3,"col":24}},{"cursor":{"row":3,"col":31},"anchor":{"row":3,"col":31}},{"cursor":{"row":3,"col":35},"anchor":{"row":3,"col":32}},{"cursor":{"row":3,"col":36},"anchor":{"row":3,"col":36}},{"cursor":{"row":4,"col":0},"anchor":{"row":4,"col":0}},{"cursor":{"row":4,"col":1},"anchor":{"row":4,"col":1}},{"cursor":{"row":4,"col":3},"anchor":{"row":4,"col":3}},{"cursor":{"row":4,"col":9},"anchor":{"row":4,"col":9}},{"cursor":{"row":4,"col":10},"anchor":{"row":4,"col":10}},{"cursor":{"row":4,"col":12},"anchor":{"row":4,"col":12}},{"cursor":{"row":4,"col":18},"anchor":{"row":4,"col":18}},{"cursor":{"row":4,"col":26},"anchor":{"row":4,"col":26}},{"cursor":{"row":4,"col":33},"anchor":{"row":4,"col":33}},{"cursor":{"row":4,"col":37},"anchor":{"row":4,"col":34}},{"cursor":{"row":4,"col":38},"anchor":{"row":4,"col":38}},{"cursor":{"row":5,"col":0},"anchor":{"row":5,"col":0}},{"cursor":{"row":5,"col":1},"anchor":{"row":5,"col":1}},{"cursor":{"row":5,"col":3},"anchor":{"row":5,"col":3}},{"cursor":{"row":5,"col":9},"anchor":{"row":5,"col":9}},{"cursor":{"row":5,"col":10},"anchor":{"row":5,"col":10}},{"cursor":{"row":5,"col":12},"anchor":{"row":5,"col":12}},{"cursor":{"row":5,"col":18},"anchor":{"row":5,"col":18}},{"cursor":{"row":5,"col":24},"anchor":{"row":5,"col":24}},{"cursor":{"row":5,"col":31},"anchor":{"row":5,"col":31}},{"cursor":{"row":5,"col":35},"anchor":{"row":5,"col":32}},{"cursor":{"row":5,"col":36},"anchor":{"row":5,"col":36}},{"cursor":{"row":6,"col":0},"anchor":{"row":6,"col":0}},{"cursor":{"row":6,"col":1},"anchor":{"row":6,"col":1}},{"cursor":{"row":6,"col":3},"anchor":{"row":6,"col":3}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":6,"col":10},"anchor":{"row":6,"col":10}},{"cursor":{"row":6,"col":12},"anchor":{"row":6,"col":12}},{"cursor":{"row":6,"col":18},"anchor":{"row":6,"col":18}},{"cursor":{"row":6,"col":24},"anchor":{"row":6,"col":24}},{"cursor":{"row":6,"col":31},"anchor":{"row":6,"col":31}},{"cursor":{"row":6,"col":35},"anchor":{"row":6,"col":32}},{"cursor":{"row":6,"col":36},"anchor":{"row":6,"col":36}},{"cursor":{"row":7,"col":0},"anchor":{"row":7,"col":0}},{"cursor":{"row":7,"col":1},"anchor":{"row":7,"col":1}},{"cursor":{"row":7,"col":3},"anchor":{"row":7,"col":3}},{"cursor":{"row":7,"col":9},"anchor":{"row":7,"col":9}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":10}},{"cursor":{"row":7,"col":12},"anchor":{"row":7,"col":12}},{"cursor":{"row":7,"col":18},"anchor":{"row":7,"col":18}},{"cursor":{"row":7,"col":24},"anchor":{"row":7,"col":24}},{"cursor":{"row":7,"col":31},"anchor":{"row":7,"col":31}},{"cursor":{"row":7,"col":34},"anchor":{"row":7,"col":32}},{"cursor":{"row":7,"col":35},"anchor":{"row":7,"col":35}},{"cursor":{"row":8,"col":0},"anchor":{"row":8,"col":0}},{"cursor":{"row":8,"col":1},"anchor":{"row":8,"col":1}},{"cursor":{"row":8,"col":3},"anchor":{"row":8,"col":3}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":8,"col":10},"anchor":{"row":8,"col":10}},{"cursor":{"row":8,"col":12},"anchor":{"row":8,"col":12}},{"cursor":{"row":8,"col":18},"anchor":{"row":8,"col":18}},{"cursor":{"row":8,"col":24},"anchor":{"row":8,"col":24}},{"cursor":{"row":8,"col":31},"anchor":{"row":8,"col":31}},{"cursor":{"row":8,"col":34},"anchor":{"row":8,"col":32}},{"cursor":{"row":8,"col":35},"anchor":{"row":8,"col":35}},{"cursor":{"row":9,"col":0},"anchor":{"row":9,"col":0}},{"cursor":{"row":9,"col":1},"anchor":{"row":9,"col":1}},{"cursor":{"row":9,"col":3},"anchor":{"row":9,"col":3}},{"cursor":{"row":9,"col":9},"anchor":{"row":9,"col":9}},{"cursor":{"row":9,"col":10},"anchor":{"row":9,"col":10}},{"cursor":{"row":9,"col":12},"anchor":{"row":9,"col":12}},{"cursor":{"row":9,"col":18},"anchor":{"row":9,"col":18}},{"cursor":{"row":9,"col":25},"anchor":{"row":9,"col":25}},{"cursor":{"row":9,"col":32},"anchor":{"row":9,"col":32}},{"cursor":{"row":9,"col":35},"anchor":{"row":9,"col":33}},{"cursor":{"row":9,"col":36},"anchor":{"row":9,"col":36}},{"cursor":{"row":10,"col":0},"anchor":{"row":10,"col":0}},{"cursor":{"row":10,"col":1},"anchor":{"row":10,"col":1}},{"cursor":{"row":10,"col":3},"anchor":{"row":10,"col":3}},{"cursor":{"row":10,"col":9},"anchor":{"row":10,"col":9}},{"cursor":{"row":10,"col":11},"anchor":{"row":10,"col":10}},{"cursor":{"row":10,"col":13},"anchor":{"row":10,"col":13}},{"cursor":{"row":10,"col":19},"anchor":{"row":10,"col":19}},{"cursor":{"row":10,"col":26},"anchor":{"row":10,"col":26}},{"cursor":{"row":10,"col":33},"anchor":{"row":10,"col":33}},{"cursor":{"row":10,"col":36},"anchor":{"row":10,"col":34}},{"cursor":{"row":10,"col":37},"anchor":{"row":10,"col":37}},{"cursor":{"row":11,"col":0},"anchor":{"row":11,"col":0}},{"cursor":{"row":11,"col":1},"anchor":{"row":11,"col":1}},{"cursor":{"row":11,"col":3},"anchor":{"row":11,"col":3}},{"cursor":{"row":11,"col":9},"anchor":{"row":11,"col":9}},{"cursor":{"row":11,"col":11},"anchor":{"row":11,"col":10}},{"cursor":{"row":11,"col":13},"anchor":{"row":11,"col":13}},{"cursor":{"row":11,"col":19},"anchor":{"row":11,"col":19}},{"cursor":{"row":11,"col":26},"anchor":{"row":11,"col":26}},{"cursor":{"row":11,"col":33},"anchor":{"row":11,"col":33}},{"cursor":{"row":11,"col":36},"anchor":{"row":11,"col":34}},{"cursor":{"row":11,"col":37},"anchor":{"row":11,"col":37}}],"primary":0} +{"name":"golf-enumerate-and-align-from09","text":"[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n","mode":"normal","cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0},"sels":[{"cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0}},{"cursor":{"row":1,"col":1},"anchor":{"row":1,"col":1}},{"cursor":{"row":1,"col":3},"anchor":{"row":1,"col":3}},{"cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9}},{"cursor":{"row":1,"col":11},"anchor":{"row":1,"col":11}},{"cursor":{"row":1,"col":13},"anchor":{"row":1,"col":13}},{"cursor":{"row":1,"col":19},"anchor":{"row":1,"col":19}},{"cursor":{"row":1,"col":27},"anchor":{"row":1,"col":27}},{"cursor":{"row":1,"col":34},"anchor":{"row":1,"col":34}},{"cursor":{"row":1,"col":38},"anchor":{"row":1,"col":35}},{"cursor":{"row":1,"col":39},"anchor":{"row":1,"col":39}},{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":0}},{"cursor":{"row":2,"col":1},"anchor":{"row":2,"col":1}},{"cursor":{"row":2,"col":3},"anchor":{"row":2,"col":3}},{"cursor":{"row":2,"col":9},"anchor":{"row":2,"col":9}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":11}},{"cursor":{"row":2,"col":13},"anchor":{"row":2,"col":13}},{"cursor":{"row":2,"col":19},"anchor":{"row":2,"col":19}},{"cursor":{"row":2,"col":27},"anchor":{"row":2,"col":27}},{"cursor":{"row":2,"col":34},"anchor":{"row":2,"col":34}},{"cursor":{"row":2,"col":38},"anchor":{"row":2,"col":35}},{"cursor":{"row":2,"col":39},"anchor":{"row":2,"col":39}},{"cursor":{"row":3,"col":0},"anchor":{"row":3,"col":0}},{"cursor":{"row":3,"col":1},"anchor":{"row":3,"col":1}},{"cursor":{"row":3,"col":3},"anchor":{"row":3,"col":3}},{"cursor":{"row":3,"col":9},"anchor":{"row":3,"col":9}},{"cursor":{"row":3,"col":11},"anchor":{"row":3,"col":11}},{"cursor":{"row":3,"col":13},"anchor":{"row":3,"col":13}},{"cursor":{"row":3,"col":19},"anchor":{"row":3,"col":19}},{"cursor":{"row":3,"col":27},"anchor":{"row":3,"col":27}},{"cursor":{"row":3,"col":34},"anchor":{"row":3,"col":34}},{"cursor":{"row":3,"col":38},"anchor":{"row":3,"col":35}},{"cursor":{"row":3,"col":39},"anchor":{"row":3,"col":39}},{"cursor":{"row":4,"col":0},"anchor":{"row":4,"col":0}},{"cursor":{"row":4,"col":1},"anchor":{"row":4,"col":1}},{"cursor":{"row":4,"col":3},"anchor":{"row":4,"col":3}},{"cursor":{"row":4,"col":9},"anchor":{"row":4,"col":9}},{"cursor":{"row":4,"col":11},"anchor":{"row":4,"col":11}},{"cursor":{"row":4,"col":13},"anchor":{"row":4,"col":13}},{"cursor":{"row":4,"col":19},"anchor":{"row":4,"col":19}},{"cursor":{"row":4,"col":27},"anchor":{"row":4,"col":27}},{"cursor":{"row":4,"col":34},"anchor":{"row":4,"col":34}},{"cursor":{"row":4,"col":38},"anchor":{"row":4,"col":35}},{"cursor":{"row":4,"col":39},"anchor":{"row":4,"col":39}},{"cursor":{"row":5,"col":0},"anchor":{"row":5,"col":0}},{"cursor":{"row":5,"col":1},"anchor":{"row":5,"col":1}},{"cursor":{"row":5,"col":3},"anchor":{"row":5,"col":3}},{"cursor":{"row":5,"col":9},"anchor":{"row":5,"col":9}},{"cursor":{"row":5,"col":11},"anchor":{"row":5,"col":11}},{"cursor":{"row":5,"col":13},"anchor":{"row":5,"col":13}},{"cursor":{"row":5,"col":19},"anchor":{"row":5,"col":19}},{"cursor":{"row":5,"col":27},"anchor":{"row":5,"col":27}},{"cursor":{"row":5,"col":34},"anchor":{"row":5,"col":34}},{"cursor":{"row":5,"col":38},"anchor":{"row":5,"col":35}},{"cursor":{"row":5,"col":39},"anchor":{"row":5,"col":39}},{"cursor":{"row":6,"col":0},"anchor":{"row":6,"col":0}},{"cursor":{"row":6,"col":1},"anchor":{"row":6,"col":1}},{"cursor":{"row":6,"col":3},"anchor":{"row":6,"col":3}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":6,"col":11},"anchor":{"row":6,"col":11}},{"cursor":{"row":6,"col":13},"anchor":{"row":6,"col":13}},{"cursor":{"row":6,"col":19},"anchor":{"row":6,"col":19}},{"cursor":{"row":6,"col":27},"anchor":{"row":6,"col":27}},{"cursor":{"row":6,"col":34},"anchor":{"row":6,"col":34}},{"cursor":{"row":6,"col":38},"anchor":{"row":6,"col":35}},{"cursor":{"row":6,"col":39},"anchor":{"row":6,"col":39}},{"cursor":{"row":7,"col":0},"anchor":{"row":7,"col":0}},{"cursor":{"row":7,"col":1},"anchor":{"row":7,"col":1}},{"cursor":{"row":7,"col":3},"anchor":{"row":7,"col":3}},{"cursor":{"row":7,"col":9},"anchor":{"row":7,"col":9}},{"cursor":{"row":7,"col":11},"anchor":{"row":7,"col":11}},{"cursor":{"row":7,"col":13},"anchor":{"row":7,"col":13}},{"cursor":{"row":7,"col":19},"anchor":{"row":7,"col":19}},{"cursor":{"row":7,"col":27},"anchor":{"row":7,"col":27}},{"cursor":{"row":7,"col":34},"anchor":{"row":7,"col":34}},{"cursor":{"row":7,"col":38},"anchor":{"row":7,"col":36}},{"cursor":{"row":7,"col":39},"anchor":{"row":7,"col":39}},{"cursor":{"row":8,"col":0},"anchor":{"row":8,"col":0}},{"cursor":{"row":8,"col":1},"anchor":{"row":8,"col":1}},{"cursor":{"row":8,"col":3},"anchor":{"row":8,"col":3}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":8,"col":11},"anchor":{"row":8,"col":11}},{"cursor":{"row":8,"col":13},"anchor":{"row":8,"col":13}},{"cursor":{"row":8,"col":19},"anchor":{"row":8,"col":19}},{"cursor":{"row":8,"col":27},"anchor":{"row":8,"col":27}},{"cursor":{"row":8,"col":34},"anchor":{"row":8,"col":34}},{"cursor":{"row":8,"col":38},"anchor":{"row":8,"col":36}},{"cursor":{"row":8,"col":39},"anchor":{"row":8,"col":39}},{"cursor":{"row":9,"col":0},"anchor":{"row":9,"col":0}},{"cursor":{"row":9,"col":1},"anchor":{"row":9,"col":1}},{"cursor":{"row":9,"col":3},"anchor":{"row":9,"col":3}},{"cursor":{"row":9,"col":9},"anchor":{"row":9,"col":9}},{"cursor":{"row":9,"col":11},"anchor":{"row":9,"col":11}},{"cursor":{"row":9,"col":13},"anchor":{"row":9,"col":13}},{"cursor":{"row":9,"col":19},"anchor":{"row":9,"col":19}},{"cursor":{"row":9,"col":27},"anchor":{"row":9,"col":27}},{"cursor":{"row":9,"col":34},"anchor":{"row":9,"col":34}},{"cursor":{"row":9,"col":38},"anchor":{"row":9,"col":36}},{"cursor":{"row":9,"col":39},"anchor":{"row":9,"col":39}},{"cursor":{"row":10,"col":0},"anchor":{"row":10,"col":0}},{"cursor":{"row":10,"col":1},"anchor":{"row":10,"col":1}},{"cursor":{"row":10,"col":3},"anchor":{"row":10,"col":3}},{"cursor":{"row":10,"col":9},"anchor":{"row":10,"col":9}},{"cursor":{"row":10,"col":11},"anchor":{"row":10,"col":10}},{"cursor":{"row":10,"col":13},"anchor":{"row":10,"col":13}},{"cursor":{"row":10,"col":19},"anchor":{"row":10,"col":19}},{"cursor":{"row":10,"col":27},"anchor":{"row":10,"col":27}},{"cursor":{"row":10,"col":34},"anchor":{"row":10,"col":34}},{"cursor":{"row":10,"col":38},"anchor":{"row":10,"col":36}},{"cursor":{"row":10,"col":39},"anchor":{"row":10,"col":39}},{"cursor":{"row":11,"col":0},"anchor":{"row":11,"col":0}},{"cursor":{"row":11,"col":1},"anchor":{"row":11,"col":1}},{"cursor":{"row":11,"col":3},"anchor":{"row":11,"col":3}},{"cursor":{"row":11,"col":9},"anchor":{"row":11,"col":9}},{"cursor":{"row":11,"col":11},"anchor":{"row":11,"col":10}},{"cursor":{"row":11,"col":13},"anchor":{"row":11,"col":13}},{"cursor":{"row":11,"col":19},"anchor":{"row":11,"col":19}},{"cursor":{"row":11,"col":27},"anchor":{"row":11,"col":27}},{"cursor":{"row":11,"col":34},"anchor":{"row":11,"col":34}},{"cursor":{"row":11,"col":38},"anchor":{"row":11,"col":36}},{"cursor":{"row":11,"col":39},"anchor":{"row":11,"col":39}}],"primary":0} +{"name":"golf-export-from-mod-01","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n","mode":"normal","cursor":{"row":2,"col":13},"anchor":{"row":0,"col":0}} +{"name":"golf-export-from-mod-02","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\nmod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n","mode":"normal","cursor":{"row":5,"col":13},"anchor":{"row":3,"col":0}} +{"name":"golf-export-from-mod-03","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n\nmod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n","mode":"normal","cursor":{"row":6,"col":13},"anchor":{"row":4,"col":0}} +{"name":"golf-export-from-mod-04","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n\nmod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n","mode":"normal","cursor":{"row":4,"col":2},"anchor":{"row":4,"col":0},"sels":[{"cursor":{"row":4,"col":2},"anchor":{"row":4,"col":0}},{"cursor":{"row":5,"col":2},"anchor":{"row":5,"col":0}},{"cursor":{"row":6,"col":2},"anchor":{"row":6,"col":0}}],"primary":0} +{"name":"golf-export-from-mod-05","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n\npub use generate_demos;\npub use mdbook_preprocessor;\npub use validate;\n","mode":"normal","cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7},"sels":[{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7}},{"cursor":{"row":6,"col":7},"anchor":{"row":6,"col":7}}],"primary":0} +{"name":"golf-export-from-mod-06","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n\npub use generate_demos;\npub use mdbook_preprocessor;\npub use validate;\n","mode":"normal","cursor":{"row":4,"col":21},"anchor":{"row":4,"col":8},"sels":[{"cursor":{"row":4,"col":21},"anchor":{"row":4,"col":8}},{"cursor":{"row":5,"col":26},"anchor":{"row":5,"col":8}},{"cursor":{"row":6,"col":15},"anchor":{"row":6,"col":8}}],"primary":0} +{"name":"golf-export-from-mod-07","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n\npub use generate_demosgenerate_demos;\npub use mdbook_preprocessormdbook_preprocessor;\npub use validatevalidate;\n","mode":"normal","cursor":{"row":4,"col":35},"anchor":{"row":4,"col":22},"sels":[{"cursor":{"row":4,"col":35},"anchor":{"row":4,"col":22}},{"cursor":{"row":5,"col":45},"anchor":{"row":5,"col":27}},{"cursor":{"row":6,"col":23},"anchor":{"row":6,"col":16}}],"primary":0} +{"name":"golf-export-from-mod","text":"mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n\npub use generate_demos::generate_demos;\npub use mdbook_preprocessor::mdbook_preprocessor;\npub use validate::validate;\n","mode":"insert","cursor":{"row":4,"col":24},"anchor":{"row":4,"col":37},"sels":[{"cursor":{"row":4,"col":24},"anchor":{"row":4,"col":37}},{"cursor":{"row":5,"col":29},"anchor":{"row":5,"col":47}},{"cursor":{"row":6,"col":18},"anchor":{"row":6,"col":25}}],"primary":0} +{"name":"golf-function-into-class-01","text":"def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"normal","cursor":{"row":10,"col":17},"anchor":{"row":0,"col":0}} +{"name":"golf-function-into-class-02","text":"def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"normal","cursor":{"row":0,"col":12},"anchor":{"row":0,"col":4},"sels":[{"cursor":{"row":0,"col":12},"anchor":{"row":0,"col":4}},{"cursor":{"row":4,"col":12},"anchor":{"row":4,"col":4}},{"cursor":{"row":8,"col":12},"anchor":{"row":8,"col":4}}],"primary":0} +{"name":"golf-function-into-class-03","text":"def get_area(length, width):\n result = length * width\n return result\n\ndef get_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef get_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"insert","cursor":{"row":0,"col":7},"anchor":{"row":0,"col":7},"sels":[{"cursor":{"row":0,"col":7},"anchor":{"row":0,"col":7}},{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":8,"col":7},"anchor":{"row":8,"col":7}}],"primary":0} +{"name":"golf-function-into-class-04","text":"def get_area(length, width):\n result = length * width\n return result\n\ndef get_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef get_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"normal","cursor":{"row":0,"col":7},"anchor":{"row":0,"col":7},"sels":[{"cursor":{"row":0,"col":7},"anchor":{"row":0,"col":7}},{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":8,"col":7},"anchor":{"row":8,"col":7}}],"primary":0} +{"name":"golf-function-into-class-05","text":"@staticmethod\ndef get_area(length, width):\n result = length * width\n return result\n\n@staticmethod\ndef get_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\n@staticmethod\ndef get_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"insert","cursor":{"row":0,"col":13},"anchor":{"row":0,"col":13},"sels":[{"cursor":{"row":0,"col":13},"anchor":{"row":0,"col":13}},{"cursor":{"row":5,"col":13},"anchor":{"row":5,"col":13}},{"cursor":{"row":10,"col":13},"anchor":{"row":10,"col":13}}],"primary":0} +{"name":"golf-function-into-class-06","text":"@staticmethod\ndef get_area(length, width):\n result = length * width\n return result\n\n@staticmethod\ndef get_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\n@staticmethod\ndef get_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"normal","cursor":{"row":0,"col":13},"anchor":{"row":0,"col":13},"sels":[{"cursor":{"row":0,"col":13},"anchor":{"row":0,"col":13}},{"cursor":{"row":5,"col":13},"anchor":{"row":5,"col":13}},{"cursor":{"row":10,"col":13},"anchor":{"row":10,"col":13}}],"primary":0} +{"name":"golf-function-into-class-07","text":"@staticmethod\ndef get_area(length, width):\n result = length * width\n return result\n\n@staticmethod\ndef get_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\n@staticmethod\ndef get_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"normal","cursor":{"row":2,"col":13},"anchor":{"row":2,"col":13},"sels":[{"cursor":{"row":2,"col":13},"anchor":{"row":2,"col":13}},{"cursor":{"row":7,"col":13},"anchor":{"row":7,"col":13}},{"cursor":{"row":12,"col":13},"anchor":{"row":12,"col":13}}],"primary":0} +{"name":"golf-function-into-class-08","text":"@staticmethod\ndef get_area(length, width):\n result = length * width\n return result\n\n@staticmethod\ndef get_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\n@staticmethod\ndef get_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"select","cursor":{"row":2,"col":26},"anchor":{"row":2,"col":13},"sels":[{"cursor":{"row":2,"col":26},"anchor":{"row":2,"col":13}},{"cursor":{"row":7,"col":32},"anchor":{"row":7,"col":13}},{"cursor":{"row":12,"col":35},"anchor":{"row":12,"col":13}}],"primary":0} +{"name":"golf-function-into-class-09","text":"@staticmethod\ndef get_area(length, width):\n result = length * width\n return result\n\n@staticmethod\ndef get_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\n@staticmethod\ndef get_volume(length, width, height):\n result = length * width * height\n return result\n","mode":"normal","cursor":{"row":2,"col":26},"anchor":{"row":2,"col":13},"sels":[{"cursor":{"row":2,"col":26},"anchor":{"row":2,"col":13}},{"cursor":{"row":7,"col":32},"anchor":{"row":7,"col":13}},{"cursor":{"row":12,"col":35},"anchor":{"row":12,"col":13}}],"primary":0} +{"name":"golf-function-into-class-10","text":"@staticmethod\ndef get_area(length, width):\n return result\n\n@staticmethod\ndef get_perimiter(length, width):\n return result\n\n@staticmethod\ndef get_volume(length, width, height):\n return result\n","mode":"normal","cursor":{"row":2,"col":0},"anchor":{"row":2,"col":0},"sels":[{"cursor":{"row":2,"col":0},"anchor":{"row":2,"col":0}},{"cursor":{"row":6,"col":0},"anchor":{"row":6,"col":0}},{"cursor":{"row":10,"col":0},"anchor":{"row":10,"col":0}}],"primary":0} +{"name":"golf-function-into-class-11","text":"@staticmethod\ndef get_area(length, width):\n return result\n\n@staticmethod\ndef get_perimiter(length, width):\n return result\n\n@staticmethod\ndef get_volume(length, width, height):\n return result\n","mode":"normal","cursor":{"row":2,"col":11},"anchor":{"row":2,"col":16},"sels":[{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":16}},{"cursor":{"row":6,"col":11},"anchor":{"row":6,"col":16}},{"cursor":{"row":10,"col":11},"anchor":{"row":10,"col":16}}],"primary":0} +{"name":"golf-function-into-class-12","text":"@staticmethod\ndef get_area(length, width):\n return length * width\n\n@staticmethod\ndef get_perimiter(length, width):\n return 2 * (length + width)\n\n@staticmethod\ndef get_volume(length, width, height):\n return length * width * height\n","mode":"normal","cursor":{"row":2,"col":11},"anchor":{"row":2,"col":24},"sels":[{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":24}},{"cursor":{"row":6,"col":11},"anchor":{"row":6,"col":30}},{"cursor":{"row":10,"col":11},"anchor":{"row":10,"col":33}}],"primary":0} +{"name":"golf-function-into-class-13","text":"@staticmethod\ndef get_area(length, width):\n return length * width\n\n@staticmethod\ndef get_perimiter(length, width):\n return 2 * (length + width)\n\n@staticmethod\ndef get_volume(length, width, height):\n return length * width * height\n","mode":"normal","cursor":{"row":2,"col":25},"anchor":{"row":1,"col":0},"sels":[{"cursor":{"row":2,"col":25},"anchor":{"row":1,"col":0}},{"cursor":{"row":6,"col":31},"anchor":{"row":5,"col":0}},{"cursor":{"row":10,"col":34},"anchor":{"row":9,"col":0}}],"primary":0} +{"name":"golf-function-into-class-14","text":"@staticmethod\ndef get_area(length, width):\n return length * width\n\n@staticmethod\ndef get_perimiter(length, width):\n return 2 * (length + width)\n\n@staticmethod\ndef get_volume(length, width, height):\n return length * width * height\n","mode":"normal","cursor":{"row":1,"col":18},"anchor":{"row":1,"col":13},"sels":[{"cursor":{"row":1,"col":18},"anchor":{"row":1,"col":13}},{"cursor":{"row":1,"col":25},"anchor":{"row":1,"col":21}},{"cursor":{"row":2,"col":16},"anchor":{"row":2,"col":11}},{"cursor":{"row":2,"col":24},"anchor":{"row":2,"col":20}},{"cursor":{"row":5,"col":23},"anchor":{"row":5,"col":18}},{"cursor":{"row":5,"col":30},"anchor":{"row":5,"col":26}},{"cursor":{"row":6,"col":21},"anchor":{"row":6,"col":16}},{"cursor":{"row":6,"col":29},"anchor":{"row":6,"col":25}},{"cursor":{"row":9,"col":20},"anchor":{"row":9,"col":15}},{"cursor":{"row":9,"col":27},"anchor":{"row":9,"col":23}},{"cursor":{"row":9,"col":35},"anchor":{"row":9,"col":30}},{"cursor":{"row":10,"col":16},"anchor":{"row":10,"col":11}},{"cursor":{"row":10,"col":24},"anchor":{"row":10,"col":20}},{"cursor":{"row":10,"col":33},"anchor":{"row":10,"col":28}}],"primary":0} +{"name":"golf-function-into-class-15","text":"@staticmethod\ndef get_area(length, width):\n return length * width\n\n@staticmethod\ndef get_perimiter(length, width):\n return 2 * (length + width)\n\n@staticmethod\ndef get_volume(length, width, height):\n return length * width * height\n","mode":"normal","cursor":{"row":1,"col":13},"anchor":{"row":1,"col":18},"sels":[{"cursor":{"row":1,"col":13},"anchor":{"row":1,"col":18}},{"cursor":{"row":1,"col":21},"anchor":{"row":1,"col":25}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":16}},{"cursor":{"row":2,"col":20},"anchor":{"row":2,"col":24}},{"cursor":{"row":5,"col":18},"anchor":{"row":5,"col":23}},{"cursor":{"row":5,"col":26},"anchor":{"row":5,"col":30}},{"cursor":{"row":6,"col":16},"anchor":{"row":6,"col":21}},{"cursor":{"row":6,"col":25},"anchor":{"row":6,"col":29}},{"cursor":{"row":9,"col":15},"anchor":{"row":9,"col":20}},{"cursor":{"row":9,"col":23},"anchor":{"row":9,"col":27}},{"cursor":{"row":9,"col":30},"anchor":{"row":9,"col":35}},{"cursor":{"row":10,"col":11},"anchor":{"row":10,"col":16}},{"cursor":{"row":10,"col":20},"anchor":{"row":10,"col":24}},{"cursor":{"row":10,"col":28},"anchor":{"row":10,"col":33}}],"primary":0} +{"name":"golf-function-into-class-16","text":"@staticmethod\ndef get_area(length, width):\n return length * width\n\n@staticmethod\ndef get_perimiter(length, width):\n return 2 * (length + width)\n\n@staticmethod\ndef get_volume(length, width, height):\n return length * width * height\n","mode":"normal","cursor":{"row":1,"col":16},"anchor":{"row":1,"col":16},"sels":[{"cursor":{"row":1,"col":16},"anchor":{"row":1,"col":16}},{"cursor":{"row":1,"col":24},"anchor":{"row":1,"col":24}},{"cursor":{"row":2,"col":14},"anchor":{"row":2,"col":14}},{"cursor":{"row":2,"col":23},"anchor":{"row":2,"col":23}},{"cursor":{"row":5,"col":21},"anchor":{"row":5,"col":21}},{"cursor":{"row":5,"col":29},"anchor":{"row":5,"col":29}},{"cursor":{"row":6,"col":19},"anchor":{"row":6,"col":19}},{"cursor":{"row":6,"col":28},"anchor":{"row":6,"col":28}},{"cursor":{"row":9,"col":18},"anchor":{"row":9,"col":18}},{"cursor":{"row":9,"col":26},"anchor":{"row":9,"col":26}},{"cursor":{"row":9,"col":33},"anchor":{"row":9,"col":33}},{"cursor":{"row":10,"col":14},"anchor":{"row":10,"col":14}},{"cursor":{"row":10,"col":23},"anchor":{"row":10,"col":23}},{"cursor":{"row":10,"col":31},"anchor":{"row":10,"col":31}}],"primary":0} +{"name":"golf-function-into-class-17","text":"@staticmethod\ndef get_area(len, wid):\n return len * wid\n\n@staticmethod\ndef get_perimiter(len, wid):\n return 2 * (len + wid)\n\n@staticmethod\ndef get_volume(len, wid, hei):\n return len * wid * hei\n","mode":"normal","cursor":{"row":1,"col":16},"anchor":{"row":1,"col":16},"sels":[{"cursor":{"row":1,"col":16},"anchor":{"row":1,"col":16}},{"cursor":{"row":1,"col":21},"anchor":{"row":1,"col":21}},{"cursor":{"row":2,"col":14},"anchor":{"row":2,"col":14}},{"cursor":{"row":2,"col":20},"anchor":{"row":2,"col":20}},{"cursor":{"row":5,"col":21},"anchor":{"row":5,"col":21}},{"cursor":{"row":5,"col":26},"anchor":{"row":5,"col":26}},{"cursor":{"row":6,"col":19},"anchor":{"row":6,"col":19}},{"cursor":{"row":6,"col":25},"anchor":{"row":6,"col":25}},{"cursor":{"row":9,"col":18},"anchor":{"row":9,"col":18}},{"cursor":{"row":9,"col":23},"anchor":{"row":9,"col":23}},{"cursor":{"row":9,"col":28},"anchor":{"row":9,"col":28}},{"cursor":{"row":10,"col":14},"anchor":{"row":10,"col":14}},{"cursor":{"row":10,"col":20},"anchor":{"row":10,"col":20}},{"cursor":{"row":10,"col":26},"anchor":{"row":10,"col":26}}],"primary":0} +{"name":"golf-function-into-class-18","text":" @staticmethod\n def get_area(len, wid):\n return len * wid\n\n @staticmethod\n def get_perimiter(len, wid):\n return 2 * (len + wid)\n\n @staticmethod\n def get_volume(len, wid, hei):\n return len * wid * hei\n","mode":"normal","cursor":{"row":10,"col":30},"anchor":{"row":0,"col":4}} +{"name":"golf-function-into-class-19","text":"\n @staticmethod\n def get_area(len, wid):\n return len * wid\n\n @staticmethod\n def get_perimiter(len, wid):\n return 2 * (len + wid)\n\n @staticmethod\n def get_volume(len, wid, hei):\n return len * wid * hei\n","mode":"insert","cursor":{"row":0,"col":0},"anchor":{"row":0,"col":0}} +{"name":"golf-function-into-class","text":"class Calculator:\n @staticmethod\n def get_area(len, wid):\n return len * wid\n\n @staticmethod\n def get_perimiter(len, wid):\n return 2 * (len + wid)\n\n @staticmethod\n def get_volume(len, wid, hei):\n return len * wid * hei\n","mode":"insert","cursor":{"row":0,"col":17},"anchor":{"row":0,"col":17}} +{"name":"golf-function-into-class-from18-18","text":" @staticmethod\n def get_area(len, wid):\n return len * wid\n\n @staticmethod\n def get_perimiter(len, wid):\n return 2 * (len + wid)\n\n @staticmethod\n def get_volume(len, wid, hei):\n return len * wid * hei\n","mode":"normal","cursor":{"row":10,"col":30},"anchor":{"row":0,"col":4}} +{"name":"golf-function-into-class-from18-19","text":"\n @staticmethod\n def get_area(len, wid):\n return len * wid\n\n @staticmethod\n def get_perimiter(len, wid):\n return 2 * (len + wid)\n\n @staticmethod\n def get_volume(len, wid, hei):\n return len * wid * hei\n","mode":"insert","cursor":{"row":0,"col":0},"anchor":{"row":0,"col":0}} +{"name":"golf-function-into-class-from18","text":"class Calculator:\n @staticmethod\n def get_area(len, wid):\n return len * wid\n\n @staticmethod\n def get_perimiter(len, wid):\n return 2 * (len + wid)\n\n @staticmethod\n def get_volume(len, wid, hei):\n return len * wid * hei\n","mode":"insert","cursor":{"row":0,"col":17},"anchor":{"row":0,"col":17}} +{"name":"golf-invert-dictionary-01","text":"var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":4},"anchor":{"row":0,"col":18}} +{"name":"golf-invert-dictionary-02","text":"var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":8},"anchor":{"row":0,"col":4},"sels":[{"cursor":{"row":0,"col":8},"anchor":{"row":0,"col":4}},{"cursor":{"row":0,"col":18},"anchor":{"row":0,"col":13}}],"primary":0} +{"name":"golf-invert-dictionary-03","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":18},"anchor":{"row":0,"col":14},"sels":[{"cursor":{"row":0,"col":9},"anchor":{"row":0,"col":4}},{"cursor":{"row":0,"col":18},"anchor":{"row":0,"col":14}}],"primary":1} +{"name":"golf-invert-dictionary-04","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":18},"anchor":{"row":0,"col":14},"sels":[{"cursor":{"row":0,"col":9},"anchor":{"row":0,"col":4}},{"cursor":{"row":0,"col":18},"anchor":{"row":0,"col":14}}],"primary":1} +{"name":"golf-invert-dictionary-05","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":23},"anchor":{"row":0,"col":0}} +{"name":"golf-invert-dictionary-06","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":1,"col":12},"anchor":{"row":0,"col":23}} +{"name":"golf-invert-dictionary-07","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":1,"col":9},"anchor":{"row":0,"col":23},"sels":[{"cursor":{"row":1,"col":9},"anchor":{"row":0,"col":23}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":11}}],"primary":0} +{"name":"golf-invert-dictionary-08","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":1,"col":8},"anchor":{"row":1,"col":4},"sels":[{"cursor":{"row":1,"col":8},"anchor":{"row":1,"col":4}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":12}}],"primary":0} +{"name":"golf-invert-dictionary-09","text":"var points_to_color = {\n 0 = \"red\",\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":1,"col":12},"anchor":{"row":1,"col":8},"sels":[{"cursor":{"row":1,"col":4},"anchor":{"row":1,"col":4}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":8}}],"primary":1} +{"name":"golf-invert-dictionary-10","text":"var points_to_color = {\n 0 = \"red\",\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":1,"col":12},"anchor":{"row":1,"col":8},"sels":[{"cursor":{"row":1,"col":4},"anchor":{"row":1,"col":4}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":8}}],"primary":1} +{"name":"golf-invert-dictionary","text":"var points_to_color = {\n 0 = \"red\",\n 5 = \"orange\",\n 10 = \"yellow\",\n 15 = \"green\",\n 20 = \"blue\",\n 30 = \"purple\",\n 50 = \"black\",\n}\n","mode":"normal","cursor":{"row":7,"col":15},"anchor":{"row":7,"col":9},"sels":[{"cursor":{"row":7,"col":5},"anchor":{"row":7,"col":4}},{"cursor":{"row":7,"col":15},"anchor":{"row":7,"col":9}}],"primary":1} +{"name":"golf-invert-dictionary-2-01","text":"var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":4},"anchor":{"row":0,"col":18}} +{"name":"golf-invert-dictionary-2-02","text":"var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":8},"anchor":{"row":0,"col":4},"sels":[{"cursor":{"row":0,"col":8},"anchor":{"row":0,"col":4}},{"cursor":{"row":0,"col":18},"anchor":{"row":0,"col":13}}],"primary":0} +{"name":"golf-invert-dictionary-2-03","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":18},"anchor":{"row":0,"col":14},"sels":[{"cursor":{"row":0,"col":9},"anchor":{"row":0,"col":4}},{"cursor":{"row":0,"col":18},"anchor":{"row":0,"col":14}}],"primary":1} +{"name":"golf-invert-dictionary-2-04","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":0,"col":23},"anchor":{"row":0,"col":0}} +{"name":"golf-invert-dictionary-2-05","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":7,"col":17},"anchor":{"row":0,"col":23}} +{"name":"golf-invert-dictionary-2-06","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":1,"col":9},"anchor":{"row":0,"col":23},"sels":[{"cursor":{"row":1,"col":9},"anchor":{"row":0,"col":23}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":11}},{"cursor":{"row":2,"col":12},"anchor":{"row":1,"col":14}},{"cursor":{"row":2,"col":15},"anchor":{"row":2,"col":14}},{"cursor":{"row":3,"col":12},"anchor":{"row":2,"col":17}},{"cursor":{"row":3,"col":16},"anchor":{"row":3,"col":14}},{"cursor":{"row":4,"col":11},"anchor":{"row":3,"col":18}},{"cursor":{"row":4,"col":15},"anchor":{"row":4,"col":13}},{"cursor":{"row":5,"col":10},"anchor":{"row":4,"col":17}},{"cursor":{"row":5,"col":14},"anchor":{"row":5,"col":12}},{"cursor":{"row":6,"col":12},"anchor":{"row":5,"col":16}},{"cursor":{"row":6,"col":16},"anchor":{"row":6,"col":14}},{"cursor":{"row":7,"col":11},"anchor":{"row":6,"col":18}},{"cursor":{"row":7,"col":15},"anchor":{"row":7,"col":13}},{"cursor":{"row":7,"col":17},"anchor":{"row":7,"col":17}}],"primary":0} +{"name":"golf-invert-dictionary-2-07","text":"var points_to_color = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n","mode":"normal","cursor":{"row":1,"col":8},"anchor":{"row":1,"col":4},"sels":[{"cursor":{"row":1,"col":8},"anchor":{"row":1,"col":4}},{"cursor":{"row":1,"col":12},"anchor":{"row":1,"col":12}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":4}},{"cursor":{"row":2,"col":15},"anchor":{"row":2,"col":15}},{"cursor":{"row":3,"col":11},"anchor":{"row":3,"col":4}},{"cursor":{"row":3,"col":16},"anchor":{"row":3,"col":15}},{"cursor":{"row":4,"col":10},"anchor":{"row":4,"col":4}},{"cursor":{"row":4,"col":15},"anchor":{"row":4,"col":14}},{"cursor":{"row":5,"col":9},"anchor":{"row":5,"col":4}},{"cursor":{"row":5,"col":14},"anchor":{"row":5,"col":13}},{"cursor":{"row":6,"col":11},"anchor":{"row":6,"col":4}},{"cursor":{"row":6,"col":16},"anchor":{"row":6,"col":15}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":4}},{"cursor":{"row":7,"col":15},"anchor":{"row":7,"col":14}}],"primary":0} +{"name":"golf-invert-dictionary-2","text":"var points_to_color = {\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n \"red\" = 0,\n}\n","mode":"normal","cursor":{"row":7,"col":8},"anchor":{"row":7,"col":4},"sels":[{"cursor":{"row":1,"col":11},"anchor":{"row":1,"col":4}},{"cursor":{"row":1,"col":15},"anchor":{"row":1,"col":15}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":4}},{"cursor":{"row":2,"col":16},"anchor":{"row":2,"col":15}},{"cursor":{"row":3,"col":10},"anchor":{"row":3,"col":4}},{"cursor":{"row":3,"col":15},"anchor":{"row":3,"col":14}},{"cursor":{"row":4,"col":9},"anchor":{"row":4,"col":4}},{"cursor":{"row":4,"col":14},"anchor":{"row":4,"col":13}},{"cursor":{"row":5,"col":11},"anchor":{"row":5,"col":4}},{"cursor":{"row":5,"col":16},"anchor":{"row":5,"col":15}},{"cursor":{"row":6,"col":10},"anchor":{"row":6,"col":4}},{"cursor":{"row":6,"col":15},"anchor":{"row":6,"col":14}},{"cursor":{"row":7,"col":8},"anchor":{"row":7,"col":4}},{"cursor":{"row":7,"col":12},"anchor":{"row":7,"col":12}}],"primary":12} +{"name":"golf-object-into-array-01","text":"const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n","mode":"normal","cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0}} +{"name":"golf-object-into-array-02","text":"const palette = [\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n];\n","mode":"normal","cursor":{"row":1,"col":0},"anchor":{"row":1,"col":0}} +{"name":"golf-object-into-array-03","text":"const palette = [\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n];\n","mode":"normal","cursor":{"row":3,"col":18},"anchor":{"row":0,"col":17}} +{"name":"golf-object-into-array-04","text":"const palette = [\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n];\n","mode":"normal","cursor":{"row":3,"col":18},"anchor":{"row":0,"col":17}} +{"name":"golf-object-into-array-05","text":"const palette = [\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n];\n","mode":"normal","cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9},"sels":[{"cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":11}},{"cursor":{"row":3,"col":7},"anchor":{"row":3,"col":7}}],"primary":0} +{"name":"golf-object-into-array-06","text":"const palette = [\n apricot, \"#f47868\",\n lightning, \"#ffcd1c\",\n delta, \"6f44f0\",\n];\n","mode":"normal","cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9},"sels":[{"cursor":{"row":1,"col":9},"anchor":{"row":1,"col":9}},{"cursor":{"row":2,"col":11},"anchor":{"row":2,"col":11}},{"cursor":{"row":3,"col":7},"anchor":{"row":3,"col":7}}],"primary":0} +{"name":"golf-object-into-array-07","text":"const palette = [\n apricot, \"#f47868\",\n lightning, \"#ffcd1c\",\n delta, \"6f44f0\",\n];\n","mode":"normal","cursor":{"row":1,"col":8},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":8},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":10},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":6},"anchor":{"row":3,"col":2}}],"primary":0} +{"name":"golf-object-into-array-08","text":"const palette = [\n \"apricot\", \"#f47868\",\n \"lightning\", \"#ffcd1c\",\n \"delta\", \"6f44f0\",\n];\n","mode":"normal","cursor":{"row":1,"col":10},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":10},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":12},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":8},"anchor":{"row":3,"col":2}}],"primary":0} +{"name":"golf-object-into-array-09","text":"const palette = [\n \"apricot\", \"#f47868\",\n \"lightning\", \"#ffcd1c\",\n \"delta\", \"6f44f0\",\n];\n","mode":"select","cursor":{"row":1,"col":21},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":21},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":23},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":18},"anchor":{"row":3,"col":2}}],"primary":0} +{"name":"golf-object-into-array","text":"const palette = [\n [\"apricot\", \"#f47868\"],\n [\"lightning\", \"#ffcd1c\"],\n [\"delta\", \"6f44f0\"],\n];\n","mode":"normal","cursor":{"row":1,"col":23},"anchor":{"row":1,"col":2},"sels":[{"cursor":{"row":1,"col":23},"anchor":{"row":1,"col":2}},{"cursor":{"row":2,"col":25},"anchor":{"row":2,"col":2}},{"cursor":{"row":3,"col":20},"anchor":{"row":3,"col":2}}],"primary":0} +{"name":"golf-reverse-golf-example-01","text":"# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"normal","cursor":{"row":0,"col":2},"anchor":{"row":0,"col":11}} +{"name":"golf-reverse-golf-example-02","text":"# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"normal","cursor":{"row":0,"col":2},"anchor":{"row":0,"col":11}} +{"name":"golf-reverse-golf-example-03","text":"# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"normal","cursor":{"row":0,"col":16},"anchor":{"row":0,"col":24}} +{"name":"golf-reverse-golf-example-04","text":"# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"normal","cursor":{"row":0,"col":16},"anchor":{"row":0,"col":24}} +{"name":"golf-reverse-golf-example-05","text":"# snake_case to snake_case\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"normal","cursor":{"row":0,"col":16},"anchor":{"row":0,"col":25}} +{"name":"golf-reverse-golf-example-06","text":"# snake_case to snake_case\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"select","cursor":{"row":0,"col":16},"anchor":{"row":0,"col":25}} +{"name":"golf-reverse-golf-example-07","text":"# snake_case to snake_case\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"select","cursor":{"row":0,"col":2},"anchor":{"row":0,"col":11},"sels":[{"cursor":{"row":0,"col":2},"anchor":{"row":0,"col":11}},{"cursor":{"row":0,"col":16},"anchor":{"row":0,"col":25}}],"primary":0} +{"name":"golf-reverse-golf-example-08","text":"# snake_case to snake_case\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"select","cursor":{"row":2,"col":24},"anchor":{"row":2,"col":32},"sels":[{"cursor":{"row":0,"col":2},"anchor":{"row":0,"col":11}},{"cursor":{"row":0,"col":16},"anchor":{"row":0,"col":25}},{"cursor":{"row":2,"col":24},"anchor":{"row":2,"col":32}}],"primary":2} +{"name":"golf-reverse-golf-example-09","text":"# camelCase to snake_case\n\nRename all fields to be snake_case.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"select","cursor":{"row":0,"col":2},"anchor":{"row":0,"col":10},"sels":[{"cursor":{"row":0,"col":2},"anchor":{"row":0,"col":10}},{"cursor":{"row":0,"col":15},"anchor":{"row":0,"col":24}},{"cursor":{"row":2,"col":24},"anchor":{"row":2,"col":33}}],"primary":0} +{"name":"golf-reverse-golf-example-10","text":"# camelCase to snake_case\n\nRename all fields to be snake_case.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"select","cursor":{"row":14,"col":3},"anchor":{"row":0,"col":0}} +{"name":"golf-reverse-golf-example-11","text":"# camelCase to snake_case\n\nRename all fields to be snake_case.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"select","cursor":{"row":6,"col":3},"anchor":{"row":6,"col":0},"sels":[{"cursor":{"row":6,"col":3},"anchor":{"row":6,"col":0}},{"cursor":{"row":12,"col":3},"anchor":{"row":12,"col":0}}],"primary":0} +{"name":"golf-reverse-golf-example-12","text":"# camelCase to snake_case\n\nRename all fields to be snake_case.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n","mode":"select","cursor":{"row":7,"col":41},"anchor":{"row":6,"col":0},"sels":[{"cursor":{"row":7,"col":41},"anchor":{"row":6,"col":0}},{"cursor":{"row":13,"col":39},"anchor":{"row":12,"col":0}}],"primary":0} +{"name":"golf-reverse-golf-example","text":"# camelCase to snake_case\n\nRename all fields to be snake_case.\n\n## Before\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n\n## After\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n","mode":"select","cursor":{"row":13,"col":41},"anchor":{"row":12,"col":0},"sels":[{"cursor":{"row":7,"col":39},"anchor":{"row":6,"col":0}},{"cursor":{"row":13,"col":41},"anchor":{"row":12,"col":0}}],"primary":1} +{"name":"golf-snake-case-to-camel-case-01","text":"const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n","mode":"normal","cursor":{"row":13,"col":2},"anchor":{"row":0,"col":0}} +{"name":"golf-snake-case-to-camel-case-02","text":"const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n","mode":"normal","cursor":{"row":0,"col":10},"anchor":{"row":0,"col":10},"sels":[{"cursor":{"row":0,"col":10},"anchor":{"row":0,"col":10}},{"cursor":{"row":1,"col":7},"anchor":{"row":1,"col":7}},{"cursor":{"row":2,"col":6},"anchor":{"row":2,"col":6}},{"cursor":{"row":3,"col":7},"anchor":{"row":3,"col":7}},{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":4,"col":22},"anchor":{"row":4,"col":22}},{"cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":10}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":9,"col":13},"anchor":{"row":9,"col":13}},{"cursor":{"row":10,"col":7},"anchor":{"row":10,"col":7}},{"cursor":{"row":11,"col":8},"anchor":{"row":11,"col":8}}],"primary":0} +{"name":"golf-snake-case-to-camel-case-03","text":"const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n","mode":"normal","cursor":{"row":4,"col":22},"anchor":{"row":4,"col":22},"sels":[{"cursor":{"row":0,"col":10},"anchor":{"row":0,"col":10}},{"cursor":{"row":1,"col":7},"anchor":{"row":1,"col":7}},{"cursor":{"row":2,"col":6},"anchor":{"row":2,"col":6}},{"cursor":{"row":3,"col":7},"anchor":{"row":3,"col":7}},{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":4,"col":22},"anchor":{"row":4,"col":22}},{"cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":10}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":9,"col":13},"anchor":{"row":9,"col":13}},{"cursor":{"row":10,"col":7},"anchor":{"row":10,"col":7}},{"cursor":{"row":11,"col":8},"anchor":{"row":11,"col":8}}],"primary":5} +{"name":"golf-snake-case-to-camel-case-04","text":"const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n","mode":"normal","cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7},"sels":[{"cursor":{"row":0,"col":10},"anchor":{"row":0,"col":10}},{"cursor":{"row":1,"col":7},"anchor":{"row":1,"col":7}},{"cursor":{"row":2,"col":6},"anchor":{"row":2,"col":6}},{"cursor":{"row":3,"col":7},"anchor":{"row":3,"col":7}},{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":10}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":9,"col":13},"anchor":{"row":9,"col":13}},{"cursor":{"row":10,"col":7},"anchor":{"row":10,"col":7}},{"cursor":{"row":11,"col":8},"anchor":{"row":11,"col":8}}],"primary":5} +{"name":"golf-snake-case-to-camel-case-05","text":"const userprofile = {\n firstname: \"John\",\n lastname: \"Doe\",\n birthdate: \"1990-05-15\",\n emailaddress: \"john_doe@example.com\",\n phonenumber: \"555-123-4567\",\n mailingaddress: {\n streetname: \"Main Street\",\n housenumber: 123,\n apartmentunit: \"4B\",\n zipcode: \"10001\",\n cityname: \"New York\",\n },\n};\n","mode":"normal","cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7},"sels":[{"cursor":{"row":0,"col":10},"anchor":{"row":0,"col":10}},{"cursor":{"row":1,"col":7},"anchor":{"row":1,"col":7}},{"cursor":{"row":2,"col":6},"anchor":{"row":2,"col":6}},{"cursor":{"row":3,"col":7},"anchor":{"row":3,"col":7}},{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":10}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":9,"col":13},"anchor":{"row":9,"col":13}},{"cursor":{"row":10,"col":7},"anchor":{"row":10,"col":7}},{"cursor":{"row":11,"col":8},"anchor":{"row":11,"col":8}}],"primary":5} +{"name":"golf-snake-case-to-camel-case","text":"const userProfile = {\n firstName: \"John\",\n lastName: \"Doe\",\n birthDate: \"1990-05-15\",\n emailAddress: \"john_doe@example.com\",\n phoneNumber: \"555-123-4567\",\n mailingAddress: {\n streetName: \"Main Street\",\n houseNumber: 123,\n apartmentUnit: \"4B\",\n zipCode: \"10001\",\n cityName: \"New York\",\n },\n};\n","mode":"normal","cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7},"sels":[{"cursor":{"row":0,"col":10},"anchor":{"row":0,"col":10}},{"cursor":{"row":1,"col":7},"anchor":{"row":1,"col":7}},{"cursor":{"row":2,"col":6},"anchor":{"row":2,"col":6}},{"cursor":{"row":3,"col":7},"anchor":{"row":3,"col":7}},{"cursor":{"row":4,"col":7},"anchor":{"row":4,"col":7}},{"cursor":{"row":5,"col":7},"anchor":{"row":5,"col":7}},{"cursor":{"row":6,"col":9},"anchor":{"row":6,"col":9}},{"cursor":{"row":7,"col":10},"anchor":{"row":7,"col":10}},{"cursor":{"row":8,"col":9},"anchor":{"row":8,"col":9}},{"cursor":{"row":9,"col":13},"anchor":{"row":9,"col":13}},{"cursor":{"row":10,"col":7},"anchor":{"row":10,"col":7}},{"cursor":{"row":11,"col":8},"anchor":{"row":11,"col":8}}],"primary":5} +{"name":"golf-text-into-array-01","text":"Hello\nThis\nIs\nHelix\n","mode":"normal","cursor":{"row":3,"col":5},"anchor":{"row":0,"col":0}} +{"name":"golf-text-into-array-02","text":"Hello\nThis\nIs\nHelix\n","mode":"normal","cursor":{"row":0,"col":4},"anchor":{"row":0,"col":0},"sels":[{"cursor":{"row":0,"col":4},"anchor":{"row":0,"col":0}},{"cursor":{"row":1,"col":3},"anchor":{"row":1,"col":0}},{"cursor":{"row":2,"col":1},"anchor":{"row":2,"col":0}},{"cursor":{"row":3,"col":4},"anchor":{"row":3,"col":0}}],"primary":0} +{"name":"golf-text-into-array-03","text":"\"Hello\"\n\"This\"\n\"Is\"\n\"Helix\"\n","mode":"normal","cursor":{"row":0,"col":6},"anchor":{"row":0,"col":0},"sels":[{"cursor":{"row":0,"col":6},"anchor":{"row":0,"col":0}},{"cursor":{"row":1,"col":5},"anchor":{"row":1,"col":0}},{"cursor":{"row":2,"col":3},"anchor":{"row":2,"col":0}},{"cursor":{"row":3,"col":6},"anchor":{"row":3,"col":0}}],"primary":0} +{"name":"golf-text-into-array-04","text":"\"Hello\", \"This\", \"Is\", \"Helix\"","mode":"insert","cursor":{"row":0,"col":8},"anchor":{"row":0,"col":8},"sels":[{"cursor":{"row":0,"col":8},"anchor":{"row":0,"col":8}},{"cursor":{"row":0,"col":16},"anchor":{"row":0,"col":16}},{"cursor":{"row":0,"col":22},"anchor":{"row":0,"col":22}}],"primary":0} +{"name":"golf-text-into-array","text":"[\"Hello\", \"This\", \"Is\", \"Helix\"]","mode":"normal","cursor":{"row":0,"col":31},"anchor":{"row":0,"col":0}} diff --git a/test/hxcases/golf.jsonl b/test/hxcases/golf.jsonl new file mode 100644 index 00000000..f327eaf1 --- /dev/null +++ b/test/hxcases/golf.jsonl @@ -0,0 +1,124 @@ +{"name": "golf-csv-to-sql-01", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%"} +{"name": "golf-csv-to-sql-02", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%"} +{"name": "golf-csv-to-sql-03", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yy"} +{"name": "golf-csv-to-sql-04", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\d"} +{"name": "golf-csv-to-sql-05", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\dd"} +{"name": "golf-csv-to-sql-06", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhh"} +{"name": "golf-csv-to-sql-07", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhb"} +{"name": "golf-csv-to-sql-08", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms`"} +{"name": "golf-csv-to-sql-09", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``"} +{"name": "golf-csv-to-sql-10", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_"} +{"name": "golf-csv-to-sql-11", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms("} +{"name": "golf-csv-to-sql-12", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(I"} +{"name": "golf-csv-to-sql-13", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `database"} +{"name": "golf-csv-to-sql-14", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `database"} +{"name": "golf-csv-to-sql-15", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`table"} +{"name": "golf-csv-to-sql-16", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela"} +{"name": "golf-csv-to-sql-17", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela "} +{"name": "golf-csv-to-sql-18", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES ("} +{"name": "golf-csv-to-sql-19", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES ("} +{"name": "golf-csv-to-sql-20", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES (\"yP"} +{"name": "golf-csv-to-sql-21", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES (\"yPS,"} +{"name": "golf-csv-to-sql-22", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES (\"yPS,ms'"} +{"name": "golf-csv-to-sql-23", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES (\"yPS,ms'A;"} +{"name": "golf-csv-to-sql-24", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES (\"yPS,ms'A;Fl"} +{"name": "golf-csv-to-sql-25", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES (\"yPS,ms'A;Fl;"} +{"name": "golf-csv-to-sql", "pane": "file", "text": "id 1,Item 1,cost 1,location 1\nid 2,Item 2,cost 2,location 2\nid 10,Item 10,cost 10,location 10\n", "keys": "%\"yys\\ddhhbms``x_ms(IINSERT INTO `databasea.`tablela AVALUES (\"yPS,ms'A;Fl;~"} +{"name": "golf-enumerate-and-align-01", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%"} +{"name": "golf-enumerate-and-align-02", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s"} +{"name": "golf-enumerate-and-align-03", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{"} +{"name": "golf-enumerate-and-align-04", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a "} +{"name": "golf-enumerate-and-align-05", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a rank: "} +{"name": "golf-enumerate-and-align-06", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a rank: #"} +{"name": "golf-enumerate-and-align-07", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a rank: #,"} +{"name": "golf-enumerate-and-align-08", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a rank: #,"} +{"name": "golf-enumerate-and-align-09", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a rank: #,%s"} +{"name": "golf-enumerate-and-align-10", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a rank: #,%s |\\d+"} +{"name": "golf-enumerate-and-align", "pane": "file", "text": "[\n { word: \"a\", count: 2565 },\n { word: \"and\", count: 1777 },\n { word: \"of\", count: 1331 },\n { word: \"that\", count: 1263 },\n { word: \"to\", count: 1030 },\n { word: \"in\", count: 1027 },\n { word: \"it\", count: 754 },\n { word: \"as\", count: 730 },\n { word: \"was\", count: 687 },\n { word: \"you\", count: 652 },\n { word: \"for\", count: 630 },\n];\n", "keys": "%s\\{a rank: #,%s |\\d+&"} +{"name": "golf-enumerate-and-align-from09-09", "pane": "file", "text": "[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n", "keys": "%s"} +{"name": "golf-enumerate-and-align-from09-10", "pane": "file", "text": "[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n", "keys": "%s |\\d+"} +{"name": "golf-enumerate-and-align-from09", "pane": "file", "text": "[\n { rank: 1, word: \"a\", count: 2565 },\n { rank: 2, word: \"and\", count: 1777 },\n { rank: 3, word: \"of\", count: 1331 },\n { rank: 4, word: \"that\", count: 1263 },\n { rank: 5, word: \"to\", count: 1030 },\n { rank: 6, word: \"in\", count: 1027 },\n { rank: 7, word: \"it\", count: 754 },\n { rank: 8, word: \"as\", count: 730 },\n { rank: 9, word: \"was\", count: 687 },\n { rank: 10, word: \"you\", count: 652 },\n { rank: 11, word: \"for\", count: 630 },\n];\n", "keys": "%s |\\d+&"} +{"name": "golf-export-from-mod-01", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%"} +{"name": "golf-export-from-mod-02", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%yp"} +{"name": "golf-export-from-mod-03", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%yp["} +{"name": "golf-export-from-mod-04", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%yp[gse"} +{"name": "golf-export-from-mod-05", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%yp[gsecpub use"} +{"name": "golf-export-from-mod-06", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%yp[gsecpub useley"} +{"name": "golf-export-from-mod-07", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%yp[gsecpub useleyp"} +{"name": "golf-export-from-mod", "pane": "file", "text": "mod generate_demos;\nmod mdbook_preprocessor;\nmod validate;\n", "keys": "%yp[gsecpub useleypi::"} +{"name": "golf-function-into-class-01", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%"} +{"name": "golf-function-into-class-02", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculate"} +{"name": "golf-function-into-class-03", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecget"} +{"name": "golf-function-into-class-04", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecget"} +{"name": "golf-function-into-class-05", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethod"} +{"name": "golf-function-into-class-06", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethod"} +{"name": "golf-function-into-class-07", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjj"} +{"name": "golf-function-into-class-08", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvgl"} +{"name": "golf-function-into-class-09", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvgly"} +{"name": "golf-function-into-class-10", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyx"} +{"name": "golf-function-into-class-11", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxb"} +{"name": "golf-function-into-class-12", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbR"} +{"name": "golf-function-into-class-13", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxx"} +{"name": "golf-function-into-class-14", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxxslength|width|height"} +{"name": "golf-function-into-class-15", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxxslength|width|heightb"} +{"name": "golf-function-into-class-16", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxxslength|width|heightblll"} +{"name": "golf-function-into-class-17", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxxslength|width|heightbllled"} +{"name": "golf-function-into-class-18", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxxslength|width|heightbllled%"} +{"name": "golf-function-into-class-19", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxxslength|width|heightbllled%O"} +{"name": "golf-function-into-class", "pane": "file", "text": "def calculate_area(length, width):\n result = length * width\n return result\n\ndef calculate_perimiter(length, width):\n result = 2 * (length + width)\n return result\n\ndef calculate_volume(length, width, height):\n result = length * width * height\n return result\n", "keys": "%scalculatecgetO@staticmethodjjvglyxxbRkxxslength|width|heightbllled%Oclass Calculator:"} +{"name": "golf-function-into-class-from18-18", "pane": "file", "text": "@staticmethod\ndef get_area(len, wid):\n return len * wid\n\n@staticmethod\ndef get_perimiter(len, wid):\n return 2 * (len + wid)\n\n@staticmethod\ndef get_volume(len, wid, hei):\n return len * wid * hei\n", "keys": "%"} +{"name": "golf-function-into-class-from18-19", "pane": "file", "text": "@staticmethod\ndef get_area(len, wid):\n return len * wid\n\n@staticmethod\ndef get_perimiter(len, wid):\n return 2 * (len + wid)\n\n@staticmethod\ndef get_volume(len, wid, hei):\n return len * wid * hei\n", "keys": "%O"} +{"name": "golf-function-into-class-from18", "pane": "file", "text": "@staticmethod\ndef get_area(len, wid):\n return len * wid\n\n@staticmethod\ndef get_perimiter(len, wid):\n return 2 * (len + wid)\n\n@staticmethod\ndef get_volume(len, wid, hei):\n return len * wid * hei\n", "keys": "%Oclass Calculator:"} +{"name": "golf-invert-dictionary-01", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "web"} +{"name": "golf-invert-dictionary-02", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_"} +{"name": "golf-invert-dictionary-03", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_"} +{"name": "golf-invert-dictionary-04", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Q"} +{"name": "golf-invert-dictionary-05", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Qx"} +{"name": "golf-invert-dictionary-06", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Qxt,"} +{"name": "golf-invert-dictionary-07", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Qxt,S="} +{"name": "golf-invert-dictionary-08", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Qxt,S=_"} +{"name": "golf-invert-dictionary-09", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Qxt,S=_"} +{"name": "golf-invert-dictionary-10", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Qxt,S=_Q"} +{"name": "golf-invert-dictionary", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_Qxt,S=_Q6q"} +{"name": "golf-invert-dictionary-2-01", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "web"} +{"name": "golf-invert-dictionary-2-02", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_"} +{"name": "golf-invert-dictionary-2-03", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_"} +{"name": "golf-invert-dictionary-2-04", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_x"} +{"name": "golf-invert-dictionary-2-05", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_xt}"} +{"name": "golf-invert-dictionary-2-06", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_xt}S,|="} +{"name": "golf-invert-dictionary-2-07", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_xt}S,|=_"} +{"name": "golf-invert-dictionary-2", "pane": "file", "text": "var color_to_points = {\n \"red\" = 0,\n \"orange\" = 5,\n \"yellow\" = 10,\n \"green\" = 15,\n \"blue\" = 20,\n \"purple\" = 30,\n \"black\" = 50,\n}\n", "keys": "webS_to_xt}S,|=_2"} +{"name": "golf-object-into-array-01", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "j"} +{"name": "golf-object-into-array-02", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{["} +{"name": "golf-object-into-array-03", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi["} +{"name": "golf-object-into-array-04", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi[s"} +{"name": "golf-object-into-array-05", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi[s:"} +{"name": "golf-object-into-array-06", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi[s:r,"} +{"name": "golf-object-into-array-07", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi[s:r,be"} +{"name": "golf-object-into-array-08", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi[s:r,bems\""} +{"name": "golf-object-into-array-09", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi[s:r,bems\"vt,"} +{"name": "golf-object-into-array", "pane": "file", "text": "const palette = {\n apricot: \"#f47868\",\n lightning: \"#ffcd1c\",\n delta: \"6f44f0\",\n};\n", "keys": "jmr{[mi[s:r,bems\"vt,ms["} +{"name": "golf-reverse-golf-example-01", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "eb"} +{"name": "golf-reverse-golf-example-02", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "eby"} +{"name": "golf-reverse-golf-example-03", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb"} +{"name": "golf-reverse-golf-example-04", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*"} +{"name": "golf-reverse-golf-example-05", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*R"} +{"name": "golf-reverse-golf-example-06", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv"} +{"name": "golf-reverse-golf-example-07", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv\"\"N"} +{"name": "golf-reverse-golf-example-08", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv\"\"Nn"} +{"name": "golf-reverse-golf-example-09", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv\"\"Nn"} +{"name": "golf-reverse-golf-example-10", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv\"\"Nn%"} +{"name": "golf-reverse-golf-example-11", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv\"\"Nn%s`+j"} +{"name": "golf-reverse-golf-example-12", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv\"\"Nn%s`+jf;"} +{"name": "golf-reverse-golf-example", "pane": "file", "text": "# snake_case to camelCase\n\nRename all fields to be camelCase.\n\n## Before\n\n```js\nconst user_profile = {first_name: \"John\"};\n```\n\n## After\n\n```js\nconst userProfile = {firstName: \"John\"};\n```\n", "keys": "ebyxb*Rv\"\"Nn%s`+jf;"} +{"name": "golf-snake-case-to-camel-case-01", "pane": "file", "text": "const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n", "keys": "%"} +{"name": "golf-snake-case-to-camel-case-02", "pane": "file", "text": "const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n", "keys": "%s_"} +{"name": "golf-snake-case-to-camel-case-03", "pane": "file", "text": "const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n", "keys": "%s_5)"} +{"name": "golf-snake-case-to-camel-case-04", "pane": "file", "text": "const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n", "keys": "%s_5)"} +{"name": "golf-snake-case-to-camel-case-05", "pane": "file", "text": "const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n", "keys": "%s_5)d"} +{"name": "golf-snake-case-to-camel-case", "pane": "file", "text": "const user_profile = {\n first_name: \"John\",\n last_name: \"Doe\",\n birth_date: \"1990-05-15\",\n email_address: \"john_doe@example.com\",\n phone_number: \"555-123-4567\",\n mailing_address: {\n street_name: \"Main Street\",\n house_number: 123,\n apartment_unit: \"4B\",\n zip_code: \"10001\",\n city_name: \"New York\",\n },\n};\n", "keys": "%s_5)d~"} +{"name": "golf-text-into-array-01", "pane": "file", "text": "Hello\nThis\nIs\nHelix\n", "keys": "%"} +{"name": "golf-text-into-array-02", "pane": "file", "text": "Hello\nThis\nIs\nHelix\n", "keys": "%"} +{"name": "golf-text-into-array-03", "pane": "file", "text": "Hello\nThis\nIs\nHelix\n", "keys": "%ms\""} +{"name": "golf-text-into-array-04", "pane": "file", "text": "Hello\nThis\nIs\nHelix\n", "keys": "%ms\"i,"} +{"name": "golf-text-into-array", "pane": "file", "text": "Hello\nThis\nIs\nHelix\n", "keys": "%ms\"i,xms["} -- cgit v1.3 From 68b0fe7600987587ed0c27cf38a3fca8216c45b4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 15:40:03 -0300 Subject: docs/selections.md says how normal mode holds its selections The primary and the others, cells against helix's gaps, how setRanges normalizes, which commands replay per range and which make one edit, and what undo, the register and repeat do with several ranges, with the places helix differs listed at the end. Co-Authored-By: Claude Opus 5.5 --- README.md | 1 + docs/selections.md | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 docs/selections.md (limited to 'README.md') diff --git a/README.md b/README.md index c82bd310..3e7a96f2 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ sketch; `docs/design.pdf` is a retained rendering/search fixture and may lag it. | `docs/detached.md` | one core, many frontends, over a unix socket | | `docs/config.md` | build options and runtime configuration | | `docs/tags.md` | editable workspace, column and pane tags; filename drafts | +| `docs/selections.md` | the normal-mode selection model and how it differs from helix's | | `docs/fs.md` | default 9P service, Look resolution, and named mounts | | `docs/lsp.md` | in-process ZLS and external language servers | | `docs/lsp-evaluation.md` | why that backend, measured against the alternatives | diff --git a/docs/selections.md b/docs/selections.md new file mode 100644 index 00000000..5b992cc4 --- /dev/null +++ b/docs/selections.md @@ -0,0 +1,103 @@ +# Selections + +How normal mode holds and changes its selections, and where that differs from +helix's `Selection` (a list of ranges over gap offsets, with a primary index). +Key-by-key behaviour is in docs/helix-keys.md; this is the model underneath. + +## What a selection is + +Every `Text` (src/Text.zig) has its own: a pane's body, its tag, a prompt's +answer, a column's or the workspace's tag. A selection is one primary range +plus up to 63 others. + +- The PRIMARY is where the cursor always was: `cur_row`/`cur_col` is the + head, `vsel.row`/`vsel.col` the anchor while `vsel.active`, and a bare + cursor (inactive `vsel`) is the one-character range under it. `msel` is + the older whole-line form (`r0`..`r1`), kept for search-result highlights. +- The others are `sels[0..nsel]`, each a `SelRange` of head and anchor plus + its own `j`/`k` goal column, in document order. The primary is not in the + list; `Text.ranges` slots it in and returns its index. +- Ends are CELLS, the characters a block cursor sits on, where helix's are + gaps between characters. `Text.cellRange`, `cellOffRange` and `rangeCells` + convert. A range covers at least one character, as in helix (min width 1), + so there are no empty ranges. +- `vsel.explicit` says the selection was made on purpose (`v`, `x`, `%`, + `s`, `n`/`N`, ...) rather than left behind by a motion. Only pardes reads + it: the look (Enter) and execute (Tab) chords act on explicit selections + and on the word under the cursor otherwise. +- `select` is `v` extend mode. `append_at` remembers where an `a` began, so + Esc can give back the range it appended over. + +`Text.setRanges` is the one writer of a whole selection: it sorts by start, +merges ranges that overlap or share a start (helix `normalize`), follows the +primary through the merges, and keeps the first 64. `setRange` writes one +range and drops the others. + +## Making, splitting, merging, rotating, removing + +- Made several by `C`/`Alt-C` (copy to the next/previous line), `s` (every + match inside each range), `S` (the pieces between matches), `Alt-s` (one + per line), `o`/`O`, and `Alt-J` (the spaces a join put in). `s`/`S` + re-run on every keystroke from the selection the prompt opened on + (`Pane.sel_snap`); Esc is that snapshot restored. +- `Alt-minus` merges all into one, `Alt-_` the consecutive ones, `_` trims + whitespace (dropping all-blank ranges). +- `)`/`(` rotate which range is primary; `Alt-)`/`Alt-(` rotate the TEXT + between ranges, the primary moving with its text. +- `,` keeps only the primary, `Alt-,` removes it (the next range takes over). +- After `s`, `S` and `Alt-s` the primary is the first range, which is + helix's behaviour (its own TODO), not a choice. + +## How a command reaches every range + +A parsed action has a scope (`modal.Normal.Action.scope`). + +- `per_selection` (motions, `d`, `c`, `y`, `p`, `r`, `~`, `>`, `ms`, ...): + `normal.replaySels` runs the ONE-range handler once per range, last range + first, each pass seeing a single selection. A pass's result is stored as + distances from the END of the text, which an edit at an earlier range + cannot move; `setRanges` then puts them back together. The mode, prefix + and select state that survive are the primary's pass. Insert-mode keys are + replayed the same way. +- `once` (the `multi` family, `s`/`S`, `J`/`Alt-J`, `Alt-(`/`Alt-)`, `&`, + `Ctrl-c`, undo/redo, builtins, search): one function takes `Text.ranges`, + makes one edit and hands the mapped ranges to `setRanges`, the way a helix + command builds one transaction. +- Anything that reaches outside the text (a builtin, a language query, a + look) runs once from the primary and drops back to one cursor + (`normal.multiOnce`). + +## Undo, registers, repeat + +- One keystroke is one undo step however many ranges it edited: only the + first replay pass records (`pushUndo`). +- An undo snapshot (`File.Snapshot`) holds the content and the PRIMARY + range. Undo puts the primary back and leaves the other ranges where they + were; helix restores the whole selection of that revision. +- There is ONE register, `Pardes.yank`, written by `y`, `d` and `c` and read + by `p`, `P` and `R`. A yank at several ranges joins their texts with + newlines into it, and a paste puts that whole value at every range. +- `Alt-.` repeats the last `f`/`t`/`F`/`T`. There is no `.` and there are no + macros. + +## Where it differs from helix + +- Registers: helix keeps one value PER RANGE and pastes value `i` at range + `i`; it has named registers (`"a`), special ones (`#` range indices, + `.` the selection, `/` the search, `_` the black hole) and inserts a + register in insert mode with `Ctrl-r`. None exist here (waiver + `msel-yank-paste`). +- Insert mode: helix maps every range through each keystroke's edit, so a + range an `i`/`a` started from stretches over what is typed and keeps its + anchor. Here only the cursor cells move, and after Esc only the primary's + `append_at` span comes back (waivers `wiX-edit-drops-sel`, `msel-append`). +- Direction of a one-character range: both of its cells are the same cell, + so it has none. helix can flip one (`Alt-;`) and the commands that read + the head (`&`, the next extend) see the difference. +- Count: at most 64 ranges; matches past that are dropped silently. +- `n`/`N` walk the look ring (acme), not regex search hits, and there is no + `*`; helix-golf's `*`, `""N` and `n` do not apply. +- `s`/`S` match as sam does (docs/helix-keys.md, "Regex selection"): each + line is its own haystack, so `^`/`$` hold at every line and a class like + `\s` does not reach the newline unless the pattern names `\n`. +- Undo restores only the primary (above). -- cgit v1.3 From 64b6a0dbdaab4b314ccbce667709d71a8561daf0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 00:01:04 -0300 Subject: The tree serves the layout: /layout, /tag and /col//tag A script could not see where the panes sit or edit the tags a person clicks in. /layout lists each column, its index, x and width in cells, current or not, empty or full, and its panes' serials, then the active column; /tag is the workspace tag and /col//tag a column's, read and written as a pane tag is (one line: a newline written in is a space, and a truncating write drops the one ending it); /index's lines end with the pane's column; the log says newcol and delcol . acme serves no column files, and the docs say so. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 4 +- README.md | 5 +- docs/fs.md | 16 +++- src/fs-help.txt | 5 +- src/fs.zig | 5 ++ src/layout.zig | 11 ++- src/ninep/cols.zig | 163 ++++++++++++++++++++++++++++++++++++++ src/ninep/events.zig | 4 + src/ninep/pane.zig | 15 +++- src/ninep/tree.zig | 111 +++++++++++++++++++++----- test/selfmount.py | 6 +- 11 files changed, 315 insertions(+), 30 deletions(-) create mode 100644 src/ninep/cols.zig (limited to 'README.md') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index b16039d2..a5447991 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -52,7 +52,7 @@ match this document, that session predates the change; restart it. ``` $m/README the served guide, worth reading first -$m/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name +$m/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name, column $m/status pid, version, panes $m/look write a line = a right click on it at the active pane (file:/re/, file:#n, :/re/ select by address, as acme's look, from the file's dot: file:0/re/ for the @@ -82,6 +82,8 @@ $m/ctl the settings, one a line as a write takes them; write a setting or a pane's builtins (Del, Save f, Collapse, which folds that pane, and the column word Delcol, which closes that pane's column) go to $m/pane//ctl $m/commands every builtin: `Word`, `Word arg`, then `root` or `pane` (which ctl takes it) +$m/layout one line per column: index x width current|notcurrent empty|full serials...; active +$m/tag the workspace tag (> replaces, >> appends, one line); $m/col//tag a column's, n from 0 $m/pane/new open it to make a pane (a scratch named /+New), read names it; it goes in the ACTIVE column (the one last typed or clicked in, or Newcol's), filling it if empty, else taking the bottom half of its last pane (ctl `Placement pardes`: the old rules); diff --git a/README.md b/README.md index 267b5ca7..e487bf9c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,10 @@ to refresh. Mini snapshots survive Dump/Restore without rereading the source. On Linux, `Tty9p` (`SPC n 9`) opens a terminal with the session's 9P tree mounted through kernel v9fs. It asks sudo in that pane, then starts your shell as your normal user. Access the tree through `$PARDES_MOUNT`. -See [mounted terminals](docs/v9fs.md). +See [mounted terminals](docs/v9fs.md). Beyond acme's per-window files the tree +serves the layout: `/layout` lists the columns, their places and panes, and +`/tag` and `/col//tag` are the workspace and column tags, editable like a +window's ([the tree](docs/fs.md#the-served-tree)). ## Requirements diff --git a/docs/fs.md b/docs/fs.md index 89a513e8..5f382e7e 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -92,7 +92,7 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. ``` /README this guide, also src/fs-help.txt -/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name +/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name, column /status pid, version and pane count /look write a line: a right click on it at the active pane; read: the serials the last look, exec or ctl write touched (made, else acted at) @@ -105,6 +105,10 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. /focus the serial of the pane with the keyboard; write a serial to give it the keyboard /ctl the settings, one a line as a write takes them; write a setting or a session builtin /commands every builtin: word, `arg` if it takes one, `root` or `pane` (the ctl that takes it), a setting's values +/layout one line per column: index x width current|notcurrent empty|full serials...; + then active (- when no column has the keyboard) +/tag the workspace tag; > replaces it, >> appends, one line +/col//tag column n's tag, the same way; columns count from 0, left to right /pane/new open it to make a pane; the read answers that pane's serial /pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll errors event look exec, plus pty/{ctl,status,data} on terminals @@ -112,6 +116,16 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. /src/ the editor's embedded sources, only when built with -Dembed-sources=true ``` +`/layout`, `/tag` and `/col` go past acme, which serves no column files -- +its columns are only where a window sits. They are here so a script can see +where the panes are (`/index`'s last word is each one's column, the same +index) and edit the tags a person clicks in: a column tag is one line, a +newline written into it a space, and a truncating write (`echo Make > +col/0/tag`) clears it and drops the newline that ends it, as a pane tag's +does. A column is named by its index, so the columns right of one that +closes move down one; the log says `newcol ` and `delcol ` as they come +and go, with /layout to read again. + Control messages are split by what they act on, as acme keeps window verbs on a window's ctl and webfs and upas/fs keep session settings on a root ctl. Each builtin declares its scope in src/builtins.zig (`scope = .session`; diff --git a/src/fs-help.txt b/src/fs-help.txt index 0121a831..2f944c8e 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -1,7 +1,7 @@ Pardes control filesystem ========================= README this guide -index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name (+New if unnamed) +index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name (+New if unnamed), column status pid, version and pane count look write a line: a right click on it at the active pane; read: the serials it touched exec write a line: a middle click, an editor command word or a shell line; read the same @@ -11,6 +11,9 @@ listeners the session's dial addresses focus the serial of the pane with the keyboard (empty on a column tag); write a serial to give it the keyboard ctl settings, one a line; or Newcol (an empty column), Dump, Exit (quits, asks once), Kill [w] (stops what pardes ran, w: by first word) commands every builtin: its word, arg if it takes one, and root or pane: which ctl takes it +layout one line per column: index x width current|notcurrent empty|full serials...; then active +tag the workspace tag: read it, > replaces it, >> appends (one line) +col//tag a column's tag, the same way (columns count from 0, as in layout) pane/new open it to make a pane (named +New) in the active column, filling it if empty; the read answers its serial pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll errors (write-only: appended to its directory's +Errors pane) event look exec, pty/ on terminals; rmdir closes diff --git a/src/fs.zig b/src/fs.zig index 0a4473d6..21ccc94e 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1270,6 +1270,11 @@ pub const Namespace = struct { /// What went wrong performing a write's effects after it was answered /// by the core (a save the host could not do): the 9P write, which /// waits for them, fails with it (src/9p_io.zig). + /// A header tag truncated by an open not yet released (ninep/cols.zig): + /// 0 the workspace's, a column's its index + 1; and whether the newline + /// that ended its last write is held back. + header_rewrite: ?u32 = null, + header_held: bool = false, late_failure: [256]u8 = undefined, late_failure_len: u16 = 0, /// A refusal that quotes the message it refuses, as Plan 9's cmderror diff --git a/src/layout.zig b/src/layout.zig index c58f3bcf..6de7a912 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -280,7 +280,7 @@ pub fn applyRowSplit(p: *Pardes, cc: usize, k: usize, cur_y: u16) void { b.vweight = pair - a.vweight; } -pub fn findPane(p: *Pardes, id: usize) ?struct { col: usize, idx: usize } { +pub fn findPane(p: *const Pardes, id: usize) ?struct { col: usize, idx: usize } { for (0..p.ncol) |c| { for (0..p.col_n[c]) |k| { if (p.col_panes[c][k] == id) return .{ .col = c, .idx = k }; @@ -325,6 +325,14 @@ pub fn dropColumn(p: *Pardes, c: usize) void { p.ncol -= 1; p.col_tags[p.ncol] = .{ .what = .column, .gpa = p.gpa }; p.col_serial[p.ncol] = 0; + noteColumn(p, "delcol", c); +} + +/// `newcol ` or `delcol ` in the log: the index, as /layout and +/// /col number columns, the ones after it moving up or down one. +fn noteColumn(p: *Pardes, what: []const u8, c: usize) void { + var buf: [16]u8 = undefined; + pardes.ctlfs.events.notePath(p, what, std.fmt.bufPrint(&buf, "{d}", .{c}) catch return); } /// Fold column `c` into the one on its right, its panes below theirs. @@ -480,6 +488,7 @@ pub fn insertColumn(p: *Pardes, col: usize, before: bool) ?usize { p.col_serial[c] = 0; p.col_n[c] = 0; p.ncol += 1; + noteColumn(p, "newcol", c); return c; } diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig new file mode 100644 index 00000000..e1688517 --- /dev/null +++ b/src/ninep/cols.zig @@ -0,0 +1,163 @@ +//! The layout and the header tags: /layout, /tag (the workspace's) and +//! /col//tag (each column's). acme serves no column files -- its columns +//! are only a window's place -- so these go past it: a script can see where +//! the panes are and edit the tags a person clicks in. +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const Pardes = pardes.Pardes; +const tree = @import("tree.zig"); +const tagline = pardes.tagline; +const layout = pardes.layout; +const Text = pardes.panes.Text; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; + +/// The column with the keyboard: the header's, when a column tag has it, +/// else the active pane's. Null when the workspace tag has it and no pane +/// is active. +pub fn activeColumn(p: *const Pardes) ?usize { + if (p.header_focus) if (p.header_column) |c| return if (c < p.ncol) c else null; + const at = layout.findPane(p, p.active) orelse return null; + return at.col; +} + +/// One line a column: its index, x and width in cells, `current` or +/// `notcurrent` (rio's words, for the column with the keyboard), `empty` or +/// `full`, and its panes' serials, top to bottom; then `active `. +pub fn writeLayout(p: *const Pardes, w: *std.Io.Writer) !void { + const active = activeColumn(p); + for (0..p.ncol) |c| { + try w.print("{d} {d} {d} {s} {s}", .{ + c, p.col_x[c], p.col_w[c], + if (active == c) "current" else "notcurrent", if (p.col_n[c] == 0) "empty" else "full", + }); + for (p.col_panes[c][0..p.col_n[c]]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial}); + try w.writeByte('\n'); + } + if (active) |c| try w.print("active {d}\n", .{c}) else try w.writeAll("active -\n"); +} + +pub fn layoutLen(p: *const Pardes) u64 { + var buf: [256]u8 = undefined; + var counting: std.Io.Writer.Discarding = .init(&buf); + writeLayout(p, &counting.writer) catch return 0; + return counting.fullCount(); +} + +/// The header a node names: the workspace's (`col` null) or a column's. +fn header(p: *Pardes, col: ?usize) ?*Text { + const c = col orelse return &p.global_tag; + return if (c < p.ncol) &p.col_tags[c] else null; +} + +pub fn headerText(p: *Pardes, col: ?usize) ?[]const u8 { + const c = col orelse return tagline.topbar(p); + return if (c < p.ncol) tagline.columnTag(p, c) else null; +} + +pub fn read(p: *Pardes, req: Req, col: ?usize) Reply { + const text = headerText(p, col) orelse return Reply.fail(req.tag, E.NOENT); + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); + out.append(p.gpa, '\n') catch return Reply.fail(req.tag, E.NOMEM); + return tree.stagedReply(p, req); +} + +/// A write appends, as a pane tag's does; the tag is one line, so a newline +/// in it becomes a space (tagline.flattenHeaders), but after a truncation +/// the newline that ends the write is dropped, as a pane tag drops it. +pub fn write(p: *Pardes, req: Req, col: ?usize) Reply { + const t = header(p, col) orelse return Reply.fail(req.tag, E.NOENT); + if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; + const was = headerText(p, col).?; + var data = req.data; + const rewriting = p.fs.header_rewrite == rewriteKey(col); + // A newline held from the write before goes in once more text follows. + const held: []const u8 = if (rewriting and p.fs.header_held) " " else ""; + p.fs.header_held = false; + if (rewriting and data[data.len - 1] == '\n') { + data = data[0 .. data.len - 1]; + p.fs.header_held = true; + } + const next = std.mem.concat(p.gpa, u8, &.{ was, held, data }) catch return Reply.fail(req.tag, E.NOMEM); + std.mem.replaceScalar(u8, next, '\n', ' '); + if (t.own) |own| p.gpa.free(own); + t.own = next; + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +/// Truncating clears it, as a pane tag's `cleartag`: its default words go +/// too, and `u` in it brings them back. +pub fn truncate(p: *Pardes, col: ?usize) tree.Status { + const t = header(p, col) orelse return .err; + const empty = p.gpa.alloc(u8, 0) catch return .err; + t.remember(p.gpa, if (t.own) |own| .{ .text = own } else null); + if (t.own) |own| p.gpa.free(own); + t.own = empty; + t.cur_row = 0; + t.cur_col = 0; + p.fs.header_rewrite = rewriteKey(col); + p.fs.header_held = false; + return .ok; +} + +/// Which header a truncation was of: the workspace's is 0, a column's its +/// index + 1. +fn rewriteKey(col: ?usize) u32 { + return if (col) |c| @intCast(c + 1) else 0; +} + +pub fn released(p: *Pardes, col: ?usize) void { + if (p.fs.header_rewrite != rewriteKey(col)) return; + p.fs.header_rewrite = null; + p.fs.header_held = false; +} + +// ---- tests ---- + +const testing = std.testing; +const th = @import("testing.zig"); +const Node = tree.Node; + +test "layout lists each column's place, panes and state, and the active one" { + const p = try th.withFile(testing.allocator, "x\n"); + defer p.deinit(); + p.newColumn(p.active); + p.sync(); + const layout_node = @intFromEnum(tree.TopFile.layout); + const text = th.rd(p, layout_node, 0, 4096).bytes; + var want: [256]u8 = undefined; + const first = try std.fmt.bufPrint(&want, "0 {d} {d} notcurrent full {d}\n", .{ p.col_x[0], p.col_w[0], p.panes[0].?.serial }); + try testing.expect(std.mem.startsWith(u8, text, first)); + // Newcol gives the new, empty column's tag the keyboard. + try testing.expect(std.mem.indexOf(u8, text, "current empty\n") != null); + try testing.expect(std.mem.endsWith(u8, text, "active 1\n")); + try testing.expectEqual(@as(u64, text.len), th.call(p, .{ .tag = 1, .op = .getattr, .node = layout_node }).reply.attr.size); + // /index says which column each pane is in, last. + try testing.expect(std.mem.endsWith(u8, th.rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, " 0\n")); + try testing.expect(th.logHas(p, "newcol 1\n")); +} + +test "a column's tag and the workspace's read, replace and append as a pane tag does, on one line" { + const p = try th.withFile(testing.allocator, "x\n"); + defer p.deinit(); + const col_dir = @intFromEnum(tree.TopFile.col); + try testing.expectEqual(tree.Status.ok, th.look_up(p, col_dir, "0").reply.status); + try testing.expectEqual(E.NOENT, th.look_up(p, col_dir, "7").errno()); + const tag = Node.ofCol(0, .tag); + try testing.expectEqual(tree.Status.ok, th.look_up(p, Node.ofCol(0, .dir), "tag").reply.status); + try testing.expectEqualStrings("New Tty Find Grep Joincol Delcol\n", th.rd(p, tag, 0, 4096).bytes); + // `echo Make > tag`: cleared, then the newline ending the write dropped. + _ = th.call(p, .{ .tag = 1, .op = .setattr, .node = tag, .truncate = true }); + _ = th.wr(p, tag, "Make\n"); + try testing.expectEqualStrings("Make\n", th.rd(p, tag, 0, 4096).bytes); + _ = th.call(p, .{ .tag = 2, .op = .release, .node = tag }); + // `>>` appends; a newline in a one-line tag is a space. + _ = th.wr(p, tag, " Lint\nNow"); + try testing.expectEqualStrings("Make Lint Now\n", th.rd(p, tag, 0, 4096).bytes); + const top = @intFromEnum(tree.TopFile.tag); + _ = th.call(p, .{ .tag = 3, .op = .setattr, .node = top, .truncate = true }); + _ = th.wr(p, top, "Newcol Exit\n"); + try testing.expectEqualStrings("Newcol Exit", tagline.topbar(p)); +} diff --git a/src/ninep/events.zig b/src/ninep/events.zig index 0e489be7..fc410d5a 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -172,6 +172,10 @@ pub fn noteError(p: *Pardes, req: Req, reply: Reply) void { if (req.node != pardes.filesystem.os_root and req.node & pardes.filesystem.os_node == 0 and req.node & tree.sources.archive_node == 0) { if (tree.Node.target(req.node)) |t| switch (t) { .top => |f| file = f.fileName(), + .col => |c| { + serial = "-"; + file = std.fmt.bufPrint(&name, "col/{d}/tag", .{c.index}) catch "col"; + }, .pane => |pt| { serial = std.fmt.bufPrint(&name, "{d}", .{pt.serial}) catch "-"; file = switch (pt.file) { diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 3eafdbce..6542d747 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -265,6 +265,12 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { // ---- the index ---- +/// The column a pane is in, as /layout and /col number them; the last word +/// of its /index line. +pub fn columnOf(p: *const Pardes, id: usize) usize { + return if (pardes.layout.findPane(p, id)) |at| at.col else 0; +} + pub fn indexLen(p: *Pardes) u64 { var n: u64 = 0; var last: u32 = 0; @@ -274,6 +280,7 @@ pub fn indexLen(p: *Pardes) u64 { var digits: [16]u8 = undefined; n += (std.fmt.bufPrint(&digits, "{d}", .{serial}) catch unreachable).len; n += 1 + kindOf(pane).len + 3 + nameOf(pane).len + 1; + n += 1 + (std.fmt.bufPrint(&digits, "{d}", .{columnOf(p, p.paneBySerial(serial).?)}) catch unreachable).len; } return n; } @@ -703,7 +710,7 @@ test "index lists serial kind dirty flag and name and stat reports its length" { const a = rd(p, index, 0, 4096); try testing.expectEqual(Status.ok, a.reply.status); var want: [64]u8 = undefined; - const clean_row = try std.fmt.bufPrint(&want, "{d} text 0 /test.txt\n", .{pane.serial}); + const clean_row = try std.fmt.bufPrint(&want, "{d} text 0 /test.txt 0\n", .{pane.serial}); try testing.expect(std.mem.indexOf(u8, a.bytes, clean_row) != null); const at = std.mem.indexOf(u8, a.bytes, clean_row).?; const stat = call(p, .{ .tag = 1, .op = .getattr, .node = index }); @@ -712,7 +719,7 @@ test "index lists serial kind dirty flag and name and stat reports its length" { pane.file.?.saved_revision = pane.file.?.revision -% 1; var dirty_want: [64]u8 = undefined; - const dirty_row = try std.fmt.bufPrint(&dirty_want, "{d} text 1 /test.txt\n", .{pane.serial}); + const dirty_row = try std.fmt.bufPrint(&dirty_want, "{d} text 1 /test.txt 0\n", .{pane.serial}); try testing.expect(std.mem.indexOf(u8, rd(p, index, 0, 4096).bytes, dirty_row) != null); const kind = at + std.mem.indexOfScalar(u8, clean_row, ' ').? + 1; try testing.expectEqualStrings("text", rd(p, index, kind, 4).bytes); @@ -722,7 +729,7 @@ test "index lists serial kind dirty flag and name and stat reports its length" { try testing.expectEqual(@as(u64, both.bytes.len), indexLen(p)); var expected: [4200]u8 = undefined; const made = p.panes[p.paneBySerial(serial).?].?; - try testing.expect(std.mem.endsWith(u8, both.bytes, try std.fmt.bufPrint(&expected, "\n{d} text 0 {s}\n", .{ serial, nameOf(made) }))); + try testing.expect(std.mem.endsWith(u8, both.bytes, try std.fmt.bufPrint(&expected, "\n{d} text 0 {s} {d}\n", .{ serial, nameOf(made), columnOf(p, p.paneBySerial(serial).?) }))); } test "a terminal is listed as term with its directory as name" { @@ -734,7 +741,7 @@ test "a terminal is listed as term with its directory as name" { try testing.expect(std.mem.indexOf( u8, rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, - try std.fmt.bufPrint(&want, "{d} term 0 /work/dir\n", .{pane.serial}), + try std.fmt.bufPrint(&want, "{d} term 0 /work/dir 0\n", .{pane.serial}), ) != null); try testing.expectEqualStrings("/work/dir\n", rd(p, Node.of(pane.serial, .name), 0, 4096).bytes); const refused = wr(p, Node.of(pane.serial, .name), "/elsewhere\n"); diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 7279b64a..9459be4f 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -18,6 +18,7 @@ pub const events = @import("events.zig"); pub const pane = @import("pane.zig"); pub const addr = @import("addr.zig"); pub const ctl = @import("ctl.zig"); +pub const cols = @import("cols.zig"); pub const pty = @import("pty.zig"); pub const sources = @import("sources.zig"); pub const screen = @import("screen.zig"); @@ -171,7 +172,7 @@ pub fn openOf(p: *Pardes, req: Req) ?*Open { // ---- nodes ---- -pub const TopFile = enum(u4) { +pub const TopFile = enum(u5) { root = 1, README, index, @@ -186,6 +187,9 @@ pub const TopFile = enum(u4) { focus, ctl, commands, + layout, + tag, + col, pub fn fileName(f: TopFile) []const u8 { return if (f == .root) "/" else @tagName(f); @@ -193,14 +197,14 @@ pub const TopFile = enum(u4) { pub fn mode(f: TopFile) u16 { return switch (f) { - .root, .pane => 0o755, - .look, .exec, .log, .focus, .ctl => 0o666, - .README, .index, .status, .screen, .listeners, .new, .commands => 0o444, + .root, .pane, .col => 0o755, + .look, .exec, .log, .focus, .ctl, .tag => 0o666, + .README, .index, .status, .screen, .listeners, .new, .commands, .layout => 0o444, }; } pub fn dir(f: TopFile) bool { - return f == .root or f == .pane; + return f == .root or f == .pane or f == .col; } }; @@ -264,6 +268,11 @@ pub const PaneFile = enum(u5) { } }; +/// /col/ and its tag: a column is named by its index, which a serial +/// never is (serials are 32 bits; this bit is past them). +pub const ColFile = enum(u5) { dir = 0, tag = 1 }; +const col_bit: u59 = 1 << 58; + pub const Node = packed struct(u64) { file: u5 = 0, serial: u59 = 0, @@ -273,11 +282,19 @@ pub const Node = packed struct(u64) { return @bitCast(Node{ .file = @intFromEnum(file), .serial = serial }); } + pub fn ofCol(index: usize, file: ColFile) u64 { + return @bitCast(Node{ .file = @intFromEnum(file), .serial = col_bit | @as(u59, @intCast(index)) }); + } + pub fn target(node: u64) ?Target { const n: Node = @bitCast(node); if (n.serial == 0) { return .{ .top = std.enums.fromInt(TopFile, n.file) orelse return null }; } + if (n.serial & col_bit != 0) return .{ .col = .{ + .index = std.math.cast(u32, n.serial & ~col_bit) orelse return null, + .file = std.enums.fromInt(ColFile, n.file) orelse return null, + } }; return .{ .pane = .{ .serial = std.math.cast(u32, n.serial) orelse return null, .file = std.enums.fromInt(PaneFile, n.file) orelse return null, @@ -288,6 +305,7 @@ pub const Node = packed struct(u64) { pub const Target = union(enum) { top: TopFile, pane: struct { serial: u32, file: PaneFile }, + col: struct { index: u32, file: ColFile }, }; /// Opening /pane/new makes a pane and reading the open fid answers its @@ -388,7 +406,7 @@ pub fn handle(p: *Pardes, req: Req) Reply { const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); if (req.op == .write or req.op == .setattr) p.fs.origin = switch (target) { .pane => |t| @as(u8, if (t.file == .body or t.file == .tag) 'E' else 'F'), - .top => 'F', + .top, .col => 'F', }; return switch (req.op) { .lookup => lookup(p, req, target), @@ -410,7 +428,7 @@ pub fn handle(p: *Pardes, req: Req) Reply { fn runAttr(p: *Pardes, req: Req, target: Target) ?Reply.Attr { const t = switch (target) { .pane => |t| t, - .top => return null, + .top, .col => return null, }; if (t.file != .pty_run) return null; const run = if (req.handle != 0) openOf(p, req) else for (&p.fs.opens) |*o| { @@ -429,6 +447,19 @@ fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { .mode = f.mode(), .size = topSize(p, f), .mtime = p.fs.started, + .append = f == .tag, + }, + .col => |c| { + if (c.index >= p.ncol) return null; + return .{ + .name = if (c.file == .dir) (std.fmt.bufPrint(&p.fs.node_name, "{d}", .{c.index}) catch unreachable) else "tag", + .node = Node.ofCol(c.index, c.file), + .dir = c.file == .dir, + .mode = if (c.file == .dir) 0o755 else 0o666, + .size = if (c.file == .tag) cols.headerText(p, c.index).?.len + 1 else 0, + .mtime = p.fs.started, + .append = c.file == .tag, + }; }, .pane => |t| { const id = p.paneBySerial(t.serial) orelse return null; @@ -461,7 +492,9 @@ fn topSize(p: *Pardes, f: TopFile) u64 { return switch (f) { // ponytail: /screen has no length until an open renders its frame, // and /pane/new none until an open has a pane to name. - .root, .pane, .screen, .new => 0, + .root, .pane, .col, .screen, .new => 0, + .layout => cols.layoutLen(p), + .tag => cols.headerText(p, null).?.len + 1, .index => pane.indexLen(p), .README => fs.help.len, .status => ctl.statusLen(p), @@ -492,6 +525,7 @@ fn lookup(p: *Pardes, req: Req, target: Target) Reply { .pty => Node.of(t.serial, .dir), else => return Reply.fail(req.tag, E.NOTDIR), }, + .col => |c| if (c.file == .dir) @intFromEnum(TopFile.col) else return Reply.fail(req.tag, E.NOTDIR), }; return handle(p, .{ .tag = req.tag, .op = .getattr, .node = parent }); } @@ -514,8 +548,19 @@ fn lookup(p: *Pardes, req: Req, target: Target) Reply { if (serial == 0) return Reply.fail(req.tag, E.NOENT); break :pane Node.of(serial, .dir); }, + // A column is its index, in decimal digits. + .col => col: { + if (name.len > 4) return Reply.fail(req.tag, E.NOENT); + for (name) |c| if (c < '0' or c > '9') return Reply.fail(req.tag, E.NOENT); + break :col Node.ofCol(std.fmt.parseInt(u32, name, 10) catch return Reply.fail(req.tag, E.NOENT), .dir); + }, else => return Reply.fail(req.tag, E.NOTDIR), }, + .col => |c| col: { + if (c.file != .dir) return Reply.fail(req.tag, E.NOTDIR); + if (!std.mem.eql(u8, name, "tag")) return Reply.fail(req.tag, E.NOENT); + break :col Node.ofCol(c.index, .tag); + }, .pane => |t| pane: { _ = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); const f = switch (t.file) { @@ -555,7 +600,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { .root => { // The guide, then what describes the session, then the // files that act, then the directories. - inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.focus, TopFile.ctl, TopFile.commands, TopFile.look, TopFile.exec, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.pane }) |t| { + inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.focus, TopFile.ctl, TopFile.commands, TopFile.look, TopFile.exec, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.layout, TopFile.tag, TopFile.pane, TopFile.col }) |t| { if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(t), t.dir(), t.fileName()); } if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, fs.os_root, true, "os"); @@ -575,8 +620,21 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { stageDirent(out, p.gpa, Node.of(serial, .dir), true, name); } }, + .col => for (0..p.ncol) |c| { + if (skip > 0) { + skip -= 1; + continue; + } + var buf: [16]u8 = undefined; + stageDirent(out, p.gpa, Node.ofCol(c, .dir), true, std.fmt.bufPrint(&buf, "{d}", .{c}) catch unreachable); + }, else => return Reply.fail(req.tag, E.NOTDIR), }, + .col => |c| { + if (c.index >= p.ncol) return Reply.fail(req.tag, E.NOENT); + if (c.file != .dir) return Reply.fail(req.tag, E.NOTDIR); + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, Node.ofCol(c.index, .tag), false, "tag"); + }, .pane => |t| { const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); const terminal = p.panes[id].?.isTerminal(); @@ -610,6 +668,7 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { .log => .{ .log = .{} }, else => return .{ .tag = req.tag }, }, + .col => |c| return if (c.index < p.ncol) .{ .tag = req.tag } else Reply.fail(req.tag, E.NOENT), .pane => |t| what: { const pn = p.panes[p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT)].?; if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); @@ -665,7 +724,7 @@ fn remove(p: *Pardes, req: Req) Reply { const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); const t = switch (target) { .pane => |t| t, - .top => return Reply.fail(req.tag, E.PERM), + .top, .col => return Reply.fail(req.tag, E.PERM), }; if (t.file != .dir) return Reply.fail(req.tag, E.PERM); const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); @@ -690,6 +749,8 @@ fn releaseHandle(p: *Pardes, req: Req) void { p.panes[id].?.fs.tag_rewrite = false; p.panes[id].?.fs.tag_held_newline = false; }; + if (t == .col and t.col.file == .tag) cols.released(p, t.col.index); + if (t == .top and t.top == .tag) cols.released(p, null); const o = openOf(p, req) orelse return; const of: ?*Pane = if (t == .pane) (if (p.paneBySerial(t.pane.serial)) |id| p.panes[id] else null) else null; if (of) |pn| switch (o.what) { @@ -725,7 +786,8 @@ fn setattr(p: *Pardes, req: Req, target: Target) Reply { return failText(req.tag, E.INVAL, pane.e_addr_failed); if (pane.truncate(p, p.panes[id].?, t.file) != .ok) return Reply.fail(req.tag, E.NOMEM); }, - .top => {}, + .col => |c| if (c.file == .tag and cols.truncate(p, c.index) != .ok) return Reply.fail(req.tag, E.NOENT), + .top => |f| if (f == .tag and cols.truncate(p, null) != .ok) return Reply.fail(req.tag, E.NOMEM), }; return .{ .tag = req.tag, .attr = attrOf(p, target) orelse return Reply.fail(req.tag, E.NOENT) }; } @@ -770,8 +832,9 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { var last: u32 = 0; while (nextSerialAfter(p, last)) |serial| { last = serial; - const pn = p.panes[p.paneBySerial(serial).?].?; - out.print(p.gpa, "{d} {s} {d} {s}\n", .{ serial, pane.kindOf(pn), @intFromBool(pane.dirtyOf(pn)), pane.nameOf(pn) }) catch {}; + const id = p.paneBySerial(serial).?; + const pn = p.panes[id].?; + out.print(p.gpa, "{d} {s} {d} {s} {d}\n", .{ serial, pane.kindOf(pn), @intFromBool(pane.dirtyOf(pn)), pane.nameOf(pn), pane.columnOf(p, id) }) catch {}; } break :index stagedReply(p, req); }, @@ -783,6 +846,13 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { .focus => ctl.readFocus(p, req), .ctl => ctl.readRoot(p, req), .commands => ctl.readCommands(p, req), + .layout => layout: { + var text: std.Io.Writer.Allocating = .init(p.scratch.allocator()); + cols.writeLayout(p, &text.writer) catch break :layout Reply.fail(req.tag, E.NOMEM); + p.fs.stage(p.gpa).appendSlice(p.gpa, text.written()) catch break :layout Reply.fail(req.tag, E.NOMEM); + break :layout stagedReply(p, req); + }, + .tag => cols.read(p, req, null), // The serial the open handed this fid, so that two reads of one // fid answer the same pane: the read observes, the open acted. .new => serial: { @@ -791,7 +861,7 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { break :serial Reply.fail(req.tag, E.NOMEM); break :serial stagedReply(p, req); }, - .root, .pane => Reply.fail(req.tag, E.PERM), + .root, .pane, .col => Reply.fail(req.tag, E.PERM), }, .pane => |t| { // A run's answer outlives the pane it ran in. @@ -807,6 +877,7 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); return pane.read(p, req, id, pn, t.file); }, + .col => |c| return if (c.file == .tag) cols.read(p, req, c.index) else Reply.fail(req.tag, E.PERM), } } @@ -817,6 +888,7 @@ fn write(p: *Pardes, req: Req, target: Target) Reply { .log => events.writeLog(p, req), .focus => ctl.writeFocus(p, req), .ctl => ctl.writeRoot(p, req), + .tag => cols.write(p, req, null), else => Reply.fail(req.tag, E.PERM), }, .pane => |t| { @@ -825,6 +897,7 @@ fn write(p: *Pardes, req: Req, target: Target) Reply { if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); return pane.write(p, req, id, pn, t.file); }, + .col => |c| return if (c.file == .tag) cols.write(p, req, c.index) else Reply.fail(req.tag, E.PERM), } } @@ -836,6 +909,7 @@ test { _ = addr; _ = ctl; _ = pty; + _ = cols; _ = sources; _ = screen; } @@ -968,12 +1042,13 @@ test "readdir lists the root and a pane directory without creating anything" { @memcpy(top_bytes[0..top_reply.bytes.len], top_reply.bytes); const top = th.dirents(top_bytes[0..top_reply.bytes.len], &buf); try testing.expect(top.len >= 10); - for ([_][]const u8{ "README", "index", "status", "focus", "ctl", "commands", "look", "exec", "log", "screen", "listeners", "pane", "os" }, 0..) |name, i| { + for ([_][]const u8{ "README", "index", "status", "focus", "ctl", "commands", "look", "exec", "log", "screen", "listeners", "layout", "tag", "pane", "col", "os" }, 0..) |name, i| { try testing.expectEqualStrings(name, top[i].name); - try testing.expectEqual(i >= 11, top[i].dir); + try testing.expectEqual(i >= 13, top[i].dir); } - try testing.expectEqual(@intFromEnum(TopFile.pane), top[11].node); - try testing.expectEqual(fs.os_root, top[12].node); + try testing.expectEqual(@intFromEnum(TopFile.pane), top[13].node); + try testing.expectEqual(@intFromEnum(TopFile.col), top[14].node); + try testing.expectEqual(fs.os_root, top[15].node); var idbuf: [16]u8 = undefined; try testing.expect(th.nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null); try testing.expect(th.nameAt(top, "self") == null); diff --git a/test/selfmount.py b/test/selfmount.py index cc889a93..90960bed 100644 --- a/test/selfmount.py +++ b/test/selfmount.py @@ -75,7 +75,7 @@ def run(binary): mount = f'/mnt/9p/pardes/{name}' with Client(sock) as client: index = client.read('/index').decode() - rows = [row.split(maxsplit=3) for row in index.splitlines()] + rows = [row.rsplit(maxsplit=1)[0].split(maxsplit=3) for row in index.splitlines()] first = rows[0][0] # A Look at the tree's own index: realpath, stat and read all go # out through 9ns and back in, and the write returns when the @@ -84,7 +84,7 @@ def run(binary): client.write('/look', (mount + '/index\n').encode()) took = time.monotonic() - started check(took < 5, f'look at the mounted index returned ({took:.2f}s)') - rows = [row.split(maxsplit=3) for row in client.read('/index').decode().splitlines()] + rows = [row.rsplit(maxsplit=1)[0].split(maxsplit=3) for row in client.read('/index').decode().splitlines()] opened = [row for row in rows if len(row) == 4 and row[3] == mount + '/index'] check(len(opened) == 1, 'a pane opened on the mounted index') if opened: @@ -94,7 +94,7 @@ def run(binary): # and a Save: the save writes back through the mount into pane 1, # and the exec returns once it has. client.write('/look', f'{mount}/pane/{first}/body\n'.encode()) - rows = [row.split(maxsplit=3) for row in client.read('/index').decode().splitlines()] + rows = [row.rsplit(maxsplit=1)[0].split(maxsplit=3) for row in client.read('/index').decode().splitlines()] mirror = [row for row in rows if len(row) == 4 and row[3] == f'{mount}/pane/{first}/body'] check(len(mirror) == 1, 'a pane opened on the mounted body') if mirror: -- cgit v1.3 From 3267d276ab2553adb412183eb92390ed579b494f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 17:03:15 -0300 Subject: zig build monkey: random snapshot scripts hunting panics test/monkey.zig (Zig, as the project's tooling is): one random .snap per seed, over bad-UTF-8, wide-glyph and long files: keys, leader bursts, typing (an alphabet with no path characters), workspace words run by a middle click (Newcol for narrow panes, Find and Grep for prompts, long prompt text), presses, drags, wheel, hover, and resizes down to a cell. pardes-snap runs it with --update; a panic is a record in the app's crash file (in the script's fake home: seen even when the crash cut the script short) or a `.zig:N:N: 0x` frame of the app's (not the harness's) in its report or captured grid, and a hit keeps the script, captures and log under --out (default /tmp/pardes-monkey). A seed always makes the same script (tested), so --from=N replays one. Not a gate. README documents it next to snap. No Shader line: the tty has no post chain; the core fuzz in src/draw.zig covers the compile-error notice at a gui's metrics. 80 seeds x 70 steps: no panic. --- README.md | 15 ++++ build/snap.zig | 19 +++++ test/monkey.zig | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 278 insertions(+) create mode 100644 test/monkey.zig (limited to 'README.md') diff --git a/README.md b/README.md index 3e7a96f2..267b5ca7 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ zig build 9p-test freestanding protocol tests zig build quic-test -Dquic=true optional QUIC transport tests zig build snap scripted input traces against frozen golden grids zig build snap-driver-test retry evidence, strict failures and fixture isolation +zig build monkey random snapshot scripts hunting panics (not a gate) +zig build monkey-test the monkey's generator and panic detector zig build hxdiff differential suite against helix's own behaviour zig build hxdiff-test comparator, allocation and CLI regression checks zig build hxdiff-live compare against a freshly run hx-harness @@ -150,6 +152,19 @@ The benchmark steps — `perf`, `pdf-bench`, `pdf-scroll-bench`, `pdf-sections-b Snapshot scripts can use `snap9p` to capture core cells and styles through the default socket alongside the terminal emulator's independent captures. +`zig build monkey -Dplatform=tty -- [steps] [--from=N] [--out=DIR] [--keep]` +writes one random script per seed (keys, leader bursts, typing, clicks, drags, +wheel, tiny resizes, prompts and long prompt text over bad-UTF-8 and wide-glyph +files), runs it through pardes-snap and looks for a panic's `.zig:N:N: 0x` +frame in the report and in the captured grid. A hit keeps the script, its +captures and its log in DIR (default `/tmp/pardes-monkey`); a seed always makes +the same script, so `--from=N` with one seed replays it. A trace longer than +the grid scrolls away: replay the kept script at a larger `start` size. Each +crash found gets a fix and a regression script in `test/snapshots/`. The tty's +tagline is the body's pitch, so what a narrower tagline does is fuzzed by a +unit test instead (`a monkey over notices…` in `src/draw.zig`, longer with +`PARDES_FUZZ_SEED`/`PARDES_FUZZ_STEPS`). + `-Dtest-filter=` applies to every unit-test binary. Use `-Doptimize=ReleaseFast` for performance measurements. To record output and first/warm command runtimes across revisions, run: diff --git a/build/snap.zig b/build/snap.zig index 6b3d2104..7aa06884 100644 --- a/build/snap.zig +++ b/build/snap.zig @@ -49,6 +49,25 @@ pub fn addTty(b: *std.Build, opts: struct { run_snap.has_side_effects = true; const snap_step = b.step("snap", "run the snapshot parity suite (-- --update regenerates goldens)"); snap_step.dependOn(&run_snap.step); + // Random scripts through pardes-snap, hunting panics (test/monkey.zig): + // not a gate, it is slow and random over seeds; a seed replays. + const monkey = b.addExecutable(.{ + .name = "pardes-monkey", + .root_module = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + .root_source_file = b.path("test/monkey.zig"), + .link_libc = true, + }), + }); + const run_monkey = b.addRunArtifact(monkey); + run_monkey.addArtifactArg(snap); + run_monkey.addArtifactArg(opts.exe); + if (b.args) |args| run_monkey.addArgs(args); + run_monkey.has_side_effects = true; + b.step("monkey", "random snapshot scripts hunting panics (-- [steps] [--from=N] [--out=DIR])").dependOn(&run_monkey.step); + const monkey_tests = b.addTest(.{ .root_module = monkey.root_module }); + b.step("monkey-test", "test the monkey's generator and panic detector").dependOn(&b.addRunArtifact(monkey_tests).step); const run_driver_test = b.addRunArtifact(snap); run_driver_test.addArg("--self-test"); run_driver_test.has_side_effects = true; diff --git a/test/monkey.zig b/test/monkey.zig new file mode 100644 index 00000000..83869ce4 --- /dev/null +++ b/test/monkey.zig @@ -0,0 +1,244 @@ +// pardes-monkey: random snapshot scripts against the tty, hunting panics. +// +// zig build monkey -Dplatform=tty -- [steps] [--from=N] [--out=DIR] [--keep] +// +// Each seed makes one script (a fixed seed makes the same script, so a hit +// replays): keys and leader bursts, typing, mouse presses, drags and wheel, +// tiny resizes, prompts and long prompt text, over files of bad UTF-8 and +// wide glyphs. pardes-snap runs it with --update into DIR (default +// /tmp/pardes-monkey), and a panic is a record in the app's crash file +// (src/crash.zig, in the script's fake home: found even when the crash cut +// the script short) or a `.zig:N:N: 0x` stack frame in the report or the +// grid it captured (a trace renders INTO the screen). A hit +// keeps DIR/seed-N.snap, its captures and its report; the rest are deleted. +// A panic's trace can scroll off a small grid: replay the kept script, or +// run the app in a larger pty. Every hit gets a fix and a pinned regression +// script in test/snapshots/. +// +// Not a test gate: it is slow, random over seeds and aimed at finding, not +// holding. Shell text typed into a pane only ever runs in the throwaway +// script directory, and its alphabet has no path characters. +const std = @import("std"); +const libc = std.c; + +const Script = struct { + out: std.ArrayListUnmanaged(u8) = .empty, + gpa: std.mem.Allocator, + rows: u16 = 24, + cols: u16 = 80, + + fn line(s: *Script, comptime fmt: []const u8, args: anytype) !void { + try s.out.print(s.gpa, fmt ++ "\n", args); + } +}; + +// Workspace-tag words: clicked with the middle button they run, and the +// harness finds their column on row 1 while the window is wide enough. +const commands = [_][]const u8{ "Newcol", "Find", "Grep", "Joincol", "Help", "Dump", "NextColor", "Debug" }; +const leader_keys = "abcdefghijklmnopqrstuvwxyz0123456789$^"; +const typed = "abcdefghijklmnopqrstuvwxyz0123456789 -_=+,:;()"; + +fn generate(gpa: std.mem.Allocator, seed: u64, steps: usize) ![]u8 { + var prng = std.Random.DefaultPrng.init(seed); + const random = prng.random(); + var s: Script = .{ .gpa = gpa }; + try s.line("# pardes-monkey seed {d}, {d} steps", .{ seed, steps }); + try s.line("file bad.txt hello \\xff\\xfe world\\nlatin-1 caf\\xe9 tail\\ntruncated \\xe6\\x97 here\\nend\\n", .{}); + try s.line("file wide.txt {s}tail\\nsecond line\\n", .{"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e " ** 8}); + try s.line("lines long.txt 400 some words after the number, long enough to wrap in a narrow pane", .{}); + try s.line("start 24 80 bad.txt", .{}); + try s.line("wait 8000 Newcol Joincol", .{}); + try s.line("stable 300 5000", .{}); + for (0..steps) |step| { + const wide = s.cols >= 70 and s.rows >= 6; + switch (random.uintLessThan(u8, 12)) { + // A workspace word, run with a middle click: new columns make + // narrow panes, Find and Grep open prompts. + 0, 1 => if (wide) { + const word = commands[random.uintLessThan(usize, commands.len)]; + try s.line("press middle @{s} 1", .{word}); + try s.line("release middle @{s} 1", .{word}); + }, + // Typing: into a prompt when one is up, far past its band. + 2, 3 => { + var text: [200]u8 = undefined; + const n = random.intRangeAtMost(usize, 1, if (random.uintLessThan(u8, 4) == 0) text.len else 12); + for (text[0..n]) |*c| c.* = typed[random.uintLessThan(usize, typed.len)]; + try s.line("text {s}", .{text[0..n]}); + }, + 4 => try s.line("key {s}", .{switch (random.uintLessThan(u8, 10)) { + 0 => "enter", + 1 => "tab", + 2 => "bs", + 3 => "up", + 4 => "down", + 5 => "left", + 6 => "right", + 7 => "pgdn", + 8 => "home", + else => "end", + }}), + 5 => { + try s.line("key esc", .{}); + try s.line("settle 120", .{}); + }, + // A leader burst: space and a chord's keys. + 6 => { + var chord: [3][2]u8 = undefined; + const n = random.intRangeAtMost(usize, 1, 3); + for (chord[0..n]) |*c| c.* = .{ leader_keys[random.uintLessThan(usize, leader_keys.len)], 0 }; + try s.out.appendSlice(gpa, "key space"); + for (chord[0..n]) |c| try s.out.print(gpa, " {c}", .{c[0]}); + try s.out.append(gpa, '\n'); + }, + 7, 8 => { + const buttons = [_][]const u8{ "left", "middle", "right" }; + const button = buttons[random.uintLessThan(usize, buttons.len)]; + const col = random.intRangeAtMost(u16, 1, s.cols); + const row = random.intRangeAtMost(u16, 1, s.rows); + try s.line("press {s} {d} {d}", .{ button, col, row }); + if (random.boolean()) try s.line("drag {s} {d} {d}", .{ button, random.intRangeAtMost(u16, 1, s.cols), random.intRangeAtMost(u16, 1, s.rows) }); + try s.line("release {s} {d} {d}", .{ button, random.intRangeAtMost(u16, 1, s.cols), random.intRangeAtMost(u16, 1, s.rows) }); + }, + 9 => try s.line("wheel {s} {d} {d}", .{ if (random.boolean()) "up" else "down", random.intRangeAtMost(u16, 1, s.cols), random.intRangeAtMost(u16, 1, s.rows) }), + 10 => try s.line("motion {d} {d}", .{ random.intRangeAtMost(u16, 1, s.cols), random.intRangeAtMost(u16, 1, s.rows) }), + // Tiny windows as often as ordinary ones. + else => { + s.rows = if (random.boolean()) random.intRangeAtMost(u16, 1, 6) else random.intRangeAtMost(u16, 7, 40); + s.cols = if (random.boolean()) random.intRangeAtMost(u16, 1, 20) else random.intRangeAtMost(u16, 21, 140); + try s.line("resize {d} {d}", .{ s.rows, s.cols }); + }, + } + try s.line("settle 30", .{}); + if (step % 10 == 9) try s.line("snap s{d}", .{step}); + } + try s.line("stable 300 5000", .{}); + try s.line("snap end", .{}); + return s.out.toOwnedSlice(gpa); +} + +/// A stack frame of a Zig panic trace, `.zig:12:34: 0x`, of the app's: the +/// harness's own error trace (a script it could not finish) is not a hit. +fn hasTrace(bytes: []const u8) bool { + var lines = std.mem.splitScalar(u8, bytes, '\n'); + while (lines.next()) |line| { + if (std.mem.indexOf(u8, line, "test/snapshot.zig") != null or std.mem.indexOf(u8, line, "test/e2e_harness.zig") != null) continue; + if (frameIn(line)) return true; + } + return false; +} + +fn frameIn(bytes: []const u8) bool { + var from: usize = 0; + while (std.mem.indexOfPos(u8, bytes, from, ".zig:")) |at| : (from = at + 1) { + var i = at + ".zig:".len; + var digits: usize = 0; + while (i < bytes.len and std.ascii.isDigit(bytes[i])) : (i += 1) digits += 1; + if (digits == 0 or i >= bytes.len or bytes[i] != ':') continue; + i += 1; + digits = 0; + while (i < bytes.len and std.ascii.isDigit(bytes[i])) : (i += 1) digits += 1; + if (digits > 0 and std.mem.startsWith(u8, bytes[i..], ": 0x")) return true; + } + return false; +} + +test "a panic trace is found, and ordinary colons are not" { + try std.testing.expect(hasTrace(" /src/draw.zig:814:31: 0x4212821 in joinNotice")); + try std.testing.expect(!hasTrace("draw.zig:814 is where it was; 12:30: 0x")); + try std.testing.expect(!hasTrace("/x/test/snapshot.zig:197:28: 0x1279761 in main (snapshot.zig)")); +} + +test "a seed makes the same script every time" { + const a = try generate(std.testing.allocator, 42, 50); + defer std.testing.allocator.free(a); + const b = try generate(std.testing.allocator, 42, 50); + defer std.testing.allocator.free(b); + try std.testing.expectEqualStrings(a, b); +} + +fn readAll(gpa: std.mem.Allocator, io: std.Io, path: []const u8) []u8 { + return std.Io.Dir.cwd().readFileAlloc(io, path, gpa, .limited(64 << 20)) catch &.{}; +} + +pub fn main(init: std.process.Init) !void { + const gpa = std.heap.page_allocator; + const io = init.io; + const args = try init.minimal.args.toSlice(init.arena.allocator()); + if (args.len < 4) { + std.debug.print("usage: pardes-monkey [steps] [--from=N] [--out=DIR]\n", .{}); + std.process.exit(2); + } + const snap = args[1]; + const app = args[2]; + var seeds: u64 = 20; + var steps: usize = 70; + var from: u64 = 1; + var out: []const u8 = "/tmp/pardes-monkey"; + // Keep every script and capture, not only a hit's: to see what it did. + var keep = false; + var positional: usize = 0; + for (args[3..]) |a| { + if (std.mem.startsWith(u8, a, "--from=")) { + from = try std.fmt.parseInt(u64, a["--from=".len..], 10); + } else if (std.mem.eql(u8, a, "--keep")) { + keep = true; + } else if (std.mem.startsWith(u8, a, "--out=")) { + out = a["--out=".len..]; + } else { + switch (positional) { + 0 => seeds = try std.fmt.parseInt(u64, a, 10), + 1 => steps = try std.fmt.parseInt(usize, a, 10), + else => {}, + } + positional += 1; + } + } + std.Io.Dir.cwd().createDirPath(io, out) catch {}; + var hits: usize = 0; + var seed = from; + while (seed < from + seeds) : (seed += 1) { + const script = try generate(gpa, seed, steps); + defer gpa.free(script); + var path_buf: [4096]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buf, "{s}/seed-{d}.snap", .{ out, seed }); + try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = path, .data = script }); + const run = std.process.run(gpa, io, .{ + .argv = &.{ snap, app, "--update", "--no-retry", "--jobs=1", path }, + .stdout_limit = .limited(64 << 20), + .stderr_limit = .limited(64 << 20), + }) catch |err| { + std.debug.print("seed {d}: pardes-snap did not run ({t})\n", .{ seed, err }); + continue; + }; + defer gpa.free(run.stdout); + defer gpa.free(run.stderr); + var golden_buf: [4096]u8 = undefined; + const golden_path = try std.fmt.bufPrint(&golden_buf, "{s}/seed-{d}.golden", .{ out, seed }); + const golden = readAll(gpa, io, golden_path); + defer gpa.free(golden); + // The app's own crash file (src/crash.zig) in the script's fake home: + // found even when the crash cut the script short of a capture. + var crash_buf: [4096]u8 = undefined; + const crash_path = try std.fmt.bufPrint(&crash_buf, "/tmp/pardes-snap/seed-{d}/home/.config/pardes/crashes", .{seed}); + const crashes = readAll(gpa, io, crash_path); + defer gpa.free(crashes); + if (crashes.len != 0 or hasTrace(run.stdout) or hasTrace(run.stderr) or hasTrace(golden)) { + hits += 1; + var log_buf: [4096]u8 = undefined; + const log_path = try std.fmt.bufPrint(&log_buf, "{s}/seed-{d}.log", .{ out, seed }); + const both = try std.mem.concat(gpa, u8, &.{ crashes, run.stdout, run.stderr }); + defer gpa.free(both); + try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = log_path, .data = both }); + std.debug.print("PANIC seed {d}: {s}\n", .{ seed, path }); + } else if (!keep) { + std.Io.Dir.cwd().deleteFile(io, path) catch {}; + std.Io.Dir.cwd().deleteFile(io, golden_path) catch {}; + std.debug.print("ok seed {d}\n", .{seed}); + } else { + std.debug.print("ok seed {d} (kept)\n", .{seed}); + } + } + std.debug.print("{d} of {d} seeds panicked; kept in {s}\n", .{ hits, seeds, out }); + if (hits != 0) std.process.exit(1); +} -- cgit v1.3 From 4881c5d13c6a705a8c8bdb0181c33f9a500b5a74 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 00:23:55 -0300 Subject: Columns are named by stable serials over 9P, as panes are /col/ named a column by its index, which shifts when a column left of it closes: exactly what scripts trip on. A column is now /col/, its serial kept while it lives and never reused; /layout lines give serial and index (` ...`), active names the serial, /index's last field is the column's serial, and the log says newcol and delcol with serials. Docs, the skill and the tree's README say so. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 6 +-- README.md | 2 +- docs/fs.md | 23 ++++----- src/fs-help.txt | 6 +-- src/layout.zig | 13 +++--- src/ninep/cols.zig | 98 +++++++++++++++++++++++---------------- src/ninep/events.zig | 2 +- src/ninep/pane.zig | 15 +++--- src/ninep/tree.zig | 49 +++++++++++--------- 9 files changed, 120 insertions(+), 94 deletions(-) (limited to 'README.md') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index a5447991..8c383962 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -52,7 +52,7 @@ match this document, that session predates the change; restart it. ``` $m/README the served guide, worth reading first -$m/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name, column +$m/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name, column serial $m/status pid, version, panes $m/look write a line = a right click on it at the active pane (file:/re/, file:#n, :/re/ select by address, as acme's look, from the file's dot: file:0/re/ for the @@ -82,8 +82,8 @@ $m/ctl the settings, one a line as a write takes them; write a setting or a pane's builtins (Del, Save f, Collapse, which folds that pane, and the column word Delcol, which closes that pane's column) go to $m/pane//ctl $m/commands every builtin: `Word`, `Word arg`, then `root` or `pane` (which ctl takes it) -$m/layout one line per column: index x width current|notcurrent empty|full serials...; active -$m/tag the workspace tag (> replaces, >> appends, one line); $m/col//tag a column's, n from 0 +$m/layout one line per column: serial index x width current|notcurrent empty|full pane-serials...; active +$m/tag the workspace tag (> replaces, >> appends, one line); $m/col//tag a column's (serials stay, as panes' do) $m/pane/new open it to make a pane (a scratch named /+New), read names it; it goes in the ACTIVE column (the one last typed or clicked in, or Newcol's), filling it if empty, else taking the bottom half of its last pane (ctl `Placement pardes`: the old rules); diff --git a/README.md b/README.md index e487bf9c..72cfcbb0 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ mounted through kernel v9fs. It asks sudo in that pane, then starts your shell as your normal user. Access the tree through `$PARDES_MOUNT`. See [mounted terminals](docs/v9fs.md). Beyond acme's per-window files the tree serves the layout: `/layout` lists the columns, their places and panes, and -`/tag` and `/col//tag` are the workspace and column tags, editable like a +`/tag` and `/col//tag` are the workspace and column tags, editable like a window's ([the tree](docs/fs.md#the-served-tree)). ## Requirements diff --git a/docs/fs.md b/docs/fs.md index 5f382e7e..fd18d523 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -92,7 +92,7 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. ``` /README this guide, also src/fs-help.txt -/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name, column +/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name, column serial /status pid, version and pane count /look write a line: a right click on it at the active pane; read: the serials the last look, exec or ctl write touched (made, else acted at) @@ -105,10 +105,10 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. /focus the serial of the pane with the keyboard; write a serial to give it the keyboard /ctl the settings, one a line as a write takes them; write a setting or a session builtin /commands every builtin: word, `arg` if it takes one, `root` or `pane` (the ctl that takes it), a setting's values -/layout one line per column: index x width current|notcurrent empty|full serials...; - then active (- when no column has the keyboard) +/layout one line per column, left to right: serial index x width current|notcurrent + empty|full pane-serials...; then active (- when no column has the keyboard) /tag the workspace tag; > replaces it, >> appends, one line -/col//tag column n's tag, the same way; columns count from 0, left to right +/col//tag the tag of the column with serial n, the same way /pane/new open it to make a pane; the read answers that pane's serial /pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll errors event look exec, plus pty/{ctl,status,data} on terminals @@ -118,13 +118,14 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. `/layout`, `/tag` and `/col` go past acme, which serves no column files -- its columns are only where a window sits. They are here so a script can see -where the panes are (`/index`'s last word is each one's column, the same -index) and edit the tags a person clicks in: a column tag is one line, a -newline written into it a space, and a truncating write (`echo Make > -col/0/tag`) clears it and drops the newline that ends it, as a pane tag's -does. A column is named by its index, so the columns right of one that -closes move down one; the log says `newcol ` and `delcol ` as they come -and go, with /layout to read again. +where the panes are (`/index`'s last word is each one's column serial) and +edit the tags a person clicks in: a column tag is one line, a newline +written into it a space, and a truncating write (`echo Make > col/3/tag`) +clears it and drops the newline that ends it, as a pane tag's does. A +column is named by its serial, as a pane is: it stays while the column +lives, whatever opens or closes beside it, and is never reused; /layout +gives each column's serial and its index left to right, and the log says +`newcol ` and `delcol ` as columns come and go. Control messages are split by what they act on, as acme keeps window verbs on a window's ctl and webfs and upas/fs keep session settings on a root ctl. diff --git a/src/fs-help.txt b/src/fs-help.txt index 2f944c8e..50dc5d9c 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -1,7 +1,7 @@ Pardes control filesystem ========================= README this guide -index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name (+New if unnamed), column +index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name (+New if unnamed), column serial status pid, version and pane count look write a line: a right click on it at the active pane; read: the serials it touched exec write a line: a middle click, an editor command word or a shell line; read the same @@ -11,9 +11,9 @@ listeners the session's dial addresses focus the serial of the pane with the keyboard (empty on a column tag); write a serial to give it the keyboard ctl settings, one a line; or Newcol (an empty column), Dump, Exit (quits, asks once), Kill [w] (stops what pardes ran, w: by first word) commands every builtin: its word, arg if it takes one, and root or pane: which ctl takes it -layout one line per column: index x width current|notcurrent empty|full serials...; then active +layout one line per column: serial index x width current|notcurrent empty|full pane-serials...; then active tag the workspace tag: read it, > replaces it, >> appends (one line) -col//tag a column's tag, the same way (columns count from 0, as in layout) +col//tag the tag of the column with serial n, the same way (a serial stays while the column lives) pane/new open it to make a pane (named +New) in the active column, filling it if empty; the read answers its serial pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll errors (write-only: appended to its directory's +Errors pane) event look exec, pty/ on terminals; rmdir closes diff --git a/src/layout.zig b/src/layout.zig index 25c95d30..b9b24e79 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -322,6 +322,7 @@ pub fn removePane(p: *Pardes, id: usize) void { /// it (the first column's to its right), as acme's rowclose gives it. pub fn dropColumn(p: *Pardes, c: usize) void { std.debug.assert(p.col_n[c] == 0); + const serial = columnSerial(p, c); tagline.exitHeader(p); if (p.ncol > 1) p.col_weight[if (c > 0) c - 1 else c + 1] +|= p.col_weight[c]; p.col_tags[c].deinit(p.gpa); @@ -336,14 +337,14 @@ pub fn dropColumn(p: *Pardes, c: usize) void { p.ncol -= 1; p.col_tags[p.ncol] = .{ .what = .column, .gpa = p.gpa }; p.col_serial[p.ncol] = 0; - noteColumn(p, "delcol", c); + noteColumn(p, "delcol", serial); } -/// `newcol ` or `delcol ` in the log: the index, as /layout and -/// /col number columns, the ones after it moving up or down one. -fn noteColumn(p: *Pardes, what: []const u8, c: usize) void { +/// `newcol ` or `delcol ` in the log: the column's serial, +/// as /layout and /col name it. +fn noteColumn(p: *Pardes, what: []const u8, serial: u32) void { var buf: [16]u8 = undefined; - pardes.ctlfs.events.notePath(p, what, std.fmt.bufPrint(&buf, "{d}", .{c}) catch return); + pardes.ctlfs.events.notePath(p, what, std.fmt.bufPrint(&buf, "{d}", .{serial}) catch return); } /// Fold column `c` into the one on its right, its panes below theirs. @@ -499,7 +500,7 @@ pub fn insertColumn(p: *Pardes, col: usize, before: bool) ?usize { p.col_serial[c] = 0; p.col_n[c] = 0; p.ncol += 1; - noteColumn(p, "newcol", c); + noteColumn(p, "newcol", columnSerial(p, c)); return c; } diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig index e1688517..682c2a02 100644 --- a/src/ninep/cols.zig +++ b/src/ninep/cols.zig @@ -1,5 +1,6 @@ //! The layout and the header tags: /layout, /tag (the workspace's) and -//! /col//tag (each column's). acme serves no column files -- its columns +//! /col//tag (each column's; a column's serial stays while it lives, +//! as a pane's does). acme serves no column files -- its columns //! are only a window's place -- so these go past it: a script can see where //! the panes are and edit the tags a person clicks in. const std = @import("std"); @@ -22,42 +23,48 @@ pub fn activeColumn(p: *const Pardes) ?usize { return at.col; } -/// One line a column: its index, x and width in cells, `current` or -/// `notcurrent` (rio's words, for the column with the keyboard), `empty` or -/// `full`, and its panes' serials, top to bottom; then `active `. -pub fn writeLayout(p: *const Pardes, w: *std.Io.Writer) !void { +/// One line a column: its serial (the name /col/ and the log give +/// it, which stays while it lives), its index left to right, x and width in +/// cells, `current` or `notcurrent` (rio's words, for the column with the +/// keyboard), `empty` or `full`, and its panes' serials, top to bottom; +/// then `active `. +pub fn writeLayout(p: *Pardes, w: *std.Io.Writer) !void { const active = activeColumn(p); for (0..p.ncol) |c| { - try w.print("{d} {d} {d} {s} {s}", .{ - c, p.col_x[c], p.col_w[c], + try w.print("{d} {d} {d} {d} {s} {s}", .{ + layout.columnSerial(p, c), c, p.col_x[c], p.col_w[c], if (active == c) "current" else "notcurrent", if (p.col_n[c] == 0) "empty" else "full", }); for (p.col_panes[c][0..p.col_n[c]]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial}); try w.writeByte('\n'); } - if (active) |c| try w.print("active {d}\n", .{c}) else try w.writeAll("active -\n"); + if (active) |c| try w.print("active {d}\n", .{layout.columnSerial(p, c)}) else try w.writeAll("active -\n"); } -pub fn layoutLen(p: *const Pardes) u64 { +pub fn layoutLen(p: *Pardes) u64 { var buf: [256]u8 = undefined; var counting: std.Io.Writer.Discarding = .init(&buf); writeLayout(p, &counting.writer) catch return 0; return counting.fullCount(); } -/// The header a node names: the workspace's (`col` null) or a column's. -fn header(p: *Pardes, col: ?usize) ?*Text { - const c = col orelse return &p.global_tag; - return if (c < p.ncol) &p.col_tags[c] else null; +/// A header by its node: the workspace's (`serial` null) or the column's +/// with that serial; null when that column has closed. +const Header = struct { text: *Text, col: ?usize }; + +fn header(p: *Pardes, serial: ?u32) ?Header { + const s = serial orelse return .{ .text = &p.global_tag, .col = null }; + const c = layout.columnBySerial(p, s) orelse return null; + return .{ .text = &p.col_tags[c], .col = c }; } -pub fn headerText(p: *Pardes, col: ?usize) ?[]const u8 { - const c = col orelse return tagline.topbar(p); - return if (c < p.ncol) tagline.columnTag(p, c) else null; +pub fn headerText(p: *Pardes, serial: ?u32) ?[]const u8 { + const h = header(p, serial) orelse return null; + return if (h.col) |c| tagline.columnTag(p, c) else tagline.topbar(p); } -pub fn read(p: *Pardes, req: Req, col: ?usize) Reply { - const text = headerText(p, col) orelse return Reply.fail(req.tag, E.NOENT); +pub fn read(p: *Pardes, req: Req, serial: ?u32) Reply { + const text = headerText(p, serial) orelse return Reply.fail(req.tag, E.NOENT); const out = p.fs.stage(p.gpa); out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); out.append(p.gpa, '\n') catch return Reply.fail(req.tag, E.NOMEM); @@ -67,12 +74,12 @@ pub fn read(p: *Pardes, req: Req, col: ?usize) Reply { /// A write appends, as a pane tag's does; the tag is one line, so a newline /// in it becomes a space (tagline.flattenHeaders), but after a truncation /// the newline that ends the write is dropped, as a pane tag drops it. -pub fn write(p: *Pardes, req: Req, col: ?usize) Reply { - const t = header(p, col) orelse return Reply.fail(req.tag, E.NOENT); +pub fn write(p: *Pardes, req: Req, serial: ?u32) Reply { + const t = (header(p, serial) orelse return Reply.fail(req.tag, E.NOENT)).text; if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; - const was = headerText(p, col).?; + const was = headerText(p, serial).?; var data = req.data; - const rewriting = p.fs.header_rewrite == rewriteKey(col); + const rewriting = p.fs.header_rewrite == rewriteKey(serial); // A newline held from the write before goes in once more text follows. const held: []const u8 = if (rewriting and p.fs.header_held) " " else ""; p.fs.header_held = false; @@ -89,27 +96,27 @@ pub fn write(p: *Pardes, req: Req, col: ?usize) Reply { /// Truncating clears it, as a pane tag's `cleartag`: its default words go /// too, and `u` in it brings them back. -pub fn truncate(p: *Pardes, col: ?usize) tree.Status { - const t = header(p, col) orelse return .err; +pub fn truncate(p: *Pardes, serial: ?u32) tree.Status { + const t = (header(p, serial) orelse return .err).text; const empty = p.gpa.alloc(u8, 0) catch return .err; t.remember(p.gpa, if (t.own) |own| .{ .text = own } else null); if (t.own) |own| p.gpa.free(own); t.own = empty; t.cur_row = 0; t.cur_col = 0; - p.fs.header_rewrite = rewriteKey(col); + p.fs.header_rewrite = rewriteKey(serial); p.fs.header_held = false; return .ok; } -/// Which header a truncation was of: the workspace's is 0, a column's its -/// index + 1. -fn rewriteKey(col: ?usize) u32 { - return if (col) |c| @intCast(c + 1) else 0; +/// Which header a truncation was of: the workspace's is 0 (no column's +/// serial is), a column's its serial. +fn rewriteKey(serial: ?u32) u32 { + return serial orelse 0; } -pub fn released(p: *Pardes, col: ?usize) void { - if (p.fs.header_rewrite != rewriteKey(col)) return; +pub fn released(p: *Pardes, serial: ?u32) void { + if (p.fs.header_rewrite != rewriteKey(serial)) return; p.fs.header_rewrite = null; p.fs.header_held = false; } @@ -125,28 +132,39 @@ test "layout lists each column's place, panes and state, and the active one" { defer p.deinit(); p.newColumn(p.active); p.sync(); + const first_serial = layout.columnSerial(p, 0); + const new_serial = layout.columnSerial(p, 1); + try testing.expect(first_serial != new_serial); const layout_node = @intFromEnum(tree.TopFile.layout); const text = th.rd(p, layout_node, 0, 4096).bytes; var want: [256]u8 = undefined; - const first = try std.fmt.bufPrint(&want, "0 {d} {d} notcurrent full {d}\n", .{ p.col_x[0], p.col_w[0], p.panes[0].?.serial }); + const first = try std.fmt.bufPrint(&want, "{d} 0 {d} {d} notcurrent full {d}\n", .{ first_serial, p.col_x[0], p.col_w[0], p.panes[0].?.serial }); try testing.expect(std.mem.startsWith(u8, text, first)); // Newcol gives the new, empty column's tag the keyboard. try testing.expect(std.mem.indexOf(u8, text, "current empty\n") != null); - try testing.expect(std.mem.endsWith(u8, text, "active 1\n")); + try testing.expect(std.mem.endsWith(u8, text, try std.fmt.bufPrint(&want, "active {d}\n", .{new_serial}))); try testing.expectEqual(@as(u64, text.len), th.call(p, .{ .tag = 1, .op = .getattr, .node = layout_node }).reply.attr.size); - // /index says which column each pane is in, last. - try testing.expect(std.mem.endsWith(u8, th.rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, " 0\n")); - try testing.expect(th.logHas(p, "newcol 1\n")); + // /index says which column each pane is in, by its serial, last. + try testing.expect(std.mem.endsWith(u8, th.rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, try std.fmt.bufPrint(&want, " {d}\n", .{first_serial}))); + try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "newcol {d}\n", .{new_serial}))); + // A column that closes takes its name with it; the others keep theirs. + try p.removeColumn(1); + try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "delcol {d}\n", .{new_serial}))); + try testing.expectEqual(E.NOENT, th.look_up(p, @intFromEnum(tree.TopFile.col), try std.fmt.bufPrint(&want, "{d}", .{new_serial})).errno()); + try testing.expectEqual(first_serial, layout.columnSerial(p, 0)); } test "a column's tag and the workspace's read, replace and append as a pane tag does, on one line" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); const col_dir = @intFromEnum(tree.TopFile.col); - try testing.expectEqual(tree.Status.ok, th.look_up(p, col_dir, "0").reply.status); - try testing.expectEqual(E.NOENT, th.look_up(p, col_dir, "7").errno()); - const tag = Node.ofCol(0, .tag); - try testing.expectEqual(tree.Status.ok, th.look_up(p, Node.ofCol(0, .dir), "tag").reply.status); + const serial = layout.columnSerial(p, 0); + var name: [16]u8 = undefined; + try testing.expectEqual(tree.Status.ok, th.look_up(p, col_dir, try std.fmt.bufPrint(&name, "{d}", .{serial})).reply.status); + try testing.expectEqual(E.NOENT, th.look_up(p, col_dir, "0").errno()); + try testing.expectEqual(E.NOENT, th.look_up(p, col_dir, "777").errno()); + const tag = Node.ofCol(serial, .tag); + try testing.expectEqual(tree.Status.ok, th.look_up(p, Node.ofCol(serial, .dir), "tag").reply.status); try testing.expectEqualStrings("New Tty Find Grep Joincol Delcol\n", th.rd(p, tag, 0, 4096).bytes); // `echo Make > tag`: cleared, then the newline ending the write dropped. _ = th.call(p, .{ .tag = 1, .op = .setattr, .node = tag, .truncate = true }); diff --git a/src/ninep/events.zig b/src/ninep/events.zig index fc410d5a..e918f09a 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -174,7 +174,7 @@ pub fn noteError(p: *Pardes, req: Req, reply: Reply) void { .top => |f| file = f.fileName(), .col => |c| { serial = "-"; - file = std.fmt.bufPrint(&name, "col/{d}/tag", .{c.index}) catch "col"; + file = std.fmt.bufPrint(&name, "col/{d}/tag", .{c.serial}) catch "col"; }, .pane => |pt| { serial = std.fmt.bufPrint(&name, "{d}", .{pt.serial}) catch "-"; diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 6542d747..c594c7a3 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -265,10 +265,11 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { // ---- the index ---- -/// The column a pane is in, as /layout and /col number them; the last word -/// of its /index line. -pub fn columnOf(p: *const Pardes, id: usize) usize { - return if (pardes.layout.findPane(p, id)) |at| at.col else 0; +/// The serial of the column a pane is in, as /layout and /col name it; the +/// last word of its /index line. +pub fn columnOf(p: *Pardes, id: usize) u32 { + const at = pardes.layout.findPane(p, id) orelse return 0; + return pardes.layout.columnSerial(p, at.col); } pub fn indexLen(p: *Pardes) u64 { @@ -710,7 +711,7 @@ test "index lists serial kind dirty flag and name and stat reports its length" { const a = rd(p, index, 0, 4096); try testing.expectEqual(Status.ok, a.reply.status); var want: [64]u8 = undefined; - const clean_row = try std.fmt.bufPrint(&want, "{d} text 0 /test.txt 0\n", .{pane.serial}); + const clean_row = try std.fmt.bufPrint(&want, "{d} text 0 /test.txt {d}\n", .{ pane.serial, columnOf(p, 0) }); try testing.expect(std.mem.indexOf(u8, a.bytes, clean_row) != null); const at = std.mem.indexOf(u8, a.bytes, clean_row).?; const stat = call(p, .{ .tag = 1, .op = .getattr, .node = index }); @@ -719,7 +720,7 @@ test "index lists serial kind dirty flag and name and stat reports its length" { pane.file.?.saved_revision = pane.file.?.revision -% 1; var dirty_want: [64]u8 = undefined; - const dirty_row = try std.fmt.bufPrint(&dirty_want, "{d} text 1 /test.txt 0\n", .{pane.serial}); + const dirty_row = try std.fmt.bufPrint(&dirty_want, "{d} text 1 /test.txt {d}\n", .{ pane.serial, columnOf(p, 0) }); try testing.expect(std.mem.indexOf(u8, rd(p, index, 0, 4096).bytes, dirty_row) != null); const kind = at + std.mem.indexOfScalar(u8, clean_row, ' ').? + 1; try testing.expectEqualStrings("text", rd(p, index, kind, 4).bytes); @@ -741,7 +742,7 @@ test "a terminal is listed as term with its directory as name" { try testing.expect(std.mem.indexOf( u8, rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, - try std.fmt.bufPrint(&want, "{d} term 0 /work/dir 0\n", .{pane.serial}), + try std.fmt.bufPrint(&want, "{d} term 0 /work/dir {d}\n", .{ pane.serial, columnOf(p, 0) }), ) != null); try testing.expectEqualStrings("/work/dir\n", rd(p, Node.of(pane.serial, .name), 0, 4096).bytes); const refused = wr(p, Node.of(pane.serial, .name), "/elsewhere\n"); diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 9459be4f..3be75960 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -19,6 +19,7 @@ pub const pane = @import("pane.zig"); pub const addr = @import("addr.zig"); pub const ctl = @import("ctl.zig"); pub const cols = @import("cols.zig"); +const layout = pardes.layout; pub const pty = @import("pty.zig"); pub const sources = @import("sources.zig"); pub const screen = @import("screen.zig"); @@ -268,8 +269,9 @@ pub const PaneFile = enum(u5) { } }; -/// /col/ and its tag: a column is named by its index, which a serial -/// never is (serials are 32 bits; this bit is past them). +/// /col/ and its tag: a column is named by its serial, which stays +/// while it lives as a pane's does; this bit, past a pane serial's 32, keeps +/// the two apart. pub const ColFile = enum(u5) { dir = 0, tag = 1 }; const col_bit: u59 = 1 << 58; @@ -282,8 +284,8 @@ pub const Node = packed struct(u64) { return @bitCast(Node{ .file = @intFromEnum(file), .serial = serial }); } - pub fn ofCol(index: usize, file: ColFile) u64 { - return @bitCast(Node{ .file = @intFromEnum(file), .serial = col_bit | @as(u59, @intCast(index)) }); + pub fn ofCol(serial: u32, file: ColFile) u64 { + return @bitCast(Node{ .file = @intFromEnum(file), .serial = col_bit | @as(u59, serial) }); } pub fn target(node: u64) ?Target { @@ -292,7 +294,7 @@ pub const Node = packed struct(u64) { return .{ .top = std.enums.fromInt(TopFile, n.file) orelse return null }; } if (n.serial & col_bit != 0) return .{ .col = .{ - .index = std.math.cast(u32, n.serial & ~col_bit) orelse return null, + .serial = std.math.cast(u32, n.serial & ~col_bit) orelse return null, .file = std.enums.fromInt(ColFile, n.file) orelse return null, } }; return .{ .pane = .{ @@ -305,7 +307,7 @@ pub const Node = packed struct(u64) { pub const Target = union(enum) { top: TopFile, pane: struct { serial: u32, file: PaneFile }, - col: struct { index: u32, file: ColFile }, + col: struct { serial: u32, file: ColFile }, }; /// Opening /pane/new makes a pane and reading the open fid answers its @@ -450,13 +452,13 @@ fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { .append = f == .tag, }, .col => |c| { - if (c.index >= p.ncol) return null; + if (layout.columnBySerial(p, c.serial) == null) return null; return .{ - .name = if (c.file == .dir) (std.fmt.bufPrint(&p.fs.node_name, "{d}", .{c.index}) catch unreachable) else "tag", - .node = Node.ofCol(c.index, c.file), + .name = if (c.file == .dir) (std.fmt.bufPrint(&p.fs.node_name, "{d}", .{c.serial}) catch unreachable) else "tag", + .node = Node.ofCol(c.serial, c.file), .dir = c.file == .dir, .mode = if (c.file == .dir) 0o755 else 0o666, - .size = if (c.file == .tag) cols.headerText(p, c.index).?.len + 1 else 0, + .size = if (c.file == .tag) cols.headerText(p, c.serial).?.len + 1 else 0, .mtime = p.fs.started, .append = c.file == .tag, }; @@ -548,18 +550,20 @@ fn lookup(p: *Pardes, req: Req, target: Target) Reply { if (serial == 0) return Reply.fail(req.tag, E.NOENT); break :pane Node.of(serial, .dir); }, - // A column is its index, in decimal digits. + // A column is its serial, in decimal digits and never 0. .col => col: { - if (name.len > 4) return Reply.fail(req.tag, E.NOENT); + if (name.len > 10) return Reply.fail(req.tag, E.NOENT); for (name) |c| if (c < '0' or c > '9') return Reply.fail(req.tag, E.NOENT); - break :col Node.ofCol(std.fmt.parseInt(u32, name, 10) catch return Reply.fail(req.tag, E.NOENT), .dir); + const serial = std.fmt.parseInt(u32, name, 10) catch return Reply.fail(req.tag, E.NOENT); + if (serial == 0) return Reply.fail(req.tag, E.NOENT); + break :col Node.ofCol(serial, .dir); }, else => return Reply.fail(req.tag, E.NOTDIR), }, .col => |c| col: { if (c.file != .dir) return Reply.fail(req.tag, E.NOTDIR); if (!std.mem.eql(u8, name, "tag")) return Reply.fail(req.tag, E.NOENT); - break :col Node.ofCol(c.index, .tag); + break :col Node.ofCol(c.serial, .tag); }, .pane => |t| pane: { _ = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); @@ -626,14 +630,15 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { continue; } var buf: [16]u8 = undefined; - stageDirent(out, p.gpa, Node.ofCol(c, .dir), true, std.fmt.bufPrint(&buf, "{d}", .{c}) catch unreachable); + const serial = layout.columnSerial(p, c); + stageDirent(out, p.gpa, Node.ofCol(serial, .dir), true, std.fmt.bufPrint(&buf, "{d}", .{serial}) catch unreachable); }, else => return Reply.fail(req.tag, E.NOTDIR), }, .col => |c| { - if (c.index >= p.ncol) return Reply.fail(req.tag, E.NOENT); + if (layout.columnBySerial(p, c.serial) == null) return Reply.fail(req.tag, E.NOENT); if (c.file != .dir) return Reply.fail(req.tag, E.NOTDIR); - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, Node.ofCol(c.index, .tag), false, "tag"); + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, Node.ofCol(c.serial, .tag), false, "tag"); }, .pane => |t| { const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); @@ -668,7 +673,7 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { .log => .{ .log = .{} }, else => return .{ .tag = req.tag }, }, - .col => |c| return if (c.index < p.ncol) .{ .tag = req.tag } else Reply.fail(req.tag, E.NOENT), + .col => |c| return if (layout.columnBySerial(p, c.serial) != null) .{ .tag = req.tag } else Reply.fail(req.tag, E.NOENT), .pane => |t| what: { const pn = p.panes[p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT)].?; if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); @@ -749,7 +754,7 @@ fn releaseHandle(p: *Pardes, req: Req) void { p.panes[id].?.fs.tag_rewrite = false; p.panes[id].?.fs.tag_held_newline = false; }; - if (t == .col and t.col.file == .tag) cols.released(p, t.col.index); + if (t == .col and t.col.file == .tag) cols.released(p, t.col.serial); if (t == .top and t.top == .tag) cols.released(p, null); const o = openOf(p, req) orelse return; const of: ?*Pane = if (t == .pane) (if (p.paneBySerial(t.pane.serial)) |id| p.panes[id] else null) else null; @@ -786,7 +791,7 @@ fn setattr(p: *Pardes, req: Req, target: Target) Reply { return failText(req.tag, E.INVAL, pane.e_addr_failed); if (pane.truncate(p, p.panes[id].?, t.file) != .ok) return Reply.fail(req.tag, E.NOMEM); }, - .col => |c| if (c.file == .tag and cols.truncate(p, c.index) != .ok) return Reply.fail(req.tag, E.NOENT), + .col => |c| if (c.file == .tag and cols.truncate(p, c.serial) != .ok) return Reply.fail(req.tag, E.NOENT), .top => |f| if (f == .tag and cols.truncate(p, null) != .ok) return Reply.fail(req.tag, E.NOMEM), }; return .{ .tag = req.tag, .attr = attrOf(p, target) orelse return Reply.fail(req.tag, E.NOENT) }; @@ -877,7 +882,7 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); return pane.read(p, req, id, pn, t.file); }, - .col => |c| return if (c.file == .tag) cols.read(p, req, c.index) else Reply.fail(req.tag, E.PERM), + .col => |c| return if (c.file == .tag) cols.read(p, req, c.serial) else Reply.fail(req.tag, E.PERM), } } @@ -897,7 +902,7 @@ fn write(p: *Pardes, req: Req, target: Target) Reply { if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); return pane.write(p, req, id, pn, t.file); }, - .col => |c| return if (c.file == .tag) cols.write(p, req, c.index) else Reply.fail(req.tag, E.PERM), + .col => |c| return if (c.file == .tag) cols.write(p, req, c.serial) else Reply.fail(req.tag, E.PERM), } } -- cgit v1.3 From f0c947bd1b1e6e172b11f007d7bdeff2d6599e03 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 23:19:54 -0300 Subject: config-test goes: config.zig is the core now, and core-test runs its tests config.zig imports pardes.zig and builtins.zig, so it cannot be compiled "without the editor" any more; the step failed with 40 missing-module errors (zls, uucode, cloud9, mupdf, ...). Its two tests (Space-k unbound, wheel drift guard) already run in core-test, checked with -Dtest-filter. Wiring every core import into it would only rebuild core-test for two tests. Co-Authored-By: Claude Opus 5.5 --- README.md | 1 - build.zig | 12 ------------ 2 files changed, 13 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 267b5ca7..d2f3d995 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,6 @@ zig build test-build compile the unit-test programs without running them zig build unit-profile test request time and process memory as JSONL zig build unit-profile-test profiler timing, failure and timeout checks zig build core-test core tests without native shell tests -zig build config-test configuration tests without compiling the editor zig build pane-test pane and namespace integration tests zig build syntax-test tree-sitter tests without building the editor zig build syntax deterministic per-byte highlighting snapshots diff --git a/build.zig b/build.zig index 3c1447eb..4a478ac5 100644 --- a/build.zig +++ b/build.zig @@ -1375,18 +1375,6 @@ pub fn build(b: *std.Build) void { lspbench_test_step.dependOn(&run_lspbench_tests.step); lspbench_check_step.dependOn(&run_lspbench_tests.step); if (testMatch(b, unit_profile, test_filters, lspbench_test_step)) |check| check.addArtifactArg(lspbench_tests); - const config_module = b.createModule(.{ - .target = target, - .optimize = optimize, - .root_source_file = b.path("src/config.zig"), - }); - config_module.addImport("pardes_config", core_module.import_table.get("pardes_config").?); - const config_tests = b.addTest(.{ .root_module = config_module, .filters = test_filters }); - const run_config_tests = b.addRunArtifact(config_tests); - run_config_tests.has_side_effects = true; - const config_test_step = b.step("config-test", "run configuration tests without compiling the editor"); - config_test_step.dependOn(&run_config_tests.step); - if (testMatch(b, unit_profile, test_filters, config_test_step)) |check| check.addArtifactArg(config_tests); const diff_tests = b.addTest(.{ .root_module = hxdiff.root_module, .filters = test_filters }); const run_diff_tests = b.addRunArtifact(diff_tests); run_diff_tests.has_side_effects = true; -- cgit v1.3 From 2d0c506583d18d6f004fc117282deb2faea1d17e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 10:30:38 -0300 Subject: Recent lists the files opened lately, closed ones too, and a jump back to a closed file reopens it A file closed by accident, its path forgotten, could not be found again: the jumplist dropped closed panes. Every file opened (a look, a Save of a scratch, a Restore, a rename) goes first in a list of 200, kept once, its dot noted when it closes, kept across sessions in $XDG_STATE_HOME/pardes/ recent. `Recent` (SPC f r) shows it in a reused +Recent, each row `path:line:col open|closed` a look reopens; /recent reads `open|closed `. The jumplist keeps a closed file's entries, +Jumps marks them `(closed)`, and Back to one opens the file at its place. acme has no such thing; its dump and Load are the nearest. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 2 + README.md | 19 ++++++ docs/fs.md | 5 ++ docs/helix-keys.md | 2 +- src/Output.zig | 49 ++++++++++++++++ src/builtins.zig | 10 ++++ src/config.zig | 2 + src/fs-help.txt | 4 +- src/main.zig | 16 +++++ src/ninep/ctl.zig | 54 +++++++++++++++++ src/ninep/events.zig | 2 + src/ninep/pane.zig | 1 + src/ninep/tree.zig | 31 +++++++--- src/pardes.zig | 104 ++++++++++++++++++++++++++++++++- src/recent.zig | 119 ++++++++++++++++++++++++++++++++++++++ test/fs.py | 28 ++++++++- 16 files changed, 434 insertions(+), 14 deletions(-) create mode 100644 src/recent.zig (limited to 'README.md') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 0575fab7..4678d55a 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -96,6 +96,8 @@ $m/ctl the settings, one a line as a write takes them; write a setting or column word Delcol, which closes that pane's column) go to $m/pane//ctl $m/commands every builtin: `Word`, `Word arg`, then `root`, `pane` or `both` (which ctl takes it), a setting's values comma-joined, then ` -- ` and one sentence of what it does +$m/recent files opened lately, closed ones too, most recent first: `open|closed `; + lost a file you closed? read this, or run Recent and look at its row to reopen it $m/layout one line per column (16 columns at most: Newcol past that fails, no space for a column): serial index x width current|notcurrent empty|full pane-serials...; active $m/tag the workspace tag (> replaces, >> appends, one line); $m/col//tag a column's (serials stay, as panes' do) $m/tagexec a word as a click in the workspace tag (pane//tagexec: in that pane's tag); every exec diff --git a/README.md b/README.md index 49ecfa4d..826f86c8 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,25 @@ pane shells outlive every frontend; a frontend keeps only what needs the human's own display. From inside the editor, `Attach` and `Detach` do the same thing as words. See `docs/detached.md`. +## Recent files + +A file closed by accident is found again. `Recent` (`SPC f r`) lists the +files opened lately, most recent first, closed ones too, each marked `open` +or `closed` at the place its dot was when it closed: + +``` +/home/me/src/main.zig:120:5 closed +/home/me/notes.txt open +``` + +A look at a row opens that file there. The list keeps 200 files, each once, +and lasts across sessions in `$XDG_STATE_HOME/pardes/recent` (else +`~/.local/state/pardes/recent`). The jumplist keeps a closed file's entries +too: `Back` to one opens the file again at its place, and `+Jumps` marks it +`(closed)`. Over 9P, `/recent` reads `open ` or `closed ` a line. +acme has nothing like it (its dump and Load are the nearest); pardes goes +beyond acme here. + ## Tests ``` diff --git a/docs/fs.md b/docs/fs.md index a0b3dcf7..dedfe94f 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -125,6 +125,11 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. /commands every builtin: word, `arg` if it takes one, `root`, `pane` or `both` (the ctl that takes it: Edit is both, at the active pane from the root; a pane's word such as Undo or Msg is refused at the root), a setting's values, then ` -- ` and what it does +/recent the files opened lately, closed ones too, most recent first, a line each: + `open ` or `closed ` (read-only; `Recent` shows them in a pane, + a look at a row reopening the file at its last dot; kept across sessions + in $XDG_STATE_HOME/pardes/recent, 200 files; acme has none, its dump and + Load the nearest) /layout one line per column (16 at most; the board 6; Newcol past that fails, `no space for a column: 16 max`, ENOSPC), left to right: serial index x width current|notcurrent (the column with the keyboard now) empty|full pane-serials...; then active diff --git a/docs/helix-keys.md b/docs/helix-keys.md index 8874bf08..5d89ba92 100644 --- a/docs/helix-keys.md +++ b/docs/helix-keys.md @@ -143,7 +143,7 @@ language-backend queries, and the shell pipe. | `gd` `gD` `gy` `gi` `gr` | LSP definition / declaration / type-definition / implementation / references. ONE answer jumps straight there; several fill `+Search`, where n/N walk and Enter opens | in-process ZLS (`src/lsp/lsp_zls.zig`), `.zig` only — on a file the backend does not speak these do nothing at all, with no error row. Ctrl+left-click is the mouse spelling of `gd` | out of corpus | | `]d` `[d` / `]D` `[D` | step the diagnostics list / go to its last or first; if no list is up, asking the backend for one is part of the press | | out of corpus | | `=` | `format_selections` — writes a `- old` / `+ new` diff into `+Lsp` | deliberate divergence: the seam returns ROWS, not edits, so this SHOWS the formatting instead of applying it. Not in the corpus, so there is no waiver to name — the query leaves the core as an effect the headless harness has no shell to perform | out of corpus | -| `Ctrl-o` / `Ctrl-i` | jumplist back / forward (also Mouse4 / Mouse5 in SDL, macOS and web); successful navigation clears selections in both panes and places the cursor at the saved location; raw tty forwards both to the child — the `Back` / `Forward` builtins, also on `SPC j o` / `SPC j i`, with `SPC j l` rendering the stack as a buffer | helix binds both keys (`jump_backward` / `jump_forward`) but to a POSITION jumplist; pardes' stack is over panes and focus, so the keys agree and the semantics do not. `Ctrl-i` and Tab are the same byte under the legacy encoding; there Tab keeps meaning execute, and the pair only separates where the host speaks the kitty keyboard protocol | pardes-specific | +| `Ctrl-o` / `Ctrl-i` | jumplist back / forward (also Mouse4 / Mouse5 in SDL, macOS and web); successful navigation clears selections in both panes and places the cursor at the saved location; raw tty forwards both to the child — the `Back` / `Forward` builtins, also on `SPC j o` / `SPC j i`, with `SPC j l` rendering the stack as a buffer; a closed file's entry stays, marked `(closed)`, and a jump to it opens the file again at its place | helix binds both keys (`jump_backward` / `jump_forward`) but to a POSITION jumplist; pardes' stack is over panes and focus, so the keys agree and the semantics do not. `Ctrl-i` and Tab are the same byte under the legacy encoding; there Tab keeps meaning execute, and the pair only separates where the host speaks the kitty keyboard protocol | pardes-specific | | `\|` | pipe every selection through `/bin/sh -c`: its bytes in on stdin, its stdout replacing them, one undo across all cursors | helix's own key and meaning; the command is typed into the pane's tag after a bare `\|` marker rather than into a popup | out of corpus | | `A-\|` | the same, and the output is DISCARDED — the text is not touched at all | helix `shell_pipe_to`. For a command run for its effect. Marker `\|-` | out of corpus | | `!` | run with NO stdin, insert the output BEFORE each selection | helix `shell_insert_output`. Runs ONCE and every cursor gets that one answer, as helix does — ten cursors and `date` give ten identical stamps. Marker `!` | out of corpus | diff --git a/src/Output.zig b/src/Output.zig index 37d25168..dd6ab92a 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -505,6 +505,12 @@ pub fn openJumps(p: *Pardes, id: usize) !void { var out: std.Io.Writer.Allocating = .init(p.gpa); errdefer out.deinit(); for (p.jumps[0..p.njumps]) |j| { + // A closed file's entry: marked, and a look at it opens it again. + if (j.serial == 0) { + const e = p.recentByHash(j.path_hash) orelse continue; + try out.writer.print("{s}:{d}:{d} (closed)\n", .{ e.path, @max(1, j.line), @max(1, j.col) }); + continue; + } const jp = p.panes[j.pane] orelse continue; var idbuf: [16]u8 = undefined; const pdf_path: ?[]const u8 = if (comptime pardes.pdf_enabled) jp.pdfPath() else null; @@ -532,6 +538,49 @@ pub fn openJumps(p: *Pardes, id: usize) !void { try openStepped(p, id, .{ .cmd = .Jumplist }, content); } +/// The recent list as rows: `:: open|closed`, most recent +/// first; a look at a row opens the file there, as a +Jumps row does. +pub fn recentText(p: *Pardes, w: *std.Io.Writer, look_rows: bool) !void { + for (p.recent.entries.items) |e| { + var is_open = false; + for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.output == null and std.mem.eql(u8, f.path, e.path)) { + is_open = true; + }; + const state: []const u8 = if (is_open) "open" else "closed"; + if (!look_rows) + try w.print("{s} {s}\n", .{ state, e.path }) + else if (e.line == 0) + try w.print("{s} {s}\n", .{ e.path, state }) + else + try w.print("{s}:{d}:{d} {s}\n", .{ e.path, e.line, e.col, state }); + } +} + +/// Recent: the one +Recent, filled again when it is there (as Find and +/// Grep's +Search is), else opened below the asking pane. +pub fn openRecent(p: *Pardes, id: usize) !void { + var out: std.Io.Writer.Allocating = .init(p.gpa); + errdefer out.deinit(); + try recentText(p, &out.writer, true); + const content = try out.toOwnedSlice(); + for (p.panes, 0..) |slot, i| { + const rp = slot orelse continue; + const rf = if (rp.file) |*f| f else continue; + const o = rf.output orelse continue; + if (!std.meta.eql(o.from, Origin{ .cmd = .Recent })) continue; + File.setContent(p, rf, content); + resetBody(p, rp); + p.fs.refilled = rp.serial; + if (p.panes[id]) |pane| { + pane.search_pane = i; + pane.search_row = null; + } + look.armLookWalk(p, i); + return; + } + try openStepped(p, id, .{ .cmd = .Recent }, content); +} + pub fn openThemes(p: *Pardes, id: usize) !void { var out: std.Io.Writer.Allocating = .init(p.gpa); errdefer out.deinit(); diff --git a/src/builtins.zig b/src/builtins.zig index 7fdf2176..2247fcbb 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1447,6 +1447,7 @@ pub const Last = struct { while (i > 0) { i -= 1; const j = c.p.jumps[i]; + if (j.serial == 0) continue; // a closed file's: Back reopens it, Last goes to a pane // Restore the cursor without recentering the pane's retained view. if (j.pane != c.id) return look.focusPaneLine(c.p, j.pane, .{ .line = j.line, .col = j.col }, .keep); } @@ -1456,6 +1457,15 @@ pub const Last = struct { } }; +/// List the files opened lately, closed ones too, each a place to open again. +pub const Recent = struct { + pub const scope: Scope = .session; + pub const output: OutputTraits = .{ .name = config.recent_buffer, .steps = true, .locations = true }; + pub fn run(c: Ctx) void { + panes.Output.openRecent(c.p, c.id) catch |err| c.p.reportError(c.id, "recent", err); + } +}; + /// List the places jumped from, each a place to go. pub const Jumplist = struct { pub const scope: Scope = .session; diff --git a/src/config.zig b/src/config.zig index 229c70ea..c7ea5411 100644 --- a/src/config.zig +++ b/src/config.zig @@ -65,6 +65,7 @@ pub const leader_path = paths: { .New = "fn", .Tty = "nt", .Find = "ff", + .Recent = "fr", .Grep = "fg", .Config = "fc", .LocationsConfig = null, @@ -448,6 +449,7 @@ pub const help_buffer = "+Help"; pub const config_buffer = "+Config"; pub const effect_code_buffer = "+EffectCode"; pub const jumps_buffer = "+Jumps"; +pub const recent_buffer = "+Recent"; pub const themes_buffer = "+Themes"; pub const fonts_buffer = "+Fonts"; pub const pdf_sections_buffer = "+PdfSections"; diff --git a/src/fs-help.txt b/src/fs-help.txt index bd822b60..62d4ae48 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -11,11 +11,11 @@ listeners the session's dial addresses focus the serial of the pane with the keyboard (empty on a column tag); write a serial to give it the keyboard ctl settings a line; or Newcol, Dump, Restore [f], Exit (asks once), Kill [w], Placement acme|pardes, size C R (--detach) commands every builtin: word, arg if it takes one, root|pane|both (the ctl that takes it), -- what it does +recent files opened lately, closed ones too, most recent first: open|closed layout a line per column: serial index x width current|notcurrent empty|full pane-serials; active tag the workspace tag, tagexec a word as a click in it; col// a column's tag, ctl (Delcol Joincol New Tty), exec; rmdir: empty only pane/new open it to make a pane (/+New) in the active column, filling it if empty; the read answers its serial -pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll errors (write-only: - appended to its directory's +Errors pane) event look exec tagexec, pty/ on terminals; rmdir closes +pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll errors (write-only, to +Errors) event look exec tagexec, pty/ on terminals; rmdir closes os/, src/ the host filesystem; the editor's own sources $m below: $NINE_MOUNT/pardes/; $NINE_MOUNT under 9ns --unix; PARDES_MOUNT in a Tty9p shell. diff --git a/src/main.zig b/src/main.zig index 86c302fe..b784ec97 100644 --- a/src/main.zig +++ b/src/main.zig @@ -369,6 +369,7 @@ fn nativeMain(init: std.process.Init) !void { opts.startup_config = found.bytes; opts.startup_config_path = found.path; opts.config_dir = found.dir; + opts.recent_path = recentPath(init.io, arena, init.environ_map); if (found.dir) |d| @import("crash.zig").setDir(d); if (detach) |name| { const named = if (name.len != 0) @@ -427,3 +428,18 @@ test { if (comptime pardes.platform == .gui) _ = @import("gui/gui.zig"); if (comptime pardes.font_picker) _ = @import("fonts.zig"); } + +/// Where the list of files opened lately is kept: $XDG_STATE_HOME/pardes +/// /recent, else ~/.local/state/pardes/recent, the directory made if need +/// be; null with no home to keep it in (the list then lasts the session). +fn recentPath(io: std.Io, arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 { + const dir = dir: { + if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.fs.path.isAbsolute(base)) + break :dir std.fs.path.join(arena, &.{ base, "pardes" }) catch return null; + const home = env.get("HOME") orelse return null; + if (home.len == 0) return null; + break :dir std.fs.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch return null; + }; + std.Io.Dir.cwd().createDirPath(io, dir) catch return null; + return std.fs.path.join(arena, &.{ dir, "recent" }) catch null; +} diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 6631e5f9..22a0923b 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2106,6 +2106,60 @@ test "a column takes panes until their documented minimums fill it, not until no } } +test "a closed file is found again: Recent and /recent list it closed, a look at its row reopens it at its dot, and a jump back does too" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "a.txt", .data = "one\ntwo\nthree\n" }); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "b.txt", .data = "bee\n" }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var line: [4200]u8 = undefined; + const a_path = try std.fmt.bufPrint(&line, "{s}/a.txt", .{dir}); + var a_buf: [4200]u8 = undefined; + const a = a_buf[0..a_path.len]; + @memcpy(a, a_path); + // Opened, its dot on line 3, then closed. + try testing.expectEqual(Status.ok, wr(p, root_look, try std.fmt.bufPrint(&line, "{s}:3\n", .{a})).reply.status); + p.sync(); + const opened = p.active; + try testing.expectEqualStrings(a, p.panes[opened].?.file.?.path); + var want: [4300]u8 = undefined; + try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "open {s}\n", .{a})) != null); + // Another file, so the jumplist has somewhere to come back from. + try testing.expectEqual(Status.ok, wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/b.txt\n", .{dir})).reply.status); + p.sync(); + try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[opened].?.serial, .ctl), "Del\n").reply.status); + p.sync(); + try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "closed {s}\n", .{a})) != null); + // Recent lists it, closed, at its dot; a look at the row opens it there. + try testing.expectEqual(Status.ok, wr(p, root_exec, "Recent\n").reply.status); + const rows = p.panes[p.paneBySerial(try std.fmt.parseInt(u32, std.mem.trimEnd(u8, rd(p, root_exec, 0, 64).bytes, "\n"), 10)).?].?; + const at = std.mem.indexOf(u8, rows.file.?.content, try std.fmt.bufPrint(&want, "{s}:3:", .{a})).?; + const row = rows.file.?.content[at .. std.mem.indexOfScalarPos(u8, rows.file.?.content, at, '\n').?]; + try testing.expect(std.mem.endsWith(u8, row, " closed")); + try testing.expectEqual(Status.ok, wr(p, Node.of(rows.serial, .look), try std.fmt.bufPrint(&line, "{s}\n", .{row[0 .. row.len - " closed".len]})).reply.status); + p.sync(); + const back = p.panes[p.active].?; + try testing.expectEqualStrings(a, back.file.?.path); + try testing.expectEqual(@as(i32, 2), back.body.cur_row); + // Closed again; the jumplist keeps its entry, closed, and a jump back + // to it opens it again. + _ = wr(p, Node.of(back.serial, .ctl), "Del\n"); + p.sync(); + var closed_entry = false; + for (p.jumps[0..p.njumps]) |j| closed_entry = closed_entry or j.serial == 0; + try testing.expect(closed_entry); + var tries: usize = 0; + while (tries < p.njumps) : (tries += 1) { + p.jumpBy(-1); + p.sync(); + if (p.panes[p.active].?.file) |f| if (std.mem.eql(u8, f.path, a)) break; + } + try testing.expectEqualStrings(a, p.panes[p.active].?.file.?.path); +} + test "size is monotonic: growing is never refused, and a size once taken is taken again" { const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 }); defer p.deinit(); diff --git a/src/ninep/events.zig b/src/ninep/events.zig index 868364a6..690efbe5 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -140,6 +140,8 @@ pub fn announce(p: *Pardes) void { if (!pane.fs.unannounced) continue; pane.fs.unannounced = false; noteLog(p, .new, pane); + // A file opened (a look, a Restore, a boot): first in Recent. + if (pane.file) |f| if (f.output == null) p.recent.opened(p.recentGpa(), f.path); } } diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 1148041a..4370d401 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -683,6 +683,7 @@ pub fn nameBuffer(p: *Pardes, id: usize, full: []const u8, preserve_tag: bool) ! look.invalidateLookHover(p, id); p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } }); events.noteLog(p, .rename, pane); + if (f.output == null) p.recent.opened(p.recentGpa(), f.path); } /// Diagnostics go to the +Errors buffer of the pane's directory. diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 9d2027bf..64089c01 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -219,6 +219,9 @@ pub const TopFile = enum(u5) { tag, col, tagexec, + /// The files opened lately, closed ones too, a line each: + /// `open|closed `, most recent first. + recent, pub fn fileName(f: TopFile) []const u8 { return if (f == .root) "/" else @tagName(f); @@ -228,7 +231,7 @@ pub const TopFile = enum(u5) { return switch (f) { .root, .pane, .col => 0o755, .look, .exec, .log, .focus, .ctl, .tag, .tagexec => 0o666, - .README, .index, .status, .screen, .listeners, .new, .commands, .layout => 0o444, + .README, .index, .status, .screen, .listeners, .new, .commands, .layout, .recent => 0o444, }; } @@ -239,6 +242,13 @@ pub const TopFile = enum(u5) { pub const root: u64 = @intFromEnum(TopFile.root); +fn recentLen(p: *Pardes) u64 { + var buf: [64]u8 = undefined; + var counting: std.Io.Writer.Discarding = .init(&buf); + pardes.panes.Output.recentText(p, &counting.writer, false) catch return 0; + return counting.fullCount(); +} + /// Declaration order is readdir order. pub const PaneFile = enum(u5) { dir = 0, @@ -556,6 +566,7 @@ fn topSize(p: *Pardes, f: TopFile) u64 { }, .ctl => ctl.rootLen(p), .commands => ctl.commandsLen(), + .recent => recentLen(p), .focus => focus: { if (p.header_focus) break :focus 0; const pn = p.panes[p.active] orelse break :focus 0; @@ -653,7 +664,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { .root => { // The guide, then what describes the session, then the // files that act, then the directories. - inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.focus, TopFile.ctl, TopFile.commands, TopFile.look, TopFile.exec, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.layout, TopFile.tag, TopFile.tagexec, TopFile.pane, TopFile.col }) |t| { + inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.focus, TopFile.ctl, TopFile.commands, TopFile.recent, TopFile.look, TopFile.exec, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.layout, TopFile.tag, TopFile.tagexec, TopFile.pane, TopFile.col }) |t| { if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(t), t.dir(), t.fileName()); } if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, fs.os_root, true, "os"); @@ -933,6 +944,12 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { .focus => ctl.readFocus(p, req), .ctl => ctl.readRoot(p, req), .commands => ctl.readCommands(p, req), + .recent => recent: { + var text: std.Io.Writer.Allocating = .init(p.scratch.allocator()); + pardes.panes.Output.recentText(p, &text.writer, false) catch break :recent Reply.fail(req.tag, E.NOMEM); + p.fs.stage(p.gpa).appendSlice(p.gpa, text.written()) catch break :recent Reply.fail(req.tag, E.NOMEM); + break :recent stagedReply(p, req); + }, .layout => layout: { var text: std.Io.Writer.Allocating = .init(p.scratch.allocator()); cols.writeLayout(p, &text.writer) catch break :layout Reply.fail(req.tag, E.NOMEM); @@ -1201,13 +1218,13 @@ test "readdir lists the root and a pane directory without creating anything" { @memcpy(top_bytes[0..top_reply.bytes.len], top_reply.bytes); const top = th.dirents(top_bytes[0..top_reply.bytes.len], &buf); try testing.expect(top.len >= 10); - for ([_][]const u8{ "README", "index", "status", "focus", "ctl", "commands", "look", "exec", "log", "screen", "listeners", "layout", "tag", "tagexec", "pane", "col", "os" }, 0..) |name, i| { + for ([_][]const u8{ "README", "index", "status", "focus", "ctl", "commands", "recent", "look", "exec", "log", "screen", "listeners", "layout", "tag", "tagexec", "pane", "col", "os" }, 0..) |name, i| { try testing.expectEqualStrings(name, top[i].name); - try testing.expectEqual(i >= 14, top[i].dir); + try testing.expectEqual(i >= 15, top[i].dir); } - try testing.expectEqual(@intFromEnum(TopFile.pane), top[14].node); - try testing.expectEqual(@intFromEnum(TopFile.col), top[15].node); - try testing.expectEqual(fs.os_root, top[16].node); + try testing.expectEqual(@intFromEnum(TopFile.pane), top[15].node); + try testing.expectEqual(@intFromEnum(TopFile.col), top[16].node); + try testing.expectEqual(fs.os_root, top[17].node); var idbuf: [16]u8 = undefined; try testing.expect(th.nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null); try testing.expect(th.nameAt(top, "self") == null); diff --git a/src/pardes.zig b/src/pardes.zig index f7aee16c..33aff840 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -14,6 +14,7 @@ const tracy = @import("tracy.zig"); pub const panes = @import("panes.zig"); pub const tagline = @import("tagline.zig"); pub const exec = @import("exec.zig"); +const recent_files = @import("recent.zig"); pub const mouse = @import("mouse.zig"); pub const normal = @import("normal.zig"); pub const edit = @import("edit.zig"); @@ -447,11 +448,17 @@ test "a compact tagline anchors at its own pane, and both shells step from the s try std.testing.expectEqual(@as(u16, 3), gridColAt(p, 3.5 * body_w, body_row, body_w, tag_w)); } +const recent_path_cap = limits.host_path_cap; + pub const Loc = struct { pane: u16, + /// 0 once its pane has closed: a file's entry stays, reopened by a + /// jump to it from `path_hash`'s recent entry. serial: u32, line: u32, col: u32, + /// The file it is in (Wyhash of the path), 0 for a pane with none. + path_hash: u64 = 0, }; test { @@ -474,6 +481,7 @@ test { _ = @import("draw.zig"); _ = @import("tag_layer.zig"); _ = @import("dump.zig"); // its tests ran nowhere before + _ = @import("recent.zig"); _ = @import("Presentation.zig"); _ = @import("animation.zig"); } @@ -4232,6 +4240,10 @@ pub const Options = struct { ninep_quic: ?[]const u8 = null, mounts: []const filesystem.Mount = &.{}, config_dir: ?[]const u8 = null, + /// Where the list of files opened lately is kept across sessions + /// (recent.zig), set by the host that has a state directory; none, it + /// lives as long as the session. + recent_path: ?[]const u8 = null, startup_config_path: ?[]const u8 = null, image_allocator: ?std.mem.Allocator = null, pdf_allocator: ?std.mem.Allocator = null, @@ -4298,6 +4310,12 @@ pub const Pardes = struct { presentation: Presentation = .{}, active: usize = 0, + /// The files opened lately, closed ones too (recent.zig): `Recent`, + /// /recent, and the jumplist's way back to a closed pane. + recent: recent_files.List = .{}, + /// The kept list was read (or there was none): only then is it written, + /// so a session never writes over one it did not read. + recent_loaded: bool = false, jumps: [MAX_JUMPS]Loc = undefined, njumps: usize = 0, jcur: usize = 0, @@ -4621,6 +4639,7 @@ pub const Pardes = struct { }, } p.sync(); + p.loadRecent(); exec.applyStartupConfig(p); colors.finishThemeInitialization(p); p.sync(); @@ -4641,7 +4660,58 @@ pub const Pardes = struct { p.col_panes[0][0] = 0; } + /// The recent list's own allocator: it is kept best effort (a file not + /// remembered for want of memory is no failure of what opened it), so + /// on a host it takes from the process heap, not the editor's, whose + /// every failure must be answered. + // ponytail: a host heap for a best-effort list; the board's gpa there. + pub fn recentGpa(p: *const Pardes) std.mem.Allocator { + return if (comptime hosted) std.heap.smp_allocator else p.gpa; + } + + /// The kept list of files opened lately, read once at start. + fn loadRecent(p: *Pardes) void { + const path = p.opts.recent_path orelse return; + if (comptime !hosted) return; + defer p.recent_loaded = true; + const bytes = filesystem.readFile(p.gpa, path) catch return; + defer p.gpa.free(bytes); + p.recent.read(p.recentGpa(), bytes); + } + + /// Written out when it changed, at the end of a step and at the end. + pub fn saveRecent(p: *Pardes) void { + if (!p.recent.dirty) return; + p.recent.dirty = false; + const path = p.opts.recent_path orelse return; + if (comptime !hosted) return; + if (!p.recent_loaded) return; + var out: std.Io.Writer.Allocating = .init(p.gpa); + defer out.deinit(); + p.recent.write(&out.writer) catch return; + turn.yield(); + defer turn.back(); + std.Io.Dir.cwd().writeFile(std.Io.Threaded.global_single_threaded.io(), .{ .sub_path = path, .data = out.written() }) catch {}; + } + + /// A file pane's path and dot, for the recent list (0 when none). + fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col: u32 } { + const f = pane.file orelse return null; + if (f.output != null) return null; + return .{ .path = f.path, .line = @intCast(@max(0, pane.body.cur_row) + 1), .col = @intCast(@max(0, pane.body.cur_col) + 1) }; + } + + /// The recent entry a closed jump names, by its path's hash. + pub fn recentByHash(p: *const Pardes, hash: u64) ?recent_files.Entry { + for (p.recent.entries.items) |e| if (std.hash.Wyhash.hash(0, e.path) == hash) return e; + return null; + } + pub fn deinit(p: *Pardes) void { + // Every file open now is closed with its dot, and the list kept. + for (p.panes) |slot| if (slot) |pane| if (recentDot(pane)) |d| p.recent.closed(p.recentGpa(), d.path, d.line, d.col); + p.saveRecent(); + p.recent.deinit(p.recentGpa()); look.cancelLookHover(p); if (p.repl_ask) |ask| p.gpa.free(ask.text); for (0..MAX_PANES) |id| p.dropPendingWrite(id); @@ -4750,6 +4820,9 @@ pub const Pardes = struct { } fn retirePane(p: *Pardes, pane: *Pane) void { + // Closed, a file is remembered with its dot: Recent and a jump back + // to it reopen it there. + if (recentDot(pane)) |d| p.recent.closed(p.recentGpa(), d.path, d.line, d.col); const watched = (if (pane.file) |f| f.output == null else false) or pane.hasPdf(); for (p.panes, 0..) |slot, id| if (slot == pane) { if (watched) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } }); @@ -5240,6 +5313,7 @@ pub const Pardes = struct { f.saved_revision = f.revision; f.disk_gone = false; ctlfs.events.noteLog(p, .save, pane); + p.recent.opened(p.recentGpa(), f.path); if (filesystem.localPath(f.path) != null) p.emit(.{ .watch = .{ .pane = id, .on = true } }); } @@ -6562,9 +6636,15 @@ pub const Pardes = struct { var cur: usize = 0; for (p.jumps[0..p.njumps], 0..) |j, i| { if (i == p.jcur) cur = w; // survives -> lands at w; dies -> the next one does - const pane = p.panes[j.pane] orelse continue; - if (pane.serial != j.serial) continue; - p.jumps[w] = j; + var kept = j; + const live = if (j.serial == 0) false else if (p.panes[j.pane]) |pane| pane.serial == j.serial else false; + // A file's pane closed: its entry stays, closed, while the recent + // list knows the file, and a jump to it opens it again. + if (!live) { + if (j.path_hash == 0 or p.recentByHash(j.path_hash) == null) continue; + kept.serial = 0; + } + p.jumps[w] = kept; w += 1; } p.njumps = w; @@ -6576,6 +6656,7 @@ pub const Pardes = struct { .serial = pane.serial, .line = if (pane.pdfPage()) |page| @intCast(page + 1) else if (pane.body.cur_pinned) @intCast(@max(0, pane.body.cur_row) + 1) else 0, .col = if (pane.pdfPage() != null) 0 else if (pane.body.cur_pinned) @intCast(@max(0, pane.body.cur_col) + 1) else 0, + .path_hash = if (recentDot(pane)) |d| std.hash.Wyhash.hash(0, d.path) else 0, }; if (p.njumps > 0 and p.samePlace(p.jumps[p.jcur], now)) { p.jumps[p.jcur] = now; // same visit; the entry IS where you are @@ -6604,6 +6685,21 @@ pub const Pardes = struct { if (p.njumps == 0 or next < 0 or next >= p.njumps) return; const j = p.jumps[@intCast(next)]; if (j.pane >= MAX_PANES) return; + // A closed file's entry: opened again at its dot, placed as a look + // places it, and the entry is that pane from here on. + if (j.serial == 0) { + const e = p.recentByHash(j.path_hash) orelse return; + var where: [recent_path_cap + 32]u8 = undefined; + const loc = std.fmt.bufPrint(&where, "{s}:{d}:{d}", .{ e.path, @max(1, j.line), @max(1, j.col) }) catch return; + const from = p.active; + look.lookAt(p, from, loc); + const opened = p.panes[p.active] orelse return; + if (p.active == from) return; + p.jumps[@intCast(next)].pane = @intCast(p.active); + p.jumps[@intCast(next)].serial = opened.serial; + p.jcur = @intCast(next); + return; + } const pane = p.panes[j.pane] orelse return; if (pane.serial != j.serial) return; if (p.panes[p.active]) |source| look.clearNavigationSelection(p, source); @@ -6640,6 +6736,8 @@ pub const Pardes = struct { if (refused) for (0..p.ncol) |c| if (!layout.columnAtMinimums(p, c)) { _ = layout.shareColumn(p, c); }; + // A file opened or closed this step: the kept list follows. + p.saveRecent(); tagline.flattenHeaders(p); if (p.header_column != null and p.columnBarHeight() == 0) { tagline.exitHeader(p); diff --git a/src/recent.zig b/src/recent.zig new file mode 100644 index 00000000..b6a1a66a --- /dev/null +++ b/src/recent.zig @@ -0,0 +1,119 @@ +//! The files opened lately, most recent first, those since closed too, as +//! `Recent` lists them and a jump to a closed pane reopens them: a path +//! and where the dot was when it closed. Kept across sessions in a small +//! file under $XDG_STATE_HOME/pardes (Options.recent_path) when the host +//! gives one. acme has nothing like it (its dump and Load are the nearest): +//! a file closed by accident, its path forgotten, is found here again. + +const std = @import("std"); + +/// At most this many files are remembered, the oldest dropped first. +pub const cap = 200; + +pub const Entry = struct { + path: []u8, + /// Where its dot was when it last closed (1-based; 0 none). + line: u32 = 0, + col: u32 = 0, +}; + +pub const List = struct { + entries: std.ArrayList(Entry) = .empty, + /// Changed since it was last written out. + dirty: bool = false, + + pub fn deinit(l: *List, gpa: std.mem.Allocator) void { + for (l.entries.items) |e| gpa.free(e.path); + l.entries.deinit(gpa); + } + + fn find(l: *const List, path: []const u8) ?usize { + for (l.entries.items, 0..) |e, i| if (std.mem.eql(u8, e.path, path)) return i; + return null; + } + + /// `path` opened: first in the list, once, keeping the dot it closed at. + pub fn opened(l: *List, gpa: std.mem.Allocator, path: []const u8) void { + if (path.len == 0) return; + var entry: Entry = if (l.find(path)) |i| l.entries.orderedRemove(i) else .{ + .path = gpa.dupe(u8, path) catch return, + }; + if (l.entries.items.len >= cap) { + const last = l.entries.pop().?; + gpa.free(last.path); + } + l.entries.insert(gpa, 0, entry) catch { + gpa.free(entry.path); + entry = undefined; + return; + }; + l.dirty = true; + } + + /// `path` closed with its dot at `line`:`col`: where a reopen lands. + /// Its place in the list is its opening's. + pub fn closed(l: *List, gpa: std.mem.Allocator, path: []const u8, line: u32, col: u32) void { + const i = l.find(path) orelse found: { + l.opened(gpa, path); + // Out of memory for it: nothing to note the dot on. + break :found l.find(path) orelse return; + }; + l.entries.items[i].line = line; + l.entries.items[i].col = col; + l.dirty = true; + } + + pub fn get(l: *const List, path: []const u8) ?Entry { + return l.entries.items[l.find(path) orelse return null]; + } + + /// One line a file, ` `, most recent first. + pub fn write(l: *const List, w: *std.Io.Writer) !void { + for (l.entries.items) |e| try w.print("{d} {d} {s}\n", .{ e.line, e.col, e.path }); + } + + /// The lines `write` wrote; a line that is not one is passed over. + pub fn read(l: *List, gpa: std.mem.Allocator, bytes: []const u8) void { + var lines = std.mem.splitScalar(u8, bytes, '\n'); + while (lines.next()) |line| { + if (l.entries.items.len >= cap) break; + var it = std.mem.splitScalar(u8, line, ' '); + const ln = std.fmt.parseInt(u32, it.next() orelse continue, 10) catch continue; + const col = std.fmt.parseInt(u32, it.next() orelse continue, 10) catch continue; + const path = it.rest(); + if (path.len == 0 or path[0] != '/' or l.find(path) != null) continue; + const owned = gpa.dupe(u8, path) catch return; + l.entries.append(gpa, .{ .path = owned, .line = ln, .col = col }) catch { + gpa.free(owned); + return; + }; + } + } +}; + +test "the list keeps a path once, most recent first, its dot from closing, capped" { + const gpa = std.testing.allocator; + var l: List = .{}; + defer l.deinit(gpa); + l.opened(gpa, "/a"); + l.opened(gpa, "/b"); + l.closed(gpa, "/a", 7, 3); + l.opened(gpa, "/a"); + try std.testing.expectEqualStrings("/a", l.entries.items[0].path); + try std.testing.expectEqual(@as(usize, 2), l.entries.items.len); + try std.testing.expectEqual(@as(u32, 7), l.get("/a").?.line); + var buf: [256]u8 = undefined; + var w = std.Io.Writer.fixed(&buf); + try l.write(&w); + try std.testing.expectEqualStrings("7 3 /a\n0 0 /b\n", w.buffered()); + var again: List = .{}; + defer again.deinit(gpa); + again.read(gpa, w.buffered()); + again.read(gpa, "junk\n"); + try std.testing.expectEqual(@as(usize, 2), again.entries.items.len); + for (0..cap + 5) |i| { + var name: [16]u8 = undefined; + l.opened(gpa, std.fmt.bufPrint(&name, "/f{d}", .{i}) catch unreachable); + } + try std.testing.expectEqual(@as(usize, cap), l.entries.items.len); +} diff --git a/test/fs.py b/test/fs.py index 20a9bbff..977b3e45 100644 --- a/test/fs.py +++ b/test/fs.py @@ -161,7 +161,7 @@ def discovery(binary, embedded=False): with session(binary, root, 'discovery') as (client, address): top = client.list('/') # A set: which files the root holds, not the order a listing gives. - assert set(top) - {'src', 'shaders'} == {'README', 'index', 'status', 'focus', 'ctl', 'commands', + assert set(top) - {'src', 'shaders'} == {'README', 'index', 'status', 'focus', 'ctl', 'commands', 'recent', 'look', 'exec', 'log', 'screen', 'listeners', 'layout', 'tag', 'tagexec', 'pane', 'col', 'os'}, top assert 'self' not in top and 'cons' not in top and 'new' not in top, top @@ -539,6 +539,31 @@ def new_terminals_named_once(binary): assert str(made[0]).encode() in b' '.join(r.split()[0] for r in client.read('/index').splitlines()) +def recent_survives_restart(binary): + """A file opened and closed is in /recent closed, and still is in the + next session: the list is kept under $XDG_STATE_HOME (here HOME's + .local/state) across restarts.""" + with tempfile.TemporaryDirectory(prefix='pardes-recent-') as directory: + root = Path(directory) + kept = root / 'kept.txt' + kept.write_bytes(b'one\ntwo\n') + with session(binary, root, 'recent1') as (client, _): + serial = look(client, f'{kept}:2') + assert f'open {kept}\n' in client.read('/recent').decode() + client.write(f'/pane/{serial}/ctl', b'Del\n') + assert f'closed {kept}\n' in client.read('/recent').decode(), client.read('/recent') + assert (root / '.local' / 'state' / 'pardes' / 'recent').exists() + with session(binary, root, 'recent2') as (client, _): + listed = client.read('/recent').decode() + assert f'closed {kept}\n' in listed, listed + # Recent shows it, and a look at its row opens it again. + client.write('/pane/1/exec', b'Recent\n') + rows = int(client.read('/pane/1/exec').split()[-1]) + row = next(r for r in client.read(f'/pane/{rows}/body').decode().splitlines() if r.startswith(f'{kept}:')) + client.write(f'/pane/{rows}/look', (row.split(' ')[0] + '\n').encode()) + assert f'open {kept}\n' in client.read('/recent').decode() + + def workflow_canary(binary): """One session driven as the dogfood agents drive it, asserting the log and the read-backs at every step: the canary for the main paths (the @@ -803,6 +828,7 @@ def test(binary, quic=False): unattended_messages_expire(binary) new_terminals_named_once(binary) workflow_canary(binary) + recent_survives_restart(binary) python_repl_runs_one_line(binary) signal_cleans_up(binary) for options, message in [ -- cgit v1.3 From 5fd713889b6bdeb27c58941b77266c9336bf7b7d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 10:31:15 -0300 Subject: ThemeSel is Themes and FontSel is Fonts; the old words still work in init files and dumps The user asked for the plainer words. Every use is renamed: the builtins, leader paths, /commands, the docs and tutor, tests, and the themesel golden, re-recorded. An init file's ThemeSel or FontSel runs the new word and says `ThemeSel: renamed to Themes`, as ColumnTags is said; a dump naming an output pane by the old word restores it. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- docs/config.md | 6 +++--- docs/design.typ | 2 +- docs/fs.md | 2 +- docs/helix-keys.md | 2 +- docs/macos.md | 2 +- docs/themes.md | 4 ++-- docs/ui-review.md | 4 ++-- src/Output.zig | 9 ++++++--- src/builtins.zig | 4 ++-- src/colors.zig | 2 +- src/config.zig | 4 ++-- src/exec.zig | 28 ++++++++++++++++++++++++++-- src/ninep/ctl.zig | 4 ++-- test/appearance_gallery.py | 8 ++++---- test/output.zig | 10 +++++----- test/snapshots/themesel.golden | 2 +- test/snapshots/themesel.snap | 2 +- 18 files changed, 62 insertions(+), 35 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 826f86c8..d7548e8c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ diagnostics and embedded terminal: `orchard` (the near-black default), `dusk`, `daybreak` provide high contrast dark and light choices. Six classic-inspired adaptations add `forge`, `lagoon`, `solarium`, `spectrum`, `harvest`, and `clay`. `forge_black` and `orchard_black` offer pure-black variations; `forge_soft` -offers a deliberately softer contrast. Execute `ThemeSel` to choose native +offers a deliberately softer contrast. Execute `Themes` to choose native themes first, followed by the existing legacy/imported collection. `FocusTint` toggles the active pane and column tag tints (on by default), and `SyntaxBold` toggles bold syntax keywords (off by default), in both GUI and TTY. diff --git a/docs/config.md b/docs/config.md index 96281cd5..9d7446f1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -96,7 +96,7 @@ The SDL GUI also has `WindowOpacity`, which takes one argument. `builtins.Board.enabled` holds, and that build has no config file.) `Theme ` wants one of the names in the compiled ring. Do not derive the -spelling — read it off `ThemeSel` (`SPC t t`), which lists every one as the +spelling — read it off `Themes` (`SPC t t`), which lists every one as the exact `Theme ` line that selects it. `slug` in `tools/gen_themes.zig` lowercases, folds punctuation runs to a single `_` and then TRIMS leading and trailing ones (`penumbra+.toml` is `penumbra`, not `penumbra_`), and every @@ -109,7 +109,7 @@ project gains or loses a file. A name that is not in the ring is ignored. The fifteen [native Pardes themes](themes.md) lead the ring: `orchard` (the default), `dusk`, `ink`, `paper`, `daybreak`, `atelier`, `forge`, `lagoon`, `solarium`, `spectrum`, `harvest`, `clay`, `forge_black`, `forge_soft`, and -`orchard_black`. `ThemeSel` lists them first under Pardes themes, followed by +`orchard_black`. `Themes` lists them first under Pardes themes, followed by a separate legacy/imported section. They add coordinated focus, search, diagnostic and terminal colors; `ink` and `daybreak` are high contrast dark and light options. The original `helix`, `dark` and `acme` @@ -391,7 +391,7 @@ asked for one. Neither reaches the child as a keystroke, so an application that would otherwise answer Ctrl-V by reading the system clipboard itself never gets the chance to read the wrong thing. -`Font` and `FontSel` exist ONLY in the SDL GUI and native macOS builds — a +`Font` and `Fonts` exist ONLY in the SDL GUI and native macOS builds — a terminal's font belongs to its emulator and a browser's to the page — so a `Font` line is one of the silently-ignored ones everywhere else. Both builds resolve the name by walking the font directories on every lookup, so a face diff --git a/docs/design.typ b/docs/design.typ index 639884a9..ed2bbb94 100644 --- a/docs/design.typ +++ b/docs/design.typ @@ -2010,7 +2010,7 @@ one pair per theme, and the three per-button tints and the dimmed extra cursors are mixed off it, so what stays fixed is the distinction between buttons and not the colours. `NextColor` browses the ring one step at a time — at 228 it is no longer how you REACH one — -`Theme ` jumps to one and `ThemeSel` (`SPC t t`) lists them all into an +`Theme ` jumps to one and `Themes` (`SPC t t`) lists them all into an output buffer whose rows are those very commands — execute a row (Tab, middle click) and the theme goes on; n/N select such a row WHOLE, since a command line holds no place to pick out of it — the third grain of that motion, the diff --git a/docs/fs.md b/docs/fs.md index dedfe94f..ceca1dd9 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -274,7 +274,7 @@ argument to a builtin that takes none, or none to one that needs it (`Msg`, `Mount`, `Find`, a setting's value but a switch's, which flips bare); `bad value in control message "X"` for a setting's value it does not take (for `Theme`, naming the themes that share the name's first letter, since -all of them, `ThemeSel`'s list, are too many for an error); +all of them, `Themes`'s list, are too many for an error); and `not a session control message "X": write it to pane//ctl` or `not a window control message "X": write it to /ctl` for a word of the other ctl. 9ns maps them all to EINVAL, and a write refused here has done nothing. A line that then fails as it runs fails the diff --git a/docs/helix-keys.md b/docs/helix-keys.md index 5d89ba92..b1035ad6 100644 --- a/docs/helix-keys.md +++ b/docs/helix-keys.md @@ -135,7 +135,7 @@ language-backend queries, and the shell pipe. | `SPC y` `SPC Y` `SPC p` `SPC P` `SPC R` | helix's clipboard menu on helix's own letters: yank the selection to the system clipboard (`ClipYank`) or the PRIMARY selection alone (`ClipYankMain`), paste the system clipboard after (`ClipPaste`) / before (`ClipPasteBefore`) the selection, replace the selection with it (`ClipReplace`) | the same as `"+y`, `"+p`, `"+P`, `"+R`: register `+` (and `*`) IS the desktop's clipboard, the only register that reaches it. `SPC y` writes `+` alone, as helix's does, not the default register too. Builtins rather than bare chords because a leader path names a builtin: they land in Help's index and are executable words like every other verb. The clipboard holds one text, so N values go out joined by newlines, as helix sends them. On a tty the write is OSC 52 out and the READ is OSC 52 back, which many terminals refuse or gate — so `SPC y` works there and `SPC p` can be a no-op | out of corpus | | a paste from the OUTER terminal | one `Event.paste`, spliced in at the cursor | the tty shell enables bracketed paste and coalesces `paste_start`..`paste_end` into a single event; before that the bytes arrived as individual key presses and normal mode RAN them, which is how a pasted `d` deleted a line. The bytes deliberately never enter the yank register — clipboard and default register are separate stores in both directions | pardes-specific | | `/` (any pane) | pardes' own plain-substring search into a `+Search` output buffer: the pattern is typed on a line of its own on the pane's notice band, Enter fills the buffer, and its rows are ordinary look targets. Enter also GOES to the first row — the buffer is focused and then the step `n` is and the look Enter is run in it (`Pardes.lookFirstHit`), so `/foo` lands on the first hit with the matched span selected. A pattern that matched nothing opens its empty buffer and moves nothing | KEEP, do not touch; not in the corpus (helix `/` is regex search). Find and Grep answer with OTHER files and deliberately do NOT jump. The stepping half is the next row | pardes-specific | -| `n` / `N` (any pane) | MOTION, not a jump: move the SELECTION to the next / previous look-able text and open NOTHING. Enter — the look chord — on what it leaves selected is what opens it | KEEP, do not touch; not in the corpus (helix's `n`/`N` walk regex search hits). What a step selects is the pane's GRAIN (`output_pane.Grain`, read in `Pardes.lookSpanIn`): in FREE TEXT — a terminal, a file, a PDF, a prose answer buffer — the largest whitespace-delimited run `look.resolve` can act on (`look.lookableSpan`, wrapper punctuation peeled off both ends), several to a line; in a RESULTS BUFFER one stop per ROW, the largest run its head resolves as (`look.lookableLineSpan`), because a row there IS one location and the words after it are the match rather than a second place to go; in a COMMAND list the whole line. The walk is a RING across PANES: every pane that has performed a Look, most recent first (`Pardes.look_src`), then the output buffers that have not, newest first, and only when both are empty the active pane. Exhausting a pane enters the next at its first (forward) / last (backward) span and the end wraps to the start, so `N` is the exact inverse of `n`. What it lands on becomes an EXPLICIT `vsel` with the cursor on its FIRST column, in the pane the walk focuses. ONE motion in every pane kind and every buffer kind — a PDF steps the `+Search` buffer its own search filled, `n` to select the row and Enter to jump. The single thing a buffer may change is that grain, and it changes it by BEING a kind of buffer rather than by a branch: `output_pane.Traits.steps` (a list of locations) makes a step take one row at a time, and `Traits.commands` makes it take the WHOLE LINE, because a command list (`ThemeSel`/`FontSel`) holds words to run and there is no path inside `Theme gruvbox` to pick out. Tab on what `n` selected wears the theme, which is the same middle click on the row is. `]d`/`[d` are helix's diagnostic motions, a different binding, and they do still jump to each diagnostic (`docs/lsp.md`) | pardes-specific | +| `n` / `N` (any pane) | MOTION, not a jump: move the SELECTION to the next / previous look-able text and open NOTHING. Enter — the look chord — on what it leaves selected is what opens it | KEEP, do not touch; not in the corpus (helix's `n`/`N` walk regex search hits). What a step selects is the pane's GRAIN (`output_pane.Grain`, read in `Pardes.lookSpanIn`): in FREE TEXT — a terminal, a file, a PDF, a prose answer buffer — the largest whitespace-delimited run `look.resolve` can act on (`look.lookableSpan`, wrapper punctuation peeled off both ends), several to a line; in a RESULTS BUFFER one stop per ROW, the largest run its head resolves as (`look.lookableLineSpan`), because a row there IS one location and the words after it are the match rather than a second place to go; in a COMMAND list the whole line. The walk is a RING across PANES: every pane that has performed a Look, most recent first (`Pardes.look_src`), then the output buffers that have not, newest first, and only when both are empty the active pane. Exhausting a pane enters the next at its first (forward) / last (backward) span and the end wraps to the start, so `N` is the exact inverse of `n`. What it lands on becomes an EXPLICIT `vsel` with the cursor on its FIRST column, in the pane the walk focuses. ONE motion in every pane kind and every buffer kind — a PDF steps the `+Search` buffer its own search filled, `n` to select the row and Enter to jump. The single thing a buffer may change is that grain, and it changes it by BEING a kind of buffer rather than by a branch: `output_pane.Traits.steps` (a list of locations) makes a step take one row at a time, and `Traits.commands` makes it take the WHOLE LINE, because a command list (`Themes`/`Fonts`) holds words to run and there is no path inside `Theme gruvbox` to pick out. Tab on what `n` selected wears the theme, which is the same middle click on the row is. `]d`/`[d` are helix's diagnostic motions, a different binding, and they do still jump to each diagnostic (`docs/lsp.md`) | pardes-specific | | insert: printable text | file: real edit; terminal: typed run splice | | helix-verified (file) | | insert: `Enter` | newline; keeps the current full indent levels and adds one 4-space logical tab when the text before the cursor ends in `(`, `[`, `{`, or `)` (including `})`) | plain lines match `insert_newline`; delimiter heuristic is pardes-specific | helix-verified (plain) / pardes-specific (delimiter) | | insert: `Backspace` (+ `Shift-Backspace`) | delete prev char, joins lines at col 0; in a line's leading blanks, back to the previous 4-column indent stop (a whole unit when on one; a tab still goes alone) | matches `delete_char_backward` and its dedent; `Ctrl-h` alias in B | helix-verified | diff --git a/docs/macos.md b/docs/macos.md index cf7091e6..8bb81be6 100644 --- a/docs/macos.md +++ b/docs/macos.md @@ -495,7 +495,7 @@ has none: The face is the shell's business and the size is the window's, so the two are reached differently on purpose. -`Font ` and the `FontSel` picker are ordinary core builtins, enabled by +`Font ` and the `Fonts` picker are ordinary core builtins, enabled by `pardes.font_picker` — the frontends that draw their own text, which is now the SDL shell and this one. `src/fonts.zig` moved out of `gui/` for that reason. It walks the platform's font directories and reads four small sfnt tables per file diff --git a/docs/themes.md b/docs/themes.md index 38596819..5349a764 100644 --- a/docs/themes.md +++ b/docs/themes.md @@ -3,11 +3,11 @@ Pardes ships fifteen native palettes: six originals, six classic-inspired adaptations and three contrast variants, designed for tags, text, search, diagnostics and embedded terminals together. `orchard` is the initial theme. -Execute `Theme ` anywhere, or open `ThemeSel` with `SPC t t` and select +Execute `Theme ` anywhere, or open `Themes` with `SPC t t` and select a theme's command. Put the same command in your [startup configuration](config.md) to keep a preference. `NextColor` cycles through the native themes first, then the retained `helix`, `dark` and `acme` themes and imported palettes. -`ThemeSel` groups the new palettes under `Pardes themes`, followed by +`Themes` groups the new palettes under `Pardes themes`, followed by `Legacy and imported themes`; its navigation skips the section headings. See the [Agave visual review](ui-review.md) for the original six-palette gallery. diff --git a/docs/ui-review.md b/docs/ui-review.md index 1180a20e..decf042d 100644 --- a/docs/ui-review.md +++ b/docs/ui-review.md @@ -12,7 +12,7 @@ and silver-blue chrome. `forge_black` and `orchard_black` use pure black; `forge_soft` joins `dusk`, `lagoon` and `solarium` as deliberately softer alternatives. Light and Acme-inspired choices remain available. -`ThemeSel` opens with the native collection, followed by a separate legacy +`Themes` opens with the native collection, followed by a separate legacy and imported section. Keyboard navigation skips both section headings. `Collapse` now transfers all released rows to one expanded pane, preferring @@ -36,7 +36,7 @@ sent to the user's session. - [Six contrast studies, OS screenshot crops](screenshots/theme-preferences.png) - [Neutral Forge, full workspace](screenshots/theme-preferences-forge.png) -- [Native-first ThemeSel, full workspace](screenshots/theme-selector.png) +- [Native-first Themes, full workspace](screenshots/theme-selector.png) ## Compact rails, classic palettes and workspace pets diff --git a/src/Output.zig b/src/Output.zig index dd6ab92a..a75718bf 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -250,6 +250,9 @@ pub fn fromWord(w: []const u8) ?Origin { if (std.mem.eql(u8, w, "/")) return .search; if (std.mem.eql(u8, w, config.errors_buffer)) return .errors; if (std.mem.eql(u8, w, config.pdf_links_buffer)) return .pdf_links; + // A dump from before the rename names them by their old words. + if (std.mem.eql(u8, w, "ThemeSel")) return .{ .cmd = .Themes }; + if (builtins.capabilities.font_picker) if (std.mem.eql(u8, w, "FontSel")) return .{ .cmd = .Fonts }; if (std.meta.stringToEnum(Builtin, w)) |b| if (builtins.registry.outputTraits(b) != null) return .{ .cmd = b }; if (std.meta.stringToEnum(lsp.Kind, w)) |k| return .{ .query = k }; @@ -591,13 +594,13 @@ pub fn openThemes(p: *Pardes, id: usize) !void { try out.writer.print(comptime config.Runtime.findAction(.theme).?.word ++ " {s}\n", .{t.name}); } const content = try out.toOwnedSlice(); - try openStepped(p, id, .{ .cmd = .ThemeSel }, content); + try openStepped(p, id, .{ .cmd = .Themes }, content); } pub fn isWalkRow(file: *const File.State, row: usize, line: []const u8) bool { const state = file.output orelse return true; if (usesLocationsConfig(state.from)) return isResultRow(file, row); - if (!std.meta.eql(state.from, Origin{ .cmd = .ThemeSel })) return true; + if (!std.meta.eql(state.from, Origin{ .cmd = .Themes })) return true; // Section labels are for reading, not stops in the command walk. return std.mem.startsWith(u8, std.mem.trimStart(u8, line, " \t"), comptime config.Runtime.findAction(.theme).?.word ++ " "); } @@ -611,7 +614,7 @@ pub fn openFonts(p: *Pardes, id: usize) !void { for (font_list) |f| try out.writer.print(comptime config.Runtime.findAction(.font).?.word ++ " {s}\n", .{f.name}); const content = try out.toOwnedSlice(); - try openStepped(p, id, .{ .cmd = .FontSel }, content); + try openStepped(p, id, .{ .cmd = .Fonts }, content); } } diff --git a/src/builtins.zig b/src/builtins.zig index 2247fcbb..041eb1b8 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -741,7 +741,7 @@ pub const NextColor = struct { }; /// List the themes in a pane, each a word to click. -pub const ThemeSel = struct { +pub const Themes = struct { pub const scope: Scope = .session; pub const output: OutputTraits = .{ .name = config.themes_buffer, .steps = true, .commands = true }; pub fn run(c: Ctx) void { @@ -779,7 +779,7 @@ pub const DumpThemes = struct { }; /// List the fonts in a pane, each a word to click. -pub const FontSel = struct { +pub const Fonts = struct { pub const scope: Scope = .session; pub const output: OutputTraits = .{ .name = config.fonts_buffer, .steps = true, .commands = true }; pub const enabled = capabilities.font_picker; diff --git a/src/colors.zig b/src/colors.zig index 8319a112..5694998d 100644 --- a/src/colors.zig +++ b/src/colors.zig @@ -559,7 +559,7 @@ fn invalidateThemeDependentRasters(p: *Pardes) void { } /// Themes whose names share `name`'s first letter, a line of them, for a -/// Theme given a name there is none of: all of them (ThemeSel) are too many +/// Theme given a name there is none of: all of them (Themes) are too many /// for a message or a refused write. pub fn themesNear(buf: []u8, name: []const u8) []const u8 { var w = std.Io.Writer.fixed(buf); diff --git a/src/config.zig b/src/config.zig index c7ea5411..2b5bf280 100644 --- a/src/config.zig +++ b/src/config.zig @@ -88,7 +88,7 @@ pub const leader_path = paths: { .Wrap = "tw", .Tagbottom = "tb", .NextColor = "tn", - .ThemeSel = "tt", + .Themes = "tt", .Theme = null, .Shell = null, .Petscii = "tp", @@ -109,7 +109,7 @@ pub const leader_path = paths: { .Exec = null, }); if (builtins.capabilities.font_picker) { - table.set(.FontSel, "tf"); + table.set(.Fonts, "tf"); table.set(.Font, null); table.set(.TaglineSize, null); } diff --git a/src/exec.zig b/src/exec.zig index 60c4172d..1fc38b9c 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -811,11 +811,35 @@ pub fn applyStartupConfig(p: *Pardes) void { if (executeBuiltinLine(p, p.active, line)) continue; // A setting pardes no longer has is said, once, and changes nothing. const word = commandText(line); - if (std.mem.eql(u8, word[0 .. std.mem.indexOfAny(u8, word, " \t") orelse word.len], "ColumnTags")) + const head = word[0 .. std.mem.indexOfAny(u8, word, " \t") orelse word.len]; + if (std.mem.eql(u8, head, "ColumnTags")) p.setMessage(p.active, "ColumnTags: column tags are always shown now; the init line is ignored"); + // A word renamed runs as its new name, and says so, once a line. + for ([_][2][]const u8{ .{ "ThemeSel", "Themes" }, .{ "FontSel", "Fonts" } }) |renamed| if (std.mem.eql(u8, head, renamed[0])) { + _ = executeBuiltinLine(p, p.active, renamed[1]); + var said: [64]u8 = undefined; + p.setMessage(p.active, std.fmt.bufPrint(&said, "{s}: renamed to {s}", .{ renamed[0], renamed[1] }) catch "renamed"); + }; } } +test "an init file's ThemeSel runs as Themes and says it was renamed" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + p.opts.startup_config = "ThemeSel\n"; + applyStartupConfig(p); + var listed = false; + for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.output) |o| { + listed = listed or std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Themes }); + }; + try std.testing.expect(listed); + var said = false; + for (p.panes) |slot| if (slot) |pane| { + said = said or std.mem.eql(u8, pane.msg[0..pane.msg_len], "ThemeSel: renamed to Themes"); + }; + try std.testing.expect(said); +} + test "an init file's retired ColumnTags line is said and ignored" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -873,7 +897,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] if (!p.announce) return; var near: [96]u8 = undefined; var text: [200]u8 = undefined; - return p.reportFailure(p.active, std.fmt.bufPrint(&text, "Theme: no theme \"{s}\"; like it: {s}; ThemeSel lists all", .{ want[0..@min(want.len, 40)], colors.themesNear(&near, want) }) catch "Theme: no such theme"); + return p.reportFailure(p.active, std.fmt.bufPrint(&text, "Theme: no theme \"{s}\"; like it: {s}; Themes lists all", .{ want[0..@min(want.len, 40)], colors.themesNear(&near, want) }) catch "Theme: no such theme"); }, .font => { if (comptime !font_picker) return; diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 22a0923b..18a7eaa9 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -414,7 +414,7 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? // `refuse` quotes the line after it, in what is left of 128. var near: [40]u8 = undefined; var why: [104]u8 = undefined; - return refuse(p, req, std.fmt.bufPrint(&why, "bad value in control message; like it: {s}; ThemeSel lists all", .{pardes.colors.themesNear(&near, arg)}) catch "bad value in control message", line); + return refuse(p, req, std.fmt.bufPrint(&why, "bad value in control message; like it: {s}; Themes lists all", .{pardes.colors.themesNear(&near, arg)}) catch "bad value in control message", line); }, .font => config.Runtime.FontSpec.parse(arg) != null, else => probe: { @@ -1093,7 +1093,7 @@ test "the root ctl reads the settings as a write takes them, and takes the sessi try testing.expectEqualStrings("bad value in control message; takes acme, pardes \"Placement east\"", wr(p, root_ctl, "Placement east").reply.ename); const no_theme = wr(p, root_ctl, "Theme no-such-theme").reply.ename; try testing.expectStringStartsWith(no_theme, "bad value in control message; like it: n"); - try testing.expect(std.mem.endsWith(u8, no_theme, "; ThemeSel lists all \"Theme no-such-theme\"")); + try testing.expect(std.mem.endsWith(u8, no_theme, "; Themes lists all \"Theme no-such-theme\"")); try testing.expectEqualStrings("wrong #args in control message \"Newcol 2\"", wr(p, root_ctl, "Newcol 2").reply.ename); try testing.expectEqualStrings("wrong #args in control message \"Theme\"", wr(p, root_ctl, "Theme").reply.ename); // A bare required word fails the check, so the line before never runs. diff --git a/test/appearance_gallery.py b/test/appearance_gallery.py index bc9a7570..46b17dd9 100644 --- a/test/appearance_gallery.py +++ b/test/appearance_gallery.py @@ -51,7 +51,7 @@ Orchard: crisp woodland color Dusk: intentionally soft and warm Theme dusk -ThemeSel: Pardes themes come first. +Themes: Pardes themes come first. ''' @@ -159,16 +159,16 @@ def run(args): if args.theme_selector: command(client, terminal, 'Collapse') before = set(panes(client)) - command(client, right, 'ThemeSel') + command(client, right, 'Themes') selector = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), - 'ThemeSel missing') + 'Themes missing') body = client.read(f'/pane/{selector}/body').decode() native, legacy = body.split('# Legacy and imported themes', 1) for theme in ('forge_black', 'forge_soft', 'orchard_black'): require('Theme ' + theme + '\n' in native, 'native contrast variant below legacy heading') require('Theme helix\n' in legacy, 'legacy theme section missing') require('Theme orchard' in ''.join(c[0] for c in client.screen()['cells']), - 'ThemeSel did not open at native first entry') + 'Themes did not open at native first entry') take_frame('theme-selector') report['native_themes_first'] = True client.write(f'/pane/{selector}/exec', b'Del\n') diff --git a/test/output.zig b/test/output.zig index 478f1b4a..21c02e0a 100644 --- a/test/output.zig +++ b/test/output.zig @@ -952,13 +952,13 @@ test "N exactly reverses n across output panes and the ring seam" { try std.testing.expect(saw_first and saw_second); } -test "ThemeSel groups native themes first and skips headings in both directions" { +test "Themes groups native themes first and skips headings in both directions" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); defer p.deinit(); const source = try p.setTestFile("notes\n"); pardes.colors.setThemeIndex(p, pardes.themes.len - 1); const original_theme = p.settings.theme; - try std.testing.expect(p.executeBuiltinLine(0, "ThemeSel")); + try std.testing.expect(p.executeBuiltinLine(0, "Themes")); const tid = source.search_pane orelse return error.MissingThemeList; const list = p.panes[tid].?; const content = list.file.?.content; @@ -979,12 +979,12 @@ test "ThemeSel groups native themes first and skips headings in both directions" for (pardes.themes[0 .. pardes.native_theme_count + 1]) |theme| { p.update(.{ .key = .{ .cp = 'n' } }); try std.testing.expectEqual(tid, p.active); - const selected = selectedOutputText(list) orelse return error.MissingThemeSelection; + const selected = selectedOutputText(list) orelse return error.MissingThemesection; try std.testing.expectEqualStrings(theme.name, selected["Theme ".len..]); try std.testing.expectEqual(original_theme, p.settings.theme); } p.update(.{ .key = .{ .cp = 'N' } }); - const previous = selectedOutputText(list) orelse return error.MissingThemeSelection; + const previous = selectedOutputText(list) orelse return error.MissingThemesection; try std.testing.expectEqualStrings(pardes.themes[pardes.native_theme_count - 1].name, previous["Theme ".len..]); p.update(.{ .key = .{ .cp = Key.tab } }); try std.testing.expectEqual(pardes.native_theme_count - 1, p.settings.theme); @@ -999,7 +999,7 @@ test "n/N selects command outputs by whole row" { defer p.deinit(); p.update(.{ .resize = .{ .cols = 100, .rows = 40 } }); - try std.testing.expect(p.executeBuiltinLine(p.active, "ThemeSel")); + try std.testing.expect(p.executeBuiltinLine(p.active, "Themes")); const tid = p.panes[p.active].?.search_pane orelse return error.MissingThemeList; const themes = p.panes[tid].?; try std.testing.expect(panes.Output.fileTraits(themes.file.?.output).commands); diff --git a/test/snapshots/themesel.golden b/test/snapshots/themesel.golden index 8d453978..92e641f5 100644 --- a/test/snapshots/themesel.golden +++ b/test/snapshots/themesel.golden @@ -31,7 +31,7 @@ | 27 line 27 | 28 line 28 == snap list grid=100x31 cursor=7,3 -|3: 1 line 1 ThemeSel +|3: 1 line 1 Themes |16: /tmp/pardes-snap/themesel/cwd/+Themes Save Tty Collapse Del |17: 1 # Pardes themes |18: 2 Theme orchard diff --git a/test/snapshots/themesel.snap b/test/snapshots/themesel.snap index 04a95d23..2b7b03c4 100644 --- a/test/snapshots/themesel.snap +++ b/test/snapshots/themesel.snap @@ -1,7 +1,7 @@ # RULE: a results buffer is a list of things you can RUN, and its traits say # what a ROW IS. Every list before this one held LOCATIONS — a row with a # `path:LINE:COL` word inside it — so n/N select that word and Enter Looks it. -# `SPC t t` (ThemeSel) opens the first one whose rows are COMMANDS: `Theme +# `SPC t t` (Themes) opens the first one whose rows are COMMANDS: `Theme # `, exactly the line you would type, with no path in it to pick out, so # n/N select the WHOLE ROW. One motion, two grains, and the same split either # way — the step only SELECTS, and Tab (Exec, or the middle button, which is -- cgit v1.3 From 290584fc1127d017603c7c98c9aab27c0523a2cf Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 17:11:35 -0300 Subject: The README and the 9P skill warn that plan9port's 9p write always truncates, so it replaces a body acme ignores OTRUNC, pardes honours it, and 9p write sets it on every open: a pipe into body that appended under acme replaces the text here. The fix is >> through a mount. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 2 ++ README.md | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'README.md') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index eb5a26e1..94ad0de8 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -275,6 +275,8 @@ A `+New` scratch counts as unsaved (and holds up Exit, Restore, Del) only once it holds 100 bytes or more. A read of `data` or `xdata` moves `addr` past what it read, as in acme. Truncating `data` is pardes's own (acme ignores OTRUNC and always inserts). +plan9port's `9p write` always opens with OTRUNC, so `… | 9p write pane/body` +replaces the whole body: append with `>>` through a mount instead. | Read the selection | `cat $pane/dot` (offsets), `cat $pane/sel` (text) | the same two reads | | Select the addressed range | `cp $pane/addr $pane/dot` | `client.write(pane + '/dot', client.read(pane + '/addr'))` | | Reload from disk | `echo get > $pane/ctl` (refused once while there are unsaved edits; again discards) | `client.write(pane + '/ctl', b'get\n')` | diff --git a/README.md b/README.md index d7548e8c..f60b0ed7 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ serves the layout: `/layout` lists the columns, their places and panes, and `/tag` and `/col//tag` are the workspace and column tags, editable like a window's ([the tree](docs/fs.md#the-served-tree)). +plan9port's `9p write` always opens with OTRUNC, so `echo x | 9p write +pardes//body` replaces the whole body where acme would append. To append, +write through a mount with `>>` (`echo x >> $PARDES_MOUNT//body`). + ## Requirements Zig **0.16.0** (`build.zig.zon` pins `minimum_zig_version`). Dependencies are -- cgit v1.3 From a22129c343d9236277dcc0353c48cb53bc3417ce Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 18:32:37 -0300 Subject: pardes --wait (-w) in a pane returns only once the pane its file landed in is deleted, so it can be $EDITOR A launch inside a pane forwards its file to the session's look and returned at once, so fish's Ctrl-O (edit_command_buffer), git commit and crontab -e read their still-unedited file back and went on. With --wait, as acme's E against B and read the way plan9port's E reads acme's log, it finds the pane /index names the file by (the one already showing it, if open), follows /log on one connection with 'follow new', reads /index once more to catch a Del that came first, and then blocks with no deadline until that pane's del record: exit 0, or 1 when the connection ends with the session. The 9P client's one-shot requests keep their 2 s deadline; its new follow takes it for the setup only. Outside pardes nothing changes. --help, docs/fs.md, the README and the 9P skill say to set EDITOR='pardes --wait', which GIT_EDITOR follows. Tested in fs.py (it returns within 50 ms of the Del, a second -w waits on the same pane, one whose session is killed exits 1) and end to end: fish 4.8 in a detached session, echo hi, Ctrl-O, the waiting launch idle in poll, the line edited over 9P, Save, Del, and fish ran echo edited. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 4 ++ README.md | 6 +++ docs/fs.md | 9 ++++ src/9p_io.zig | 86 +++++++++++++++++++++++++++++++-------- src/main.zig | 85 ++++++++++++++++++++++++++++++++++++++ test/fs.py | 41 +++++++++++++++++++ 6 files changed, 213 insertions(+), 18 deletions(-) (limited to 'README.md') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 18700589..1d32ce7a 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -34,6 +34,10 @@ cat "$m/pane/$PARDES_PANE/body" From there the editor is files: `cat`, `echo >`, `ls` and shell scripts are the whole interface, and nothing below needs more than they do. +`pardes FILE` run in a pane opens FILE in that session and returns at once; +`pardes --wait FILE` returns when that pane is deleted (1 if the session goes +away), which is what `EDITOR='pardes --wait'` needs (`GIT_EDITOR` follows it). + Entries for dead sessions stay listed and answer `Input/output error` on any access, so name the session you mean rather than globbing or taking the newest. `cat "$m/index"` is the cheapest liveness check, and `cat "$m/status"` reports diff --git a/README.md b/README.md index f60b0ed7..14803aef 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ serves the layout: `/layout` lists the columns, their places and panes, and `/tag` and `/col//tag` are the workspace and column tags, editable like a window's ([the tree](docs/fs.md#the-served-tree)). +`pardes FILE` in a pane opens FILE in that session and returns at once. As +`$EDITOR`, use `EDITOR='pardes --wait'` (`GIT_EDITOR` follows it): `--wait` +returns when that pane is deleted, so fish's Ctrl-O, `git commit` and +`crontab -e` read the file after you edit it +([forwarding](docs/fs.md#filesystem)). + plan9port's `9p write` always opens with OTRUNC, so `echo x | 9p write pardes//body` replaces the whole body where acme would append. To append, write through a mount with `>>` (`echo x >> $PARDES_MOUNT//body`). diff --git a/docs/fs.md b/docs/fs.md index 52f991c2..ca02082b 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -15,6 +15,15 @@ separate editor and withholds `PARDES_PID` from its pane shells, so a pardes started in one of them runs a session of its own; its 9P service stays available. +A forwarded launch returns at once, as acme's `B` does. `--wait` (`-w`) +returns only once the pane the file landed in -- the one already showing +it, if any -- is deleted (exit 0), or the session goes away (exit 1), as +acme's `E` does: what an `$EDITOR` must do, since fish's Ctrl-O +(`edit_command_buffer`), `git commit` and `crontab -e` read the file back +when the editor exits. Set `EDITOR='pardes --wait'`; `GIT_EDITOR` follows +`EDITOR` when unset. Outside pardes `--wait` changes nothing, a session +blocking anyway. + Look resolves the OS filesystem first, then the editor's virtual filesystem. Explicit paths bypass that search: diff --git a/src/9p_io.zig b/src/9p_io.zig index 6f05e3ab..78ff5d59 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -1947,14 +1947,8 @@ pub const Client = struct { } }; - fn transact( - s: *Session, - names: []const []const u8, - out: *std.Io.Writer.Allocating, - remote: *RemoteError, - write_bytes: ?[]const u8, - read_limit: usize, - ) !void { + /// Version, attach and a walk to `names`: the fid there and its qid. + fn walkTo(s: *Session, names: []const []const u8, remote: *RemoteError) !struct { fid: u32, qid: ninep.Qid } { _ = try s.ask(.{ .version = .{} }, remote); if (s.cl.msize == 0) return Error.Botch; @@ -1978,6 +1972,20 @@ pub const Client = struct { next = if (next == 1) 2 else 1; i += n; } + return .{ .fid = cur, .qid = here }; + } + + fn transact( + s: *Session, + names: []const []const u8, + out: *std.Io.Writer.Allocating, + remote: *RemoteError, + write_bytes: ?[]const u8, + read_limit: usize, + ) !void { + const at = try walkTo(s, names, remote); + const cur = at.fid; + const here = at.qid; defer s.dropNoWait(cur); const directory = here.type & ninep.qtdir != 0; @@ -2036,15 +2044,20 @@ pub const Client = struct { read_limit: usize, ) ![]u8 { if (comptime !supported) return Error.Dial; + const s = try startSession(gpa, sock, display_path); + defer endSession(gpa, s); + var out: std.Io.Writer.Allocating = .init(gpa); + errdefer out.deinit(); + try transact(s, names, &out, remote, write_bytes, read_limit); + return out.toOwnedSlice(); + } + + /// A connected session whose requests have the usual deadline. + fn startSession(gpa: std.mem.Allocator, sock: Dial, display_path: []const u8) !*Session { const deadline = nowMs() +| budget_ms; const s = try gpa.create(Session); s.* = .{ .fd = -1, .deadline = deadline, .display_path = display_path }; - defer { - if (quic_enabled and s.quic != null) { - s.quic.?.deinit(); - } else if (s.fd >= 0) _ = libc.close(s.fd); - gpa.destroy(s); - } + errdefer endSession(gpa, s); if (sock == .quic) { if (comptime quic_enabled) { s.quic = quic.Connection.dial(sock.quic) catch return Error.Dial; @@ -2052,11 +2065,48 @@ pub const Client = struct { } else return Error.QuicUnavailable; } else s.fd = try connect(sock, deadline); s.cl = .init(.{ .in = &s.in, .out = &s.out }); + return s; + } - var out: std.Io.Writer.Allocating = .init(gpa); - errdefer out.deinit(); - try transact(s, names, &out, remote, write_bytes, read_limit); - return out.toOwnedSlice(); + fn endSession(gpa: std.mem.Allocator, s: *Session) void { + if (quic_enabled and s.quic != null) { + s.quic.?.deinit(); + } else if (s.fd >= 0) _ = libc.close(s.fd); + gpa.destroy(s); + } + + /// Opens `path` on one connection and writes `first` to it (/log's + /// `follow new`), all with the usual deadline; then, once `ready(ctx)` + /// has said it is not done already, reads it with no deadline, a read at + /// a time, until `record(ctx, bytes)` says done. An end of file or a + /// dropped connection is Hangup. What `pardes --wait` blocks on. + pub fn follow( + gpa: std.mem.Allocator, + dial: []const u8, + path: []const u8, + first: []const u8, + ctx: anytype, + comptime ready: fn (@TypeOf(ctx)) bool, + comptime record: fn (@TypeOf(ctx), []const u8) bool, + ) !void { + if (comptime !supported) return error.Unsupported; + var names: [max_depth][]const u8 = undefined; + const n = try elements(path, &names); + var sock_buf: [sun_path_len]u8 = undefined; + const sock = try resolve(&sock_buf, dial); + var remote: RemoteError = .{}; + const s = try startSession(gpa, sock, path); + defer endSession(gpa, s); + const fid = (try walkTo(s, names[0..n], &remote)).fid; + _ = try s.ask(.{ .open = .{ .fid = fid, .mode = ninep.ordwr } }, &remote); + _ = try s.ask(.{ .write = .{ .fid = fid, .offset = 0, .data = first } }, &remote); + if (ready(ctx)) return; + s.deadline = std.math.maxInt(i64); + while (true) { + const data = (try s.ask(.{ .read = .{ .fid = fid, .offset = 0, .count = s.cl.maxRead() } }, &remote)).read; + if (data.len == 0) return Error.Hangup; + if (record(ctx, data)) return; + } } fn connect(sock: Dial, deadline: i64) Error!c_int { diff --git a/src/main.zig b/src/main.zig index aaa237f6..ec2472d7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -58,6 +58,12 @@ const help_text = \\ A FILE argument boots just that file instead. \\ --tty-toggle use Ctrl- to toggle tty/editor mode \\ -l load a dump of another instance (see Dump) + \\ -w, --wait inside a pardes pane, hand FILE to the outer + \\ session and return only once the pane it opened + \\ (or already had) is deleted: 0 then, 1 if the + \\ session goes away. For $EDITOR (acme's E): + \\ EDITOR='pardes --wait', which GIT_EDITOR follows. + \\ Outside pardes a session blocks anyway. \\ --nested run a full session even inside another pardes. \\ Without it, a pardes started inside a pardes \\ hands its FILE argument to the outer one. This @@ -92,6 +98,81 @@ const help_text = \\ ; +/// `--wait` after a forwarded look, as plan9port's E reads acme's log: the +/// pane `path` landed in (the one it already had, if open), then /log +/// followed on one connection until that pane's `del` -- exit 0 -- or the +/// connection ends with the session -- exit 1. +fn waitForDel(io: std.Io, gpa: std.mem.Allocator, dial: []const u8, path: []const u8) noreturn { + const first = ninep_io.Client.read(gpa, dial, "/index", "/index") catch std.process.exit(1); + const serial = paneShowing(first, path) orelse { + std.Io.File.stderr().writeStreamingAll(io, "pardes: --wait: no pane shows that file\n") catch {}; + std.process.exit(1); + }; + gpa.free(first); + const Wait = struct { + gpa: std.mem.Allocator, + dial: []const u8, + serial: u32, + /// Deleted between the look and the follow: /index, read once the + /// follow stands, says so, and a `del` after it is followed. + fn gone(w: *const @This()) bool { + const index = ninep_io.Client.read(w.gpa, w.dial, "/index", "/index") catch return false; + defer w.gpa.free(index); + return !hasPane(index, w.serial); + } + fn deleted(w: *const @This(), bytes: []const u8) bool { + return isDel(bytes, w.serial); + } + }; + const w: Wait = .{ .gpa = gpa, .dial = dial, .serial = serial }; + ninep_io.Client.follow(gpa, dial, "/log", "follow new", &w, Wait.gone, Wait.deleted) catch std.process.exit(1); + std.process.exit(0); +} + +/// Whether log records `bytes` hold `del ...`. +fn isDel(bytes: []const u8, serial: u32) bool { + var records = std.mem.splitScalar(u8, bytes, '\n'); + while (records.next()) |rec| { + if (!std.mem.startsWith(u8, rec, "del ")) continue; + const word = rec[4 .. std.mem.indexOfScalarPos(u8, rec, 4, ' ') orelse rec.len]; + if ((std.fmt.parseInt(u32, word, 10) catch continue) == serial) return true; + } + return false; +} + +/// The serial of /index's first row named `path` (`serial kind dirty name col`). +fn paneShowing(index: []const u8, path: []const u8) ?u32 { + var rows = std.mem.splitScalar(u8, index, '\n'); + while (rows.next()) |row| { + var words = std.mem.splitScalar(u8, row, ' '); + const serial = std.fmt.parseInt(u32, words.first(), 10) catch continue; + _ = words.next() orelse continue; // kind + _ = words.next() orelse continue; // dirty + const rest = words.rest(); + const end = std.mem.lastIndexOfScalar(u8, rest, ' ') orelse continue; + if (std.mem.eql(u8, rest[0..end], path)) return serial; + } + return null; +} + +fn hasPane(index: []const u8, serial: u32) bool { + var rows = std.mem.splitScalar(u8, index, '\n'); + while (rows.next()) |row| { + const first = row[0 .. std.mem.indexOfScalar(u8, row, ' ') orelse row.len]; + if ((std.fmt.parseInt(u32, first, 10) catch continue) == serial) return true; + } + return false; +} + +test "--wait finds the pane /index names a file by, spaces and all, and sees it gone" { + const index = "1 term 0 /home/u 1\n4 text 1 /tmp/a b.txt 2\n"; + try std.testing.expectEqual(@as(?u32, 4), paneShowing(index, "/tmp/a b.txt")); + try std.testing.expectEqual(@as(?u32, null), paneShowing(index, "/tmp/a")); + try std.testing.expect(hasPane(index, 4) and !hasPane(index, 2)); + try std.testing.expect(isDel("new 5 /x\ndel 4 /tmp/a b.txt\n", 4)); + try std.testing.expect(!isDel("del 41 /x\n", 4) and !isDel("undel 4\n", 4)); +} + fn badArgs(io: std.Io, comptime fmt: []const u8, args: anytype) noreturn { var buf: [1024]u8 = undefined; const line = std.fmt.bufPrint(&buf, "pardes: " ++ fmt ++ "\nTry 'pardes --help'.\n", args) catch @@ -159,6 +240,7 @@ fn nativeMain(init: std.process.Init) !void { var detach: ?[]const u8 = null; var attach: ?[]const u8 = null; var positional: ?[:0]const u8 = null; + var wait = false; var i: usize = 1; while (i < args.len) : (i += 1) { const a = args[i]; @@ -239,6 +321,8 @@ fn nativeMain(init: std.process.Init) !void { mounts_len += 1; } else if (std.mem.eql(u8, a, "--nested")) { opts.nested = true; + } else if (std.mem.eql(u8, a, "-w") or std.mem.eql(u8, a, "--wait")) { + wait = true; } else if (std.mem.eql(u8, a, "--detach")) { detach = ""; } else if (std.mem.startsWith(u8, a, "--detach=")) { @@ -328,6 +412,7 @@ fn nativeMain(init: std.process.Init) !void { var command_buf: [8192]u8 = undefined; const command = std.fmt.bufPrint(&command_buf, "{s}{s}\n", .{ path, word[target.path.len..] }) catch break :forwarding; ninep_io.Client.write(arena, parent.dial, look, command) catch break :forwarding; + if (wait) waitForDel(init.io, arena, parent.dial, path); return; } if (positional) |a| { diff --git a/test/fs.py b/test/fs.py index 7401861b..db10f32d 100644 --- a/test/fs.py +++ b/test/fs.py @@ -1224,6 +1224,47 @@ def test(binary, quic=False): cell[0] for cell in local.screen()['cells']) assert client.read('/index') == before + # --wait (acme's E): a launch inside a pane lasts until the pane it + # opened is deleted, as an $EDITOR must; one on a file already open + # waits on that pane; a session that goes away ends it with 1. + with session(binary, root, 'wait') as (client, address): + status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines()) + env = {k: v for k, v in os.environ.items() if k != 'PARDES_FORWARD_LOOK'} + env.update(PARDES_9P=str(address), PARDES_PANE='1', PARDES_PID=status['pid']) + edited = root / 'wait edit.txt' + edited.write_bytes(b'edit me\n') + + def serials(): + return {int(row.split()[0]) for row in client.read('/index').splitlines()} + + def launch(flag): + before = serials() + child = subprocess.Popen([binary, flag, str(edited)], cwd=root, env=env, + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + deadline = time.monotonic() + 3 + while child.poll() is None and not serials() - before and time.monotonic() < deadline: + time.sleep(.01) + return child + + first = launch('--wait') + opened, = serials() - {1} + second = launch('-w') + time.sleep(.5) + assert first.poll() is None and second.poll() is None, (first.stderr.read(), second.stderr.read()) + assert serials() == {1, opened} + client.write(f'/pane/{opened}/body', b'edited\n', truncate=True) + execute(client, opened, 'Save') + client.remove(f'/pane/{opened}') + deleted = time.monotonic() + assert first.wait(timeout=5) == 0 + # Woken by the `del` record, not a poll. + assert time.monotonic() - deleted < .05, time.monotonic() - deleted + assert second.wait(timeout=5) == 0 + assert edited.read_bytes() == b'edited\n' + orphan = launch('--wait') + assert orphan.poll() is None + assert orphan.wait(timeout=5) == 1 + for tty in [False, True]: name = 'lsp-tty' if tty else 'lsp-detached' with session(binary, root, name, tty=tty) as (client, _): -- cgit v1.3 From 57b30ba3e38153a4446626449b0fed5120da954c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 19:25:00 -0300 Subject: The docs and the 9P skill say each fact once, in the file that owns it, and say only what a live session does Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 570 +++--------- README.md | 265 ++---- docs/cloud9.md | 147 +-- docs/config.md | 834 ++++------------- docs/detached.md | 76 +- docs/divergences.md | 116 +-- docs/fs.md | 1773 ++++++++++++++----------------------- docs/open-questions.md | 87 +- docs/tags.md | 452 ++++------ docs/v9fs.md | 142 +-- 10 files changed, 1309 insertions(+), 3153 deletions(-) (limited to 'README.md') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 1d32ce7a..7cdca1a0 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -1,486 +1,174 @@ --- name: pardes-9p -description: Inspect and drive a running Pardes editor through its control filesystem, or exercise its panes, builtins, terminal input and rendered output in an isolated session. Use for Pardes interaction, plugin development and end-to-end debugging. +description: Inspect and drive a running Pardes editor through its 9P control filesystem, or exercise its panes, builtins, terminal input and rendered output in an isolated session. Use for Pardes interaction, plugin development and end-to-end debugging. --- # Pardes over 9P -Pardes is driven by reading and writing files. Prefer ordinary file tools over -a mount; reach for the Python client only when nothing is mounted, or when the -work needs a fid held open. Do not build another wire client: project tooling -stays in Zig. Run the examples from the repository root; paths below are -relative to that root unless linked. +Pardes is files: `cat`, `echo >`, `ls` and shell scripts are the whole +interface. [docs/fs.md](../../../docs/fs.md) is the reference for every +file; this page is recipes. Paths are relative to the repository root. -## Find the session through the mount - -Check `$NINE_MOUNT` first. `9ns --mntgen` sets it for every process it starts -(an interactive shell on this machine runs inside one), so a set `$NINE_MOUNT` -means the posted-9P registry is mounted there, usually `/mnt/9p`, and each -running editor is a directory `$NINE_MOUNT/pardes//` (a `--detach=NAME` -session's is `pardes/NAME/`; `pardes --detach=NAME &` runs the editor as -that process, so `$!` is its pid, and `$m/status`'s first line, `pid `, -says the same). Inside a pane, `$PARDES_9P` is that session's -socket (`/run/user/1000/pardes-9p-.sock`), which names the -directory either way, and `$PARDES_PANE` is the calling pane's serial: +## Find the session ```sh [ -n "$NINE_MOUNT" ] || echo 'no 9P mount: use the Python client below' s=${PARDES_9P##*/pardes-9p-}; m=$NINE_MOUNT/pardes/${s%.sock} -# under `9ns --unix SOCKET -- cmd` the session is the mount itself: m=$NINE_MOUNT cat "$m/index" -cat "$m/pane/$PARDES_PANE/body" ``` -From there the editor is files: `cat`, `echo >`, `ls` and shell scripts are -the whole interface, and nothing below needs more than they do. +`$NINE_MOUNT` is set by `9ns --mntgen` (usually `/mnt/9p`). `$PARDES_9P` is +the session socket of the pane you run in, `$PARDES_PANE` that pane's +serial. Under `9ns --unix SOCK -- cmd` the session is the mount itself: +`m=$NINE_MOUNT`. In a `Tty9p` shell: `m=$PARDES_MOUNT`. A dead session's +entry answers `Input/output error`: name the session, never glob. A running +session serves the binary that started it. + +## Look around -`pardes FILE` run in a pane opens FILE in that session and returns at once; -`pardes --wait FILE` returns when that pane is deleted (1 if the session goes -away), which is what `EDITOR='pardes --wait'` needs (`GIT_EDITOR` follows it). +```sh +cat "$m/index" # serial kind dirty name column, a pane a line +cat "$m/layout" # columns, then `active ` +cat "$m/focus" # the pane with the keyboard +cat "$m/README" # the one-screen guide +cat "$m/commands" # every builtin and where it goes +``` -Entries for dead sessions stay listed and answer `Input/output error` on any -access, so name the session you mean rather than globbing or taking the newest. -`cat "$m/index"` is the cheapest liveness check, and `cat "$m/status"` reports -the `pid`, `version` and `panes` of a session new enough to serve it. +Parse an index row with `rsplit(maxsplit=1)` first: names may hold blanks. +Re-read the index after anything that opens or closes panes. -`$NINE_MOUNT/pardes` is the registry of posted sessions, mounted once for the -machine. It is not the per-pane kernel mount the `Tty9p` builtin makes, which -gives one pane's shell `$PARDES_MOUNT`; see [docs/v9fs.md](../../../docs/v9fs.md) -for that. Either mountpoint serves the same tree. A `9ns --unix SOCKET -- cmd` -mount exists only inside `cmd`'s private namespace, and there `$NINE_MOUNT` is -the session's own root (`$NINE_MOUNT/index`), not a registry; to share one, -use the registry (`9ns --mntgen`). +## Open a file, go to a place + +```sh +echo "$PWD/main.zig:120" > "$m/look"; cat "$m/look" # serial it landed in +echo "main.zig:0/fn main/" > "$m/look" # first match; without 0, the next after dot +``` -A running session serves whatever binary started it. If a listing does not -match this document, that session predates the change; restart it. +A miss opens nothing, reads back empty and logs an `err look: ...` +line; the write itself succeeds. `L:C` columns are bytes. -## The tree, and what to do with it +## Make, fill, name and save a pane +```sh +n=$(cat "$m/pane/new") # each open makes one: read it once +printf 'hello\n' > "$m/pane/$n/body" # > replaces the text +printf 'more\n' >> "$m/pane/$n/body" # >> appends +echo "$PWD/notes.txt" > "$m/pane/$n/name" +echo Save > "$m/pane/$n/ctl" +rmdir "$m/pane/$n" # close it, saved or not ``` -$m/README the served guide, worth reading first -$m/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name, column serial -$m/status pid, version, panes -$m/look write a line = a right click on it at the active pane (file:/re/, file:#n, :/re/ - select by address, as acme's look, from the file's dot: file:0/re/ for the - first match; file:N selects the line; a miss changes nothing, logs err, and - look reads back empty) -$m/exec write a line = a middle click: an editor command word, or a shell line -$m/pane//pty/run write one line, read `exit N` + its output, or `busy` / `error ...`, on the same open: - exec 3<>$m/pane/$n/pty/run; echo make >&3; cat <&3 - (a fresh terminal: waits for its first prompt; if none comes, interrupt the read) -$m/log recent events, then EOF: new|del|rename|save , msg , - run , exit , send , - ask , answer , changed - [reloaded|deleted] (under unsaved edits; a clean reload; gone from disk), - unsaved (each pane a refusal is about), newcol|delcol , restored|restoredcol , - dump|restore , err : - (exec 3<>$m/log; echo follow >&3; cat <&3 replays what is there, then waits for new - ones; `echo follow new` waits for new ones only; tail -f does not wait; - while read -r line <&3; do ...; done loses nothing within a session (through - FUSE, `read -t` never times out: use `timeout N` around the loop): a Restore - hangs every connection up, so dial again, and restart a 9ns mount) -$m/screen the rendered screen as JSON, frozen per open -$m/listeners this session's dial addresses -$m/focus the serial of the pane with the keyboard (empty while a column/workspace tag has it); - echo a serial into it to move the keyboard (a folded pane stays folded) -$m/ctl the settings, one a line as a write takes them; write a setting or a session builtin; - `size ` sizes a --detach session no frontend is attached to (160x50 before) - (Newcol makes an empty column, Dump, Theme x; Exit QUITS the editor, Kill [word...] stops the - commands pardes started (command panes, lines it typed into shells), a word - matching a command line's first word; Exit and Restore refuse once, - logging `unsaved ` for each unsaved pane, then failing the write with - `: Modified (Exit again to discard)` for one or `4 unsaved panes: Modified (Exit - again to discard)` for more (Restore's says `Restore again`); on screen the list stays - in the one +Unsaved pane under a short notice (`3 unsaved panes — Exit again to discard`); a second refusal names only the panes edited since the last, - as acme's does, and the same word again with nothing edited since DISCARDS them all -- not a retry, unlike lock's `file in use`; - Kill stops a command pane's whole line, `&` jobs included; of a line typed into a - shell only the foreground job, and the shell decides the rest (of `sleep 30; echo done` - bash and fish both run the echo); Joincol folds the keyboard's column into the one - on its right, its panes going below that column's own, in order, and needs such a column); - a pane's builtins (Del, Save f, Collapse, which folds that pane, and the - column word Delcol, which closes that pane's column) go to $m/pane//ctl -$m/commands every builtin: `Word`, `Word arg`, then `root`, `pane` or `both` (which ctl takes - it), a setting's values comma-joined, then ` -- ` and one sentence of what it does -$m/recent files opened lately, closed ones too, most recent first: `open|closed `; - lost a file you closed? read this, or run Recent and look at its row to reopen it -$m/layout one line per column (16 columns at most: Newcol past that fails, no space for a column): serial index x width current|notcurrent empty|full pane-serials...; active -$m/tag the workspace tag (> replaces, >> appends, one line); $m/col//tag a column's (serials stay, as panes' do) -$m/tagexec a word as a click in the workspace tag (pane//tagexec: in that pane's tag); every exec - file reads back the serials its last write touched -$m/col//ctl Delcol, Joincol, New, Tty on that column; col//exec a word as a click in its tag; - rmdir col/ closes an empty column -$m/pane/new open it to make a pane (a scratch named /+New), read names it; it goes in - the ACTIVE column (the one last typed or clicked in, or Newcol's), filling it if - empty, else taking the bottom half of its last pane (ctl `Placement pardes`: the old rules); - a session holds 64 panes (16 on the board): past that, every route that opens one - fails with `no space for a pane: 64 max` (ENOSPC), and so does one whose column - has no room (each pane keeps its tag and 2 rows: `no space for a pane in that column`); rmdir $m/pane/ closes it; a column's last pane leaves the column EMPTY - (focus reads empty, the log says only del), and the session's LAST pane QUITS it -$m/pane//errors write-only: text appended to the +Errors pane of the pane's directory -$m/os/ the host filesystem + +## Edit text + +```sh +p=$m/pane/$n +echo 'Edit ,x/foo/c/bar/' > $p/ctl # sam edit, one undo step +echo '/old/' > $p/addr; printf 'new' > $p/data # replace the next match +echo 0 > $p/addr # back to the top +echo '3' > $p/addr; : > $p/data # delete line 3 +cp $p/addr $p/dot; cat $p/sel # select it, read the selection ``` -The first field of an index row is a stable pane serial, not a slot or row -number. A row is `serial kind dirty name column`, the last word the pane's -column serial, so `head, col = row.rsplit(maxsplit=1)` then -`serial, kind, dirty, name = head.split(maxsplit=3)` keeps a name with spaces -intact. Re-read the index after anything that might open, -reuse or close a pane. +`addr` searches on from the last address (it is the pane's, shared by all +clients); after a `data` write it sits just past the text, so write `addr` +before each replacement. A failed `addr` leaves none and `data` refuses: +check the write's status. An Edit block of several lines goes in one open: +`printf 'Edit ,x/foo/{\ni//\n}\n' > $p/ctl`. + +## Run a command ```sh -cat "$m/index" # which panes exist -n=$(cat "$m/pane/new") # make one, take its serial -printf 'text\n' > "$m/pane/$n/body" # replace its text (> truncates) -printf 'more\n' >> "$m/pane/$n/body" # append -cat "$m/pane/$n/tag" # what its tagline offers -echo notes.txt > "$m/pane/$n/name" # rename the buffer -echo Save > "$m/pane/$n/exec" # save it (or to its ctl) -echo Tty > "$m/pane/$n/ctl" # a terminal in its directory -echo "/etc/hosts:3" > "$m/look"; cat "$m/look" # open a file, see where it landed -rmdir "$m/pane/$n" # close it, dirty or not +echo 'make test' > "$m/exec"; c=$(cat "$m/exec") # a command pane; its serial +grep "^exit $c " "$m/log" | tail -1 # `exit ` once done ``` -A session may open its own mount from inside itself: a Look at `$m/anything` -in the editor that serves `$m` is answered on the connection's task while the -editor's own syscall waits. `/n/self/...` names the same tree without leaving -the process. - -**Opening** `$m/pane/new` is what makes a pane, and reading the open file -answers its serial — `/net/tcp/clone`'s mechanism. Each open makes another one, -two reads of the same open file answer the same serial, and closing it leaves -the pane. A pane is named by the serial the editor gives it, never by a name -you choose. - -A *stat* makes nothing, which is the whole reason the allocation sits on open: -`new` is listed in `$m/pane`, so `ls` shows it, and `ls -l`, `find` and -anything else that stats every name a listing handed it stay inert. acme -allocates on the walk instead and lets it land inside the new window, so -`/dev/new/body` works in one step — it can afford that because a Plan 9 -directory read carries every entry's stat and nothing walks. Under a kernel or -FUSE mount that would be a pane per `ls -l`. Nothing else in the tree can be -created or removed, and no read creates anything. - -`look` and `exec` are the editor's two clicks, one per line of a write, at the -active pane from the root and at that pane from `$m/pane//look` and -`$m/pane//exec`. Reading any of them answers the serials the last command -made, or the pane it focused or acted on: an open's own last write's, or, on -an open that never wrote, the session's last. With other clients about, -write and read one open (`exec 3<>$m/look; echo x >&3; cat <&3; exec 3<&-`). -A read is a stream: once read, a second read on the same fd gives EOF (on -an open that wrote, until its next write); open again, or seek to 0, to read -it again. Each command line runs once whole, however a mount cuts a big write; a -write's last line with no newline runs with it (and fails it), unless the -write filled its 9P message and may go on; an Edit block still open when the -file closes fails there (an `err`: ``unmatched `{'``, or an a/c/i text with no `.` -line), changing nothing. One rule: a builtin that fails, whether through a -ctl (a pane's pty/ctl `exec` too), look, exec, tagexec or a column's exec, -fails the write (EINVAL for a malformed line, ENOENT for what is not there -- -a directory gone, a Find or Grep with no hit -- else EIO or an errno that -fits) and logs one `err` with the reason, no `msg`. A look that finds nothing is no failure: it answers -nothing and logs one `err`. A command line run in a command pane is judged -by its `exit` record. A word no builtin -knows (a typo included) is a command line: written at a terminal at its -prompt it is typed into that shell; from anywhere else it runs as a command -pane, a terminal whose child is the root ctl's `Shell` ($SHELL, else /bin/sh, unless set) -running `-c` the line in the pane's directory, which ends showing `exit N` (a typo: `exit 127`) and logs `run - ` and `exit ` -- `exec` reads back its serial, -so follow `log` for the exit. The directory's next command reuses a finished -command pane, below what it showed. A terminal bound as a REPL (`Repl -python` on its ctl) takes the middle clicks made on a `.py` body instead, -but never a 9P write: a script sends code by writing the REPL pane's -`pty/data`, and runs a command from such a file with `Exec ` or the -tag. A bound terminal's `ctl` line ends with its id (`python-a`); an event -record written back from such a file's body goes to its REPL, as the click -would. `Repl -` unbinds; a bare `Repl` says the binding. With several -REPLs bound for a language an exec asks which, logged `ask repl a b` -(Del's side from the keyboard is `ask del k j`): answer with -`echo 'answer a' > $m/pane//ctl`, or `answer -` to send nothing (the -log says `answer a|-`). Kill does not stop what a REPL runs (it was -typed, not started by pardes): `echo 'sig INT' > $m/pane//pty/ctl` -interrupts it. A range of a `.py` pane goes to its REPL by writing the event -record `MX ` to that pane's `event`. A chorded exec's record (flag 8) -is followed by two, its argument and where it came from; write all three back -as read (one write or three) and it runs once with its argument. `Tty`'s argument is a shell -(`Tty fish`), and `Tty` on a pane's ctl opens a new terminal pane. After a -Restore, panes have new serials (`restored ` in the log), a -command pane shows how it ended, `exit N` (`exit ?` if it was still running when -dumped), and does not run again, and REPLs are unbound. Multi-line code -written to `pty/data` should be a bracketed paste, `\e[200~\e[201~`, -then, in a separate write once the REPL has echoed the paste (Python 3.13+ -takes a `\r` read with the paste as part of it, even for one line), `\r`. -A paste of one line needs that one `\r`; a paste of more than one line -needs a second `\r` unless the pasted code ends in a newline (one Enter -leaves a multi-line input at `...`). A middle click, or an event -write-back, sends what it needs by itself. Sent line by line, a blank line ends a Python block, and Python -3.14's REPL auto-indents each line it is typed. Every refused 9P write adds an `err -: ` record to `$m/log`; through a mount the write itself only says -`Invalid argument`. Only writes log one: a refused open or truncation -(an OTRUNC open, as `data`'s after a failed `addr`), create or remove is -its error alone, as are a write to `pane/new` (`permission denied`) and a -write on a fid opened read-only (`bad use of fid`). Errors are words, never -a C errno string. A look miss quotes what was written: `no match for "zzq:#3"`. - -## Edit through addresses, dot and the flag files - -For a file or scratch pane, with `pane=$m/pane/`: - -Rename everywhere, or any sam edit, is one write: `echo 'Edit ,x/foo/c/bar/' -> $pane/ctl`. `Edit` takes sam's command language (acme's): addresses, `x y g -v c a i d s p = m t u` and `{ }` (commands in braces one to a line, so from -exec or a tag, not a one-line ctl write). Its changes are one undo step, and -one that fails changes nothing and fails the write with acme's words (`Edit: -no substitution`), logged as `err`; an `x` that finds nothing is no failure -(sam's), so `,x/zzz/c/bar/` with no `zzz` succeeds silently. A block goes to the pane's `ctl`, the -root `ctl` (the active pane) or `exec` on one open, in one write or several -(bash's `printf` writes line by line): an `Edit` line takes the lines after it -until its `{` closes or its `a`/`c`/`i` text ends with `.`, and runs then. `sel` -reads the selected text, and a write to it replaces the selection: +At a terminal's prompt, run and get the status and output in one go: ```sh -cat > $pane/ctl <<'END' -Edit ,x/area_of/{ -i/[/ -a/]/ -} -END -env printf 'Edit ,x/foo/{\ni//\n}\n' > $pane/ctl +t=$(awk '$2=="term"{print $1; exit}' "$m/index") +exec 3<>"$m/pane/$t/pty/run"; echo 'ls' >&3; cat <&3; exec 3<&- # `exit N`, then output +printf 'q' > "$m/pane/$t/pty/data" # raw keystrokes (\r Enter, \x03 Ctrl-C) +echo 'sig INT' > "$m/pane/$t/pty/ctl" # interrupt ``` - `p` and `=` print to the directory's -`+Errors`. Not there: `b B D e r w f X Y`, `< | >`, and `\1`-`\9` in `s`. - -> **sam gotchas** (as sam does them, pardes too) -> - `$-1` is the last line when the text ends in a newline (`a\nb\n`: `b\n`), -> but the one before it when it does not (`a\nb`: `$` is on `b`, so `a\n`). -> - With a final newline, the line after the last is the empty place at the -> end, not an error: `N+1` at the last line is `#,#`. Without one -> (`a\nb`), the last line runs to the end and `N+1` is out of range. -> - `^` and `$` match at the text's end too: `/^/` from the end finds the -> empty place after a final newline. -> - `2,1` is no error: it is `#,#`, an empty range at -> line 2's start (only a range whose end is before its start is refused). -> - `y` yields the stretch before the first match too, empty if the text -> starts with one: `,y/a/` on `abc` gives `` and `bc`. -> - `c/&/` puts a literal `&`; only `s` expands `&` to the match. -> - `line:col` columns count bytes from 1: `12:0` is refused -> (`a column counts from 1`); a tool's character column is the same only -> on an ASCII line. - -| Operation | Shell | Python client | -|---|---|---| -| Read text | `cat $pane/body` | `client.read(pane + '/body')` | -| Append text | `echo text >> $pane/body` | `client.write(pane + '/body', b'text\n')` | -| Replace all text | `echo text > $pane/body` | `client.write(pane + '/body', b'text\n', truncate=True)` | -| Address a byte range | `echo '#0,#2' > $pane/addr` | `client.write(pane + '/addr', b'#0,#2')` | -| Replace that range | `printf 'pub fn' > $pane/data` (`>>` too) | `client.write(pane + '/data', b'pub fn')` | -| Delete that range | `: > $pane/data` | truncate `data` (open with OTRUNC) | - -A write leaves `addr` just past what it wrote, so a second `echo x > data` -inserts after the first: write `addr` again before each replacement. The -writes of one open of `data` are one undo step (a multi-line `printf` too); -to make a loop's writes one, `echo 1 > mark` -(an undo point now), `echo 0 > mark`, the writes, then `echo 1 > mark`. -A `+New` scratch counts as unsaved (and holds up Exit, Restore, Del) only -once it holds 100 bytes or more. A read -of `data` or `xdata` moves `addr` past what it read, as in acme. -Truncating `data` is pardes's own (acme ignores OTRUNC and always inserts). -plan9port's `9p write` always opens with OTRUNC, so `… | 9p write pane/body` -replaces the whole body: append with `>>` through a mount instead. -| Read the selection | `cat $pane/dot` (offsets), `cat $pane/sel` (text) | the same two reads | -| Select the addressed range | `cp $pane/addr $pane/dot` | `client.write(pane + '/dot', client.read(pane + '/addr'))` | -| Reload from disk | `echo get > $pane/ctl` (refused once while there are unsaved edits; again discards) | `client.write(pane + '/ctl', b'get\n')` | -| Close it | `rmdir $pane` | `client.remove(pane)` | - -`addr`, `dot` and `limit` each read the pair of offsets they also accept, which -is why copying one onto another is all that acme's `addr=dot`, `dot=addr` and -`limit=addr` ever were; a write may also be an address expression (`#0,#5`, -`/pattern/`, `2+1`, or pardes's `12:5`: line 12, byte column 5, composing as -`12:5,14:1`; a Recent, +Search or Jumplist row's `12:5-14:2` is taken too, -through 14:2 inclusive), whose regexps are mvzr's searched as sam searches: -`^`/`$` match at any line's start and end, `.` and `[^...]` never match a -newline, the leftmost match wins (the first alternative there, not the -longest). In a pattern with `\n`, `^` works only first (`^def .*\n` finds -every def line) and `$` only just before a `\n`; anywhere else the pattern is -refused, not silently unmatched. `^def|^ ` finds lines starting either way -(every branch anchored; a mix like `^def|x` is refused). `[éa-z]` and -`[à-ÿ]` match those runes (a range up to 256 runes); `[^é]` and a wider -range are refused. An expression is evaluated from the current address (the last one -written, or just past the last `data` write): `.` is that address, not the -selection, `/re/` searches on from its end and wraps unless `limit` is set, -`?re?` or `-/re/` searches back, `#100,#50` fails `addresses out of order`, -and one search that runs past its step budget (about 300 ms; each search of -an Edit `x` has its own) fails with `regular expression search took too -much time, gave up`. A failed address says -why (`no match for regexp`, `address out of range`) and leaves no address: -`addr` reads empty and `data` refuses until the next good one, so a missed target is never -written at the old one. Moving `dot` scrolls the pane to it. `limit` bounds -only the end of a forward search, as in acme, and reads empty until set; -truncate it to lift it. In `12:5` the column counts bytes from 1 and clamps -past the end of the line; a line past the end is `address out of range`. -A refused write repeated the same way is one `err` line counted, `(x4)`. - -`dirty`, `mark` and `scroll` read `0` or `1` and take `0` or `1`: whether the -buffer differs from its file, whether a write pushes an undo point, and whether -a write scrolls. `tag` reads the path, then the text you may edit: `> tag` -replaces that text (default words too), `>> tag` appends to it. - -Address state belongs to the pane, not to a client: it keeps the last range -written until someone writes another, so writing an address and reading it back -evaluates it, and two clients addressing the same pane will interfere. Neither -an open nor a `>` resets it (acme resets it on the first open): each `echo /re/ -> addr` searches on from the last address, so a find-and-replace loop advances. -Write `0` to start from the top. The search wraps, so stop a find-all loop when -the address comes back to where it began, or set `limit`. -`$pane/ctl` reads acme's window status line — serial, tag length, body length, -isdir (0), the dirty flag, the width in cells, the font, the tab width, the -undo flag and the redo flag, as acme's fields — then `current` or -`notcurrent` — and takes `get` (reload from disk), -`lock`/`unlock`, and any builtin that acts on a pane (`Del`, `Save f`, -`Collapse`, `Undo`/`Redo`: 256 steps; with none left they say so, and the -write succeeds). A `lock` another open holds fails at once with `file in use` -(EBUSY): retry it. Session builtins and settings go to the root `ctl`, which reads -back every setting in the syntax it takes. A ctl write is checked whole -first and refused as `unknown control message "X"` (EINVAL) and the like, -a required argument missing included (`wrong #args ... "Mount"`); then a line -whose builtin reports an error fails the write with that error and the line -(EIO, or an errno that fits: ENOENT for a missing pane, file or dump), after the lines before it took effect. A `Save` on a scratch fails -rather than prompt. The lock binds only clients that take it, and is held by the -open that wrote it, so a shell holds an fd across the edit: -`exec 3>$pane/ctl; echo lock >&3; ...; exec 3>&-`. - -Terminal panes have no file: writing their `body` sends child input, and -truncation does not erase terminal history. - -## The Python client, for what a shell cannot express - -Use the existing [Python client](../../../test/ninep.py) when there is no -mount, or when the work needs a fid held open across several operations — -`log`, `event` and `pty/data` are consuming queues whose reads park, and shell -redirection cannot hold one open. + +`busy: is running` means the prompt is not free: a program holds +the terminal, so talk to it through `pty/data`. + +## Follow what happens + +```sh +exec 3<>"$m/log"; echo 'follow new' >&3 +timeout 30 cat <&3 # one record a line, as they come +exec 3<&- +``` + +`follow` (without `new`) replays the ring first. `tail -f` sees nothing new. +Through FUSE `read -t` never times out: use `timeout`. After a `Restore` +every connection is cut: dial again and restart the mount. + +## Traps + +- A refused write says only `Invalid argument` or `Input/output error`; the + reason is the `err` line in `$m/log` (`tail -1 "$m/log"`). +- Only writes log: a refused open, truncation (`> data` after a failed + `addr`) or `rmdir` has its errno alone. +- Settings and session words go to `$m/ctl`; pane words (`Undo`, `Save`, + `Del`) to `$m/pane//ctl`. The wrong one is refused naming the right one. +- `Exit`, `Restore`, `Del`, `get` refuse once over unsaved text; the same word + again discards. +- A word no builtin knows is a shell command (`exit 127` if a typo). +- `lock` needs a held fd: `exec 3>$p/ctl; echo lock >&3; ...; exec 3>&-`. +- plan9port `9p write` truncates: it replaces a whole `body`. + +## No mount: the Python client + +Use [test/ninep.py](../../../test/ninep.py) when nothing is mounted, or when +a fid must stay open (`event`, `pty/data`, a followed `log`). Its paths are +the served root (`/index`, `/pane/2/body`). ```sh PYTHONPATH=test python3 -B - "$PARDES_9P" <<'PY' import sys from ninep import Client - -with Client(sys.argv[1]) as client: - print(client.read('/index').decode(), end='') - print(client.read('/listeners').decode(), end='') +with Client(sys.argv[1]) as c: + print(c.read('/index').decode(), end='') + n = int(c.read('/pane/new')) + c.write(f'/pane/{n}/body', b'hello\n', truncate=True) + fid = c.open(f'/pane/{n}/event', 0) # hold event: clicks come here + c.write(f'/pane/{n}/exec', b'Msg hi\n') + print(c.read_fid(fid, 0, 4096)) # b'FX0 0 1 6 Msg hi\n' + c.close(fid) + c.remove(f'/pane/{n}') PY ``` -`Client` takes a raw Unix socket path, or `(numeric_ip, port)` for TCP; it does -not parse Pardes dial strings or implement QUIC. It negotiates 9P2000, uses a -five-second socket timeout, and closes on leaving `with`. Its paths are the -served root: `/index`, `/pane/2/body`, `/os/...`. `/n/self`, `/n/os`, `/n/peer` -and `/virtual` are editor Look paths, not server paths — Look -`/virtual/src/pardes.zig` corresponds to reading `/src/pardes.zig`. - -For live terminal output or plugin events, use `open` / `read_fid` / `close`, -not the read-until-EOF helper. `pty/data` captures output while held open; it -is not a history replay. Both files are shared, consuming queues, not -per-client broadcasts, so a slow reader loses older data. Holding `event` open -intercepts that pane's Look and Exec clicks -- and lines written to that pane's -own `look`/`exec`, or to the root's while it has the keyboard, as `F` records -at `0 0` with the text, and clicks in a terminal's body, also at `0 0` -- so -it is not a passive logger: a helper holding `event` that writes its own -pane's exec gets its command back as a record; run it through `ctl` or write -the record back. To have a record done, write it back: the short form -` \n` acts on that range's text, and the whole record -as read acts on its text when the range is empty (the only way for a record -at `0 0`). Chord reports need explicit handling. A record is -` \n` and its text may hold -newlines: read `n` bytes of text, never up to the next newline (acme counts -runes; pardes counts bytes, as all its offsets are). Every address lands on a -rune boundary, never inside one and never widened to a grapheme cluster: `#n` -or `line:col` inside a rune snaps back to its start, a match covers the runes -it touches, and a combining mark or a CRLF's `\r` is addressable alone. -A Restore puts a new editor under every client: the Restore write is -answered, then every connection is hung up (their fids name the old -editor's panes); dial again, and the new log has a `new` for each restored pane, then -`restore `, then `restored ` for each pane and -`restoredcol ` for each column -- `restore ` the authority, since a slow client may see the cut -before the answer. A 9ns older than cloud9 2a7137c could fail the Restore -write with ECONNRESET although the Restore went ahead; trust the log. `Dump` writes `pardes--