diff options
Diffstat (limited to 'src/panes.zig')
| -rw-r--r-- | src/panes.zig | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/panes.zig b/src/panes.zig index 51710d08..a782e3e0 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -24,6 +24,14 @@ const Key = pardes.Key; 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. + pub const replica = .{ + .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" } }, + }; /// The words that throw unsaved text away (builtins.zig warnModified). pub const Discarding = enum { Exit, Restore, get, Del, Delcol }; @@ -128,7 +136,12 @@ pub const Pane = struct { /// The last command line pardes typed into this terminal (an exec, a /// middle click, a pty/run): its first word, which Kill matches, and /// the shell's command count its start (C mark) reaches. - sent_command: ?struct { word: [64]u8 = undefined, len: u8 = 0, seq: u32 = 0 } = null, + sent_command: ?struct { + pub const replica = .{ .len = .{.{ "word", "len" }} }; + word: [64]u8 = undefined, + len: u8 = 0, + seq: u32 = 0, + } = null, /// A command pane (exec.zig runCommand): the line its child runs as /// `$SHELL -c`, owned, where an interactive terminal has null. command: ?[]u8 = null, @@ -245,6 +258,12 @@ pub const Pane = struct { body_rows: u16 = 0, body_visible_rows: u16 = 0, context_row_limit: ?u16 = null, + /// What the geometry above was made for (File.geometry), and the bytes + /// its text takes; 0 has it made again by whoever reads it next. + 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 } = .{}, sel: [3]Sel = @splat(.{}), pointer_selections: [3]?PointerSelection = @splat(null), next_pointer_selection: u64 = 0, @@ -292,6 +311,7 @@ pub const Pane = struct { /// Older message lines kept on screen under a new one. pub const message_stack = 3; pub const OlderMessage = struct { + pub const replica = .{ .len = .{.{ "text", "len" }} }; text: [256]u8 = undefined, len: u16 = 0, life: MessageLife = .{}, @@ -515,6 +535,7 @@ pub const Pane = struct { } pub fn wrapAt(pane: *Pane, vr: i32) struct { line: i32, at: i32, pad: i32 = 0 } { + File.geometry(pane); if (pane.wrap_n > 0 and vr >= 0 and vr < @as(i32, pane.wrap_n)) return .{ .line = pane.wrap_line[@intCast(vr)], .at = pane.wrap_col[@intCast(vr)], .pad = pane.wrap_pad[@intCast(vr)] }; // unwrapped: rows ARE lines, and the byte column a row starts at is the @@ -523,6 +544,7 @@ pub const Pane = struct { } pub fn wrapRow(pane: *Pane, line: i32, col: i32) struct { row: i32, at: i32, pad: i32 = 0 } { + File.geometry(pane); if (pane.wrap_n == 0) return .{ .row = line - pane.scroll(), .at = pane.hscroll }; var i: u16 = 0; while (i < pane.wrap_n) : (i += 1) { @@ -572,10 +594,11 @@ pub const Pane = struct { } pub fn ensureCursorVisible(pane: *Pane) void { + File.geometry(pane); const off = pane.scroll(); var in_context = false; - // Maps survive until the next render. A jump may have changed scroll - // already, so only treat an ancestor as pinned in the matching view. + // The map is the view's as it is now (File.geometry): an ancestor is + // pinned only in the view it was found for. if (pane.context_rows < pane.wrap_n and pane.wrap_line[pane.context_rows] == off) { for (pane.wrap_line[0..pane.context_rows]) |row| { if (row == pane.body.cur_row) { |
