summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig41
1 files changed, 30 insertions, 11 deletions
diff --git a/core/Core.zig b/core/Core.zig
index d2cfadfc..2b0a898d 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -355,6 +355,11 @@ lsp_ask: Ask = .{},
pipe: Pipe = .{},
/// A query pane's Grep, and its Find's listing, on a worker (Stream.zig).
stream: Stream = .{},
+/// The panes' `Changes` (jj.zig): what was asked of jj, and what it
+/// answered for each pane, by its serial: the session's, not a field of
+/// every pane (a digest and a rollback copy walk every pane's fields at
+/// every step), and nothing in a digest until a `Changes` is asked.
+changes: @import("jj.zig").Session = .{},
fs: filesystem.Namespace = .{},
boot: Boot = .shell,
@@ -864,6 +869,7 @@ pub fn deinit(p: *Pardes) void {
for (p.spawn_dirs) |d| if (d) |dir| gpa.free(dir);
p.pipe.deinit(gpa);
p.stream.deinit(gpa);
+ p.changes.deinit(gpa);
p.handover.deinit(gpa);
if (p.stream.ahead.len > 0) p.tree_sitter_gpa.free(p.stream.ahead);
p.locations_cache.deinit(p.tree_sitter_gpa);
@@ -876,6 +882,8 @@ pub fn deinit(p: *Pardes) void {
for (&p.surface.body_layers) |*layer| gpa.free(layer.cells);
for (&p.surface.tag_layers) |*layer| gpa.free(layer.cells);
p.surface.placements.deinit(gpa);
+ p.surface.lanes.deinit(gpa);
+ p.surface.heat.deinit(gpa);
gpa.destroy(p);
}
@@ -942,8 +950,9 @@ fn reportFocus(p: *Pardes) void {
// A client's own step records what it told and writes nothing: the
// session's step makes the write, off the tape on both sides
// (tape.hostCall's pty_write), so the switch shows at once and the
- // program hears of it a round trip later.
- if (p.tape.speculating and p.tape.screen_state) return;
+ // program hears of it a round trip later (a write there would stop the
+ // speculation: pty_write is `keeps_stopping`'s).
+ if (p.tape.speculating) return;
if (v.focus_told) |old| if (p.panes[old.id]) |pane| {
if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O");
};
@@ -1905,6 +1914,7 @@ pub fn sync(p: *Pardes) void {
// and its context declarations.
if (pane.file) |*f| pardes.panes.File.refreshContext(p, pane, f);
pane.view = .{ .wrap = p.settings.wrap, .body_h = v.row_metrics.body_h, .tagline_h = v.row_metrics.tagline_h, .rect_h = r.h };
+ if (pane.layers.lanes > 0) @import("jj.zig").showGhosts(p, pane);
// The tag takes a row per line, leaving the body one row if it
// had any; a folded pane shows its first line only. Its prefix
// is made once, on the stack: this runs on every event, and not
@@ -2004,6 +2014,16 @@ pub fn sync(p: *Pardes) void {
tagline.revealHeader(p);
}
+/// Pane `id`'s pty as its host is to size it: its grid (or `cells`, a
+/// size 9P's pty/ctl gave), in pixels at the cell of the view that sizes
+/// it: a program sizes its kitty graphics by them.
+pub fn ptySize(p: *const Pardes, id: Pane.Id, cells: ?[2]u16) pardes.PtySize {
+ const pane = p.panes[id.index()] orelse return .{ .cols = 1, .rows = 1 };
+ const c = cells orelse .{ pane.cols, pane.rows };
+ const cell = (if (pane.sized_by) |k| p.views[k] orelse p.views[p.live].? else p.views[p.live].?).cell_pixels;
+ return .{ .cols = @max(c[0], 1), .rows = @max(c[1], 1), .w_px = std.math.cast(u16, @as(u32, c[0]) * cell.w) orelse 0, .h_px = std.math.cast(u16, @as(u32, c[1]) * cell.h) orelse 0 };
+}
+
/// The view typing goes into is the one its terminal is sized for
/// (`sizes`).
fn typedInto(p: *Pardes) void {
@@ -2011,16 +2031,15 @@ fn typedInto(p: *Pardes) void {
}
/// 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, a
-/// shorter one passed down to its cursor (`Pane.pan`, Pane.panFor).
+/// sizes takes the size of the view that typed into it last, and keeps it
+/// once that view is gone until another types into it (views.dropView):
+/// a view nobody types in never takes it. The others show it at that
+/// size, a shorter one passed down to its cursor (`Pane.pan`,
+/// Pane.panFor).
// ponytail: a panned view's pointer reports to a terminal's program and
// its kitty images are placed as the unpanned rows are.
-fn sizes(p: *Pardes, pane: *Pane) bool {
- if (pane.sized_by == p.live) return true;
- if (Views.isOpen(p, pane.sized_by)) return false;
- pane.sized_by = p.live;
- return true;
+fn sizes(p: *const Pardes, pane: *const Pane) bool {
+ return pane.sized_by == p.live;
}
pub fn theme(p: *const Pardes) *const Theme {
@@ -2879,7 +2898,7 @@ test "a spawn is for the pane it was made for, not whatever took the slot since"
var command: [32]u8 = undefined;
var core: *Pardes = undefined;
const vtable: Host.VTable = .{ .spawn = spawn };
- fn spawn(_: ?*anyopaque, id: pardes.Pane.Id, _: []const u8) void {
+ fn spawn(_: ?*anyopaque, id: pardes.Pane.Id, _: []const u8, _: pardes.PtySize) void {
const pane = id.index();
spawns += 1;
const line = core.panes[pane].?.command.?;