summaryrefslogtreecommitdiff
path: root/src/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 17:01:35 -0300
committerGabriel Schneider <[email protected]>2026-10-29 19:38:53 -0300
commit2cce341e2c94fb3150dc1f3e7911c26502a70487 (patch)
treec637fcfa9a52aa66f6c34600f4cdea4020088e01 /src/panes.zig
parentc2b4f235e78735102c691677f08bd1b2403168df (diff)
downloadpardes-2cce341e2c94fb3150dc1f3e7911c26502a70487.tar.gz
pardes-2cce341e2c94fb3150dc1f3e7911c26502a70487.zip
views: several clients on one session, each its own layout, focus, cursors and scroll over the panes they share; a second `pardes --attach` draws on its own terminal beside the first, and `pardes-gui --attach` opens another window
The core still sees one view, the live one, in the fields it always had (src/views.zig): a view's share of the session (`views.fields`: its screen, columns, rects, focus, pointer and gestures, jumps, key prefixes, column tags, presentation and animations, windowed and native_images) and of each pane (`PaneView`: its place in the layout, which text has the keyboard, the body's cursor, selections and mode, its scroll, a document's size, what the step measured of it) is copied out when another view goes live and back when it is live again. One view never parks: the single client pays a test of one byte a step. `toView`, `openView` and `closeView` are taped inputs; the pump draws each other view by going into it and back, which leaves every digested field as it was, so the replica that draws nothing skips it. A parked view is in no digest (its slot is written whenever it goes out); what drawing it made of its own (animations, presentation) is kept, whatever its unpark brought inside a changed text is done again when it is next live. Shared: the panes' text, terminals, tags, prompts, messages, registers (yanked in one view, put in another), the workspace tag and settings. A terminal shown at two sizes takes the size of the view that typed into it last (`Pane.sized_by`), and any view's once that one is gone; the others show it at that size. A text edited in one view moves the other views' cursors and scroll with the splice, as a Zerox twin's (File.ParkedPlaces). A pane closed in one view leaves the others' layouts (by its slot's serial); a pane focused in a view that does not show it is placed in its active column (views.show). tty: each terminal is a Screen of its own (its vaxis, input reader, frame answer, kitty images and shm probe, glide, trail and flash); its input reaches the loop as its view's (a `from` ahead of it when another terminal posted last, so one terminal posts none). A SIGWINCH asks every terminal its size; a SIGHUP asks each whether it hung up or lost its stub. Detach, or a terminal's end, with other views left closes only that view, its stub told `d`; the session's end tells every stub. daemon.zig: an attach names an attached session too (or the only one there is when none is detached). gui: the Gui holds the live window's share of itself (window_fields: the SDL window and its presenting, scroll, glide, scene and post chain, pointer, blink, captures); the others wait in Shell.windows, swapped in (`follow`) as the core's live view changes, and each SDL event first takes its window's view live (`route`). Closing a window while others stay closes its view. Harnesses: `start <rows> <cols> views=N` in a snapshot script gives the app N-1 more terminals (PARDES_TEST_VIEWS, opened as attached ones), `view <k>` types into and captures terminal k, every wait reads them all; `pardes-monkey --views=N` switches among N; `zig build replay` runs its seeds at three views too. views.snap pins two terminals: an edit seen in both, a scroll in one, a line yanked in one and put in the other, Newcol in one, Detach in one. Unit tests: own cursor, scroll, mode, layout and focus; edits shared; registers shared; terminal size by last typist; closing views; drawing the others leaves the digest; a view keeps its place in a text another edits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/panes.zig')
-rw-r--r--src/panes.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/panes.zig b/src/panes.zig
index a782e3e0..71a04464 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -1,6 +1,7 @@
const std = @import("std");
const vaxis = @import("vaxis");
const pardes = @import("pardes.zig");
+const views = @import("views.zig");
const layout = @import("layout.zig");
const config = @import("config.zig");
const Pardes = pardes.Pardes;
@@ -26,8 +27,9 @@ pub const EditText = struct { text: []u8, row0: i32 };
pub const Pane = struct {
/// What the replay digest leaves out (src/walk.zig): the view's geometry,
/// made again from the rest (File.geometry); the 9P server's record of
- /// the pane's opens and readers.
+ /// the pane's opens and readers; the other views' share of it (views.zig).
pub const replica = .{
+ .local = .{ "pv", "pv_known" },
.derived = .{ "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "view", "notices" },
.authority = .{"fs"},
.len = .{ .{ "msg", "msg_len" }, .{ "msg_older", "msg_older_len" }, .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } },
@@ -95,6 +97,7 @@ pub const Pane = struct {
pub const Cwd = union(enum) { none, inherited: *Pane, owned: []u8 };
pub const Focus = enum { body, tag };
+ pub const SessionView = struct { wrap: bool = true, layered: bool = true, body_h: u32 = 0, tagline_h: u32 = 0, rect_h: u16 = 0 };
terminal: ?*terminal.State = null,
gpa: std.mem.Allocator,
serial: u32 = 0,
@@ -263,7 +266,7 @@ pub const Pane = struct {
geometry_key: u64 = 0,
geometry_len: usize = 0,
/// The session's part of the geometry, as of the last step (`sync`).
- view: struct { wrap: bool = true, layered: bool = true, body_h: u32 = 0, tagline_h: u32 = 0, rect_h: u16 = 0 } = .{},
+ view: SessionView = .{},
sel: [3]Sel = @splat(.{}),
pointer_selections: [3]?PointerSelection = @splat(null),
next_pointer_selection: u64 = 0,
@@ -297,6 +300,15 @@ pub const Pane = struct {
/// body layer reserves exactly `len` rows for them, the way it already
/// reserves rows for sticky context headers.
notices: Notices = .{},
+ /// Each other view's share of this pane, while it is not live
+ /// (views.zig): its cursor, scroll and place in that view's layout.
+ pv: [views.max]views.PaneView = undefined,
+ /// The views `pv` holds a share for (a pane retired before a view came
+ /// has none of it).
+ pv_known: u8 = 0,
+ /// The view that last typed into it: a terminal shown at two sizes takes
+ /// that view's (Pardes.sync).
+ sized_by: u8 = 0,
pub const MessagePhase = enum { entering, shown, lingering, leaving };
/// One message line's animation: falling in, shown, lingering after the