summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pardes.zig3
-rw-r--r--src/views.zig4
-rw-r--r--test/daemon.py19
-rw-r--r--test/snapshots/views-term.golden46
-rw-r--r--test/snapshots/views-term.snap27
5 files changed, 95 insertions, 4 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 88d75fd1..59233347 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -7857,6 +7857,9 @@ pub const Pardes = struct {
/// Whether the live view sizes terminal `pane`: a terminal shown at two
/// sizes takes the size of the view that typed into it last, and any
/// view's once that one is gone. The others show it at that size.
+ // ponytail: a view smaller than the terminal shows its top rows, the
+ // rest cut; panning to its cursor, as tmux does, when a small view must
+ // follow a busy shell it never types into.
fn sizes(p: *Pardes, pane: *Pane) bool {
if (pane.sized_by == p.view) return true;
if (views.isOpen(p, pane.sized_by)) return false;
diff --git a/src/views.zig b/src/views.zig
index ae2b338d..e3ba5b4e 100644
--- a/src/views.zig
+++ b/src/views.zig
@@ -339,7 +339,9 @@ pub fn drawOthers(p: *Pardes, h: pardes.Host) !void {
_ = p.frame_arena.reset(.{ .retain_with_limit = pardes.memory.limits.frame_kept });
const surface = try p.render(p.frame_arena.allocator());
if (v.present) |f| f(h.ctx, surface);
- if (v.post_present) |f| f(h.ctx);
+ // No post_present: what a shell acknowledges there moves the
+ // session's pointer and hover, which are the live view's to move;
+ // a view's panels are acknowledged when it is live and drawn.
copy(&drawn_fields, &p.parked[k].?.view, p);
}
}
diff --git a/test/daemon.py b/test/daemon.py
index 04455f0f..41cfbaf7 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -212,11 +212,13 @@ def main(binary, cycles):
# (src/views.zig), drawn beside the first. Detached from inside, its
# stub ends and the first draws on; closed outright, the same.
for how in ('detach', 'close'):
- term2 = Term(20, 60)
+ # Bigger than the first: the shell, sized for the first (its
+ # last typist), shows whole in it.
+ term2 = Term(40, 120)
stub2 = term2.spawn([binary, '--attach=work'], env)
started.append(stub2.pid)
wait_for('the second terminal\'s first frame', lambda: b'\x1b[?1049h' in term2.text())
- wait_for('the second terminal\'s view live', lambda: client.screen()['cols'] == 60)
+ wait_for('the second terminal\'s view live', lambda: client.screen()['cols'] == 120)
seen = len(term.text())
run(client, shell, f'echo both-drawn-{how}\n'.encode())
wait_for('the first terminal drawn', lambda: f'both-drawn-{how}'.encode() in term.text()[seen:])
@@ -230,7 +232,7 @@ def main(binary, cycles):
term2.close()
else:
term2.close()
- assert stub2.wait(timeout=10) != 0 or True
+ stub2.wait(timeout=10)
wait_for('the first terminal\'s view live again', lambda: client.screen()['cols'] == 100)
seen = len(term.text())
run(client, shell, f'echo first-on-{how}\n'.encode())
@@ -359,6 +361,17 @@ def gui(binary, cycles):
baseline = baseline or now
assert now == baseline, (cycle, now, baseline)
print(f'daemon: {cycles} window detach/attach cycles, fds/processes level: {baseline}')
+ # Attached already: another window, a view of its own (its test
+ # captures under view-1); Detach in it closes only it.
+ attach = subprocess.run([binary, '--attach=win'], env=env, cwd=root, timeout=10,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ assert attach.returncode == 0, attach.stderr
+ wait_for('the second window drawn', lambda: (root / 'caps' / 'view-1' / 'latest.ppm').exists())
+ client.write(f'/pane/{shell}/exec', b'Detach\n')
+ time.sleep(.5)
+ assert not sized(client), 'the first window stays'
+ assert proc.poll() is None
+ print('daemon: a second window on an attached window session, detached alone')
# Another kind is refused in words, and so is a name nobody has.
client.write(f'/pane/{shell}/exec', b'Detach\n')
wait_for('the window closed', lambda: sized(client))
diff --git a/test/snapshots/views-term.golden b/test/snapshots/views-term.golden
new file mode 100644
index 00000000..d3cff726
--- /dev/null
+++ b/test/snapshots/views-term.golden
@@ -0,0 +1,46 @@
+== snap small grid=50x14 cursor=4,4
+| Newcol Joincol Find Grep Help Changelog Tutor Du
+| New Tty Find Grep Joincol Delcol
+|$ /tmp/pardes-snap/views-term/cwd Tty+bash Save Mo
+| de Filter Collapse Del
+| $
+|
+|
+|
+|
+|
+| /tmp/pardes-snap/views-term/cwd/+New Save Tty Co
+| llapse Del
+| 1
+== snap big grid=80x24 cursor=4,5
+| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit
+| New Tty Find Grep Joincol Delcol
+|$ /tmp/pardes-snap/views-term/cwd Tty+bash Save Mode Filter Collapse Del
+| $ echo from-the-big-one
+| from-the-big-one
+| $
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+|
+| /tmp/pardes-snap/views-term/cwd/+New Save Tty Collapse Del
+| 1
+== snap small-sees grid=50x14 cursor=4,6
+|4: $ echo from-the-big-one
+|5: from-the-big-one
+|6: $
+== snap small-typed grid=50x14 cursor=4,8
+|6: $ echo from-the-small-one
+|7: from-the-small-one
+|8: $
+== snap big-sees grid=80x24 cursor=4,7
+|5: $ echo from-the-small-one
+|6: from-the-small-one
+|7: $
diff --git a/test/snapshots/views-term.snap b/test/snapshots/views-term.snap
new file mode 100644
index 00000000..bbd1c368
--- /dev/null
+++ b/test/snapshots/views-term.snap
@@ -0,0 +1,27 @@
+# A terminal shown in two views at two sizes (src/views.zig): it takes the
+# size of the view that typed into it last; the other shows it at that size.
+config Verbose off
+start 24 80 views=2
+wait 8000 $
+stable 700 20000
+view 2
+resize 14 50
+stable 500 10000
+snap small
+# Typed in the big view: sized for it, shown so in the small one.
+view 1
+text echo from-the-big-one
+key enter
+stable 500 10000
+snap big
+view 2
+stable 500 10000
+snap small-sees
+# Typed in the small view: sized for it now, the big one shows it so.
+text echo from-the-small-one
+key enter
+stable 500 10000
+snap small-typed
+view 1
+stable 500 10000
+snap big-sees