diff options
| -rw-r--r-- | next-next-steps.txt | 8 | ||||
| -rw-r--r-- | src/pardes.zig | 18 | ||||
| -rw-r--r-- | src/tutor.txt | 1 | ||||
| -rw-r--r-- | test/snapshots/ttyclick.golden | 124 | ||||
| -rw-r--r-- | test/snapshots/ttyclick.snap | 32 |
5 files changed, 175 insertions, 8 deletions
diff --git a/next-next-steps.txt b/next-next-steps.txt index 430f0a7c..e109ff38 100644 --- a/next-next-steps.txt +++ b/next-next-steps.txt @@ -1,10 +1,10 @@ - when clicking in a tty, don't change the mode, keep as it was - in insert/normal mode in a tty don't scroll for new input, only in tty mode -- implement missing acme mouse chords -- fix crash and decreasing font size on tty +- implement missing acme mouse chords (you should explore pardes and acme codebase to do a survey) +- fix crash when decreasing font size on tty - for the web version make LOOK on a file focus it if it's loaded as a pane on the snapshot - when using a command that needs a selection, if there's none of the current pane, look for selections in other panes. -- panes can be shinked to just have the tagline visible -- when a new pane is going to open, if the chosen parent would leave it if less that 2 rows (without counting the tagline), then choose a different one, if none is found then just choose the largest one in height +- panes can be shrinked to just have the tagline visible +- when a new pane is going to open, if the chosen parent would leave it with less than 5 rows (without counting the tagline), then choose a different one, if none is found then just choose the largest one in height on the target column - parse the argv so that when you run pardes with no arguments: it opens in tty mode, if you pass a file it'll open that file focused (with a terminal split on the directory pardes was opened from) and if you pass a directory it'll set pardes cwd to there - the gui should have a different binary name, and non linux-x64 should have the os and tag along the name too diff --git a/src/pardes.zig b/src/pardes.zig index 53ec4172..8fb0b43d 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -525,6 +525,9 @@ pub const Pane = struct { tag_init: bool = false, tag_edit: bool = false, tag_sel: bool = false, + /// the body mode a tag edit hijacked (tags are always insert); terminals + /// restore it on exit so clicking the tag never changes the pane's mode + tag_mode: Mode = .normal, tag_col: u16 = 0, tag_anchor: u16 = 0, ed_undo: std.ArrayList(EditSnap) = .empty, @@ -1001,6 +1004,7 @@ pub const Pardes = struct { pane.tag_tail.appendSlice(p.gpa, if (pane.file != null) file_pane_tail else pane_tail) catch return; pane.tag_init = true; } + if (!pane.tag_edit) pane.tag_mode = pane.mode; pane.tag_edit = true; pane.tag_sel = false; // a one-line tag has no use for normal mode: always insert @@ -1011,10 +1015,15 @@ pub const Pardes = struct { } fn exitTagEdit(pane: *Pane) void { + // tags are always insert; leaving one restores the body mode: files + // back to normal, terminals to whatever they had — a click (this runs + // on every body press) must never change a shell pane's mode + if (pane.isTerminal()) { + if (pane.tag_edit) pane.mode = pane.tag_mode; + } else pane.mode = .normal; pane.tag_edit = false; pane.tag_sel = false; pane.search_edit = false; // an abandoned `/` input stays as tag text - pane.mode = .normal; // tags are always insert; leaving one never is } fn tagSelBounds(pane: *Pane) struct { lo: usize, hi: usize } { @@ -3705,8 +3714,9 @@ pub const Pardes = struct { pane.sel[b].state = .done; if (s.button == .left) { // keep a dragged selection highlighted; a plain click clears - // it. Either way pin the cursor + enter normal mode on text - // panes (tty keeps the mouse usable without dropping modes). + // it. Either way pin the cursor; files also enter normal + // mode, terminals keep the mode they had (tty keeps the + // mouse usable, insert keeps typing where you clicked). const sl = pane.sel[0]; const dragged = sl.c0 != sl.c1 or sl.r0 != sl.r1; if (!dragged) pane.sel[0].state = .none; @@ -3716,7 +3726,7 @@ pub const Pardes = struct { pane.cur_col = if (pane.file != null) @max(0, sl.c1 - @as(i32, PREFIX_W)) + pane.hscroll else sl.c1; pane.cur_off = if (pane.runAt(pane.cur_row, pane.cur_col)) |i| pane.edits[i].len else 0; pane.cur_pinned = true; - pane.mode = .normal; + if (!pane.isTerminal()) pane.mode = .normal; pane.msel.active = false; pane.pending = 0; } diff --git a/src/tutor.txt b/src/tutor.txt index 4c162b97..815cd4f7 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -58,6 +58,7 @@ L select a plain click also FOCUSES the pane and PINS the modal cursor where you click, so you can edit there next. + A click never changes a pane's MODE (tty stays tty). M execute run the selected text: a builtin name runs it, anything else is SENT to the shell the pane runs. This is how you run a command you typed in a text mode. diff --git a/test/snapshots/ttyclick.golden b/test/snapshots/ttyclick.golden new file mode 100644 index 00000000..a02ed2b5 --- /dev/null +++ b/test/snapshots/ttyclick.golden @@ -0,0 +1,124 @@ +== snap tty-bodyclick grid=100x30 cursor=4,4 +|Kill Newcol Tutor Debug Colors NextColor Dump +| TTY /tmp/pardes-snap/ttyclick/cwd Del NOR /tmp/pardes-snap/ttyclick/cwd Del +| $ ls +| probe.txt probe.txt +| $ +| +| +| +| +| +| +| +| +| +| +| +| NOR /tmp/pardes-snap/ttyclick/cwd Del +| +| probe.txt +| +| +| +| +| +| +| +| +| +| +| +== snap tty-tagedit grid=100x30 cursor=39,1 +|Kill Newcol Tutor Debug Colors NextColor Dump +| INS /tmp/pardes-snap/ttyclick/cwd Del NOR /tmp/pardes-snap/ttyclick/cwd Del +| +| probe.txt probe.txt +| +| +| +| +| +| +| +| +| +| +| +| +| NOR /tmp/pardes-snap/ttyclick/cwd Del +| +| probe.txt +| +| +| +| +| +| +| +| +| +| +| +== snap tty-tagexit grid=100x30 cursor=4,4 +|Kill Newcol Tutor Debug Colors NextColor Dump +| TTY /tmp/pardes-snap/ttyclick/cwd Del NOR /tmp/pardes-snap/ttyclick/cwd Del +| $ ls +| probe.txt probe.txt +| $ +| +| +| +| +| +| +| +| +| +| +| +| NOR /tmp/pardes-snap/ttyclick/cwd Del +| +| probe.txt +| +| +| +| +| +| +| +| +| +| +| +== snap ins-bodyclick grid=100x30 cursor=11,3 +|Kill Newcol Tutor Debug Colors NextColor Dump +| INS /tmp/pardes-snap/ttyclick/cwd Del NOR /tmp/pardes-snap/ttyclick/cwd Del +| +| probe.txt probe.txt +| +| +| +| +| +| +| +| +| +| +| +| +| NOR /tmp/pardes-snap/ttyclick/cwd Del +| +| probe.txt +| +| +| +| +| +| +| +| +| +| +| diff --git a/test/snapshots/ttyclick.snap b/test/snapshots/ttyclick.snap new file mode 100644 index 00000000..9654b590 --- /dev/null +++ b/test/snapshots/ttyclick.snap @@ -0,0 +1,32 @@ +# clicks in a shell pane never change its mode: a body click in raw tty +# keeps TTY (before: the press dropped it to NOR), a tag-edit round trip +# restores the mode it hijacked, and an insert-mode body click re-pins the +# cursor but stays INS. File panes keep the old behavior (click -> normal). +file probe.txt marker +start 30 100 -n 3 +wait 8000 probe.txt +stable 700 20000 +key c-b +stable 600 8000 +# body click in raw tty: focus/selection only, mode stays TTY +press left 10 4 +release left 10 4 +stable 400 5000 +snap tty-bodyclick +# tag edit from tty: INS while editing, Esc restores TTY (not NOR) +press left 40 2 +release left 40 2 +stable 400 5000 +snap tty-tagedit +key esc +stable 400 5000 +snap tty-tagexit +# out of tty, into insert: a body click moves the cursor but keeps INS +key c-b +stable 600 8000 +key i +stable 400 5000 +press left 12 4 +release left 12 4 +stable 400 5000 +snap ins-bodyclick |
