summaryrefslogtreecommitdiff
path: root/tests.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-06-30 20:29:05 -0300
committerGabriel Schneider <[email protected]>2026-06-30 20:29:27 -0300
commit8b60c2c29c016c7db0fa6ee63769cea1defd9b3c (patch)
tree24935a622521142b3754df6de0a95c6cef5a5e18 /tests.zig
parent1f65d7368c9a31427b145f683eb891da16181b73 (diff)
downloadpardes-8b60c2c29c016c7db0fa6ee63769cea1defd9b3c.tar.gz
pardes-8b60c2c29c016c7db0fa6ee63769cea1defd9b3c.zip
minor fixes
Diffstat (limited to 'tests.zig')
-rw-r--r--tests.zig111
1 files changed, 107 insertions, 4 deletions
diff --git a/tests.zig b/tests.zig
index 51b4e83a..bd44e2ea 100644
--- a/tests.zig
+++ b/tests.zig
@@ -72,7 +72,9 @@ pub fn main(init: std.process.Init) !void {
try hs.pump(600);
try hs.send("printf '#!/bin/sh\\necho ZZTABRAN\\n' > /tmp/zztabcmd; chmod +x /tmp/zztabcmd; clear; echo /tmp/zztabcmd\r");
try hs.pump(1200);
- try hs.send("\x1b[<0;8;3M\x1b[<0;8;3m"); // left-click the path on body row 0 -> normal + pin (+1 row: global tagbar)
+ try hs.send("\x02"); // tty -> normal (Ctrl-b): the mouse no longer exits tty mode
+ try hs.pump(600);
+ try hs.send("\x1b[<0;8;3M\x1b[<0;8;3m"); // left-click the path on body row 0 -> pin the cursor on it (+1 row: global tagbar)
try hs.pump(600);
try hs.send("\t"); // TAB: execute "/tmp/zztabcmd"
try hs.expectWaitFor("ZZTABRAN", 8000, "normal-mode Tab did not execute the word under the cursor");
@@ -141,6 +143,12 @@ pub fn main(init: std.process.Init) !void {
try hs.expectWaitFor(marker, 8000, "tty mode did not forward the marker to the shell");
try hs.expectContains("sy /", "no 'sy' indicator after Ctrl-b (tty mode)");
+ // 4a. The mouse stays in tty mode: a body left-click (press+release) must NOT
+ // drop to normal — only Ctrl-b exits tty now. The tag stays "sy".
+ try hs.send("\x1b[<0;6;4M\x1b[<0;6;4m"); // left-click + release in the body
+ try hs.pump(500);
+ try hs.expectContains("sy /", "a left-click in tty mode wrongly returned to normal");
+
// 4b. Ctrl-b toggles back: tty -> normal. Send Ctrl-b again and confirm the
// tag flips off "sy" (raw tty) back to "nm" (normal).
try hs.send("\x02"); // tty -> normal (Ctrl-b)
@@ -151,12 +159,14 @@ pub fn main(init: std.process.Init) !void {
// 5. Prompt hiding in TEXT mode. tty shows the real terminal (command line +
// output). BOTH normal and insert hide the prompt/command rows (the acme
- // compose surface) while keeping output. Run a command in tty, left-click
- // to NORMAL, and check: output present, the command's prompt row hidden.
+ // compose surface) while keeping output. Run a command in tty, Ctrl-b to
+ // NORMAL, and check: output present, the command's prompt row hidden.
try hs.send("echo CMDHIDEZZ\r");
try hs.expectWaitFor("CMDHIDEZZ", 8000, "tty mode did not run the command");
try hs.pump(800); // let tty-mode frames settle
- try hs.send("\x1b[<0;6;4M\x1b[<0;6;4m"); // left-click body -> normal (prompts now hidden) (+1 row: global tagbar)
+ try hs.send("\x02"); // tty -> normal (Ctrl-b): the mouse no longer exits tty mode
+ try hs.pump(600);
+ try hs.send("\x1b[<0;6;4M\x1b[<0;6;4m"); // left-click body to pin the cursor (already normal) (+1 row: global tagbar)
try hs.pump(600);
try hs.expectContains("CMDHIDEZZ", "command output not shown in normal mode");
// The prompt row (with the typed command) is hidden in normal mode now too. We
@@ -267,6 +277,34 @@ pub fn main(init: std.process.Init) !void {
// sanity: the deep marker (line 150, above the opened/deleted line) survives.
try hs.expectContains("ZZDEEPMARK", "ZZDEEPMARK vanished — file pane content was clobbered");
+ // 10b. Char-wise select (`v`) + delete, then undo/redo. Open a line, type a
+ // marker, `0` to the line start, `v` to start a char selection, `$` to
+ // extend to the line end, `d` to delete the range (gone), `u` to undo it
+ // (back), `U` to redo (gone again). Proves v-select, real char-range
+ // deletion, and the dumb undo/redo stack on a file pane.
+ try hs.send("o"); // open line below -> insert
+ try hs.pump(500);
+ try hs.send("ZZVSELMARK");
+ try hs.pump(500);
+ try hs.send("\x1b"); // -> normal, cursor on the new line
+ try hs.pump(500);
+ try hs.expectContains("ZZVSELMARK", "char-select setup: typed marker not shown");
+ try hs.send("0"); // line start
+ try hs.pump(300);
+ try hs.send("v"); // start char selection
+ try hs.pump(300);
+ try hs.send("$"); // extend the selection to the line end
+ try hs.pump(300);
+ try hs.send("d"); // delete the selected char range
+ try hs.pump(800);
+ try hs.expectNotContains("ZZVSELMARK", "v + $ + d did not delete the char selection");
+ try hs.send("u"); // undo the delete
+ try hs.pump(800);
+ try hs.expectContains("ZZVSELMARK", "u (undo) did not restore the deleted text");
+ try hs.send("U"); // redo the delete
+ try hs.pump(800);
+ try hs.expectNotContains("ZZVSELMARK", "U (redo) did not re-apply the delete");
+
// 11. The Tutor builtin now lives in the GLOBAL tagbar (top row, full width):
// "Kill Newcol Tutor Debug". Clicking "Tutor" there spawns the tutor as a
// file pane. The tutor is embedded in the binary (@embedFile), so its
@@ -289,4 +327,69 @@ pub fn main(init: std.process.Init) !void {
try hs2.send("echo ZZTTYFLAG\r");
try hs2.expectWaitFor("ZZTTYFLAG", 8000, "--tty single shell did not forward input to the shell");
}
+
+ // 13. Terminal char-mode editing end to end (fresh instance for a clean pane):
+ // insert an overlay run, backspace part of it, Ctrl-b to tty (overlay hidden)
+ // and back (overlay returns), then u (undo the whole insert) / U (redo).
+ {
+ var hs3 = try Harness.init(gpa, exe.ptr, 24, 80);
+ defer hs3.deinit();
+ try hs3.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ // pin the cursor on the top-left pane and type a marker (insert mode).
+ try hs3.send("\x1b[<0;5;8M\x1b[<0;5;8m"); // left-click -> normal + pin (+1 row: global tagbar)
+ try hs3.pump(400);
+ try hs3.send("i");
+ try hs3.pump(300);
+ try hs3.send("ZZTERMINSXYZ");
+ try hs3.pump(500);
+ try hs3.expectContains("ZZTERMINSXYZ", "terminal insert did not show the typed overlay");
+ // insert-mode backspace erases within the run: drop the trailing "XYZ".
+ try hs3.send("\x7f\x7f\x7f");
+ try hs3.pump(500);
+ try hs3.expectNotContains("ZZTERMINSXYZ", "terminal insert-mode backspace did not erase typed text");
+ try hs3.expectContains("ZZTERMINS", "backspace erased too much of the run");
+ try hs3.send("\x1b"); // insert -> normal
+ try hs3.pump(400);
+ try hs3.send("\x02"); // normal -> tty: the overlay is hidden
+ try hs3.pump(700);
+ try hs3.expectNotContains("ZZTERMINS", "tty mode did not hide the inserted-text overlay");
+ try hs3.send("\x02"); // tty -> normal: the overlay returns
+ try hs3.pump(700);
+ try hs3.expectContains("ZZTERMINS", "overlay did not return after leaving tty mode");
+ try hs3.send("u"); // undo the whole insert session
+ try hs3.pump(600);
+ try hs3.expectNotContains("ZZTERMINS", "u (undo) did not remove the terminal insertion");
+ try hs3.send("U"); // redo
+ try hs3.pump(600);
+ try hs3.expectContains("ZZTERMINS", "U (redo) did not restore the terminal insertion");
+ }
+
+ // 14. Normal-mode Tab/Enter act on the SELECTION when one is active (not the
+ // word under the cursor). Clear a fresh pane, type a computed command as an
+ // overlay, `x` to select the whole line, Tab -> the SELECTION runs. The
+ // output marker (ZZSEL5X) differs from the source ($((2+3))) so it only
+ // matches if the selection actually executed.
+ {
+ var hs4 = try Harness.init(gpa, exe.ptr, 24, 80);
+ defer hs4.deinit();
+ try hs4.expectWaitFor("build.zig", 8000, "fresh terminal never auto-ls'd");
+ try hs4.send("\x02"); // normal -> tty
+ try hs4.pump(500);
+ try hs4.send("clear\r"); // blank the pane, prompt to row 0
+ try hs4.pump(900);
+ try hs4.send("\x02"); // tty -> normal
+ try hs4.pump(400);
+ try hs4.send("\x1b[<0;2;6M\x1b[<0;2;6m"); // pin a blank low row near col 0
+ try hs4.pump(400);
+ try hs4.send("i");
+ try hs4.pump(300);
+ try hs4.send("echo ZZSEL$((2+3))X"); // overlay; output is "ZZSEL5X"
+ try hs4.pump(500);
+ try hs4.send("\x1b"); // -> normal
+ try hs4.pump(400);
+ try hs4.send("x"); // select the whole typed line
+ try hs4.pump(400);
+ try hs4.send("\t"); // Tab: execute the SELECTION (not the word under cursor)
+ try hs4.expectWaitFor("ZZSEL5X", 8000, "Tab on a selection did not execute the selected text");
+ }
}