summaryrefslogtreecommitdiff
path: root/core/term/TerminalImages.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 20:21:32 -0300
committerGabriel Schneider <[email protected]>2026-11-22 20:21:32 -0300
commit3f250d0f963f375d699f11ffc02b07f2e2cbbbee (patch)
tree4e5a1f577fd3dd247f3643d979868347524ce703 /core/term/TerminalImages.zig
parent34e2d82a322bd3767a8ec62b3a4c0894399e8c04 (diff)
parentc607dc14502a6956bdfa3575bc7363514a7abeb4 (diff)
downloadpardes-3f250d0f963f375d699f11ffc02b07f2e2cbbbee.tar.gz
pardes-3f250d0f963f375d699f11ffc02b07f2e2cbbbee.zip
integration (a base for the terminals' next round, not yet the gathered line): the viewport in the view and the patches in the semantics hash on merge58 with the terminal put back: pardes-raw-tty (`muwnrqro`, on pardes-merge58: a TERM that reaches a session while it leaves its terminal no longer leaves it raw: `Killed.disarm` puts the cooked modes back itself, `leave` calls it last) and pardes-term-join-10's two changes (`xktusoyq` on `qtxssxyk`, on pardes-term-join-9: where a view stands in a terminal's history is the view's (`Pane.scrolled_to`), carried once a confirmed write that moves rows, the wire at 31; build/patches hashed into a replica's semantics); no conflict; core-test 917/1077 (160 skipped), shell-test 1119/1122, pane-test 182/183, term-test 16/16; NOT gated whole: the viewport's gate had one perf count over its budget ("terminal on all" +0.235%), which the next round brings down before this is the gathered line (2026-11-22)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/term/TerminalImages.zig')
-rw-r--r--core/term/TerminalImages.zig25
1 files changed, 13 insertions, 12 deletions
diff --git a/core/term/TerminalImages.zig b/core/term/TerminalImages.zig
index d0d364a1..e3996b92 100644
--- a/core/term/TerminalImages.zig
+++ b/core/term/TerminalImages.zig
@@ -157,16 +157,18 @@ fn decodePng(gpa: std.mem.Allocator, bytes: []const u8) ghostty_vt.sys.DecodeErr
return .{ .width = scaled.width, .height = scaled.height, .data = gpa.dupe(u8, scaled.data) catch return error.InvalidData };
}
-/// Draw the active screen's images. `rows_of[v]` is the body row the
-/// viewport's row `v` is shown on, if it is shown; `cols` how many of its
-/// columns the body shows, from `tx`. The caches are `own`'s (the
-/// emulator's), `out` is `gpa`'s.
+/// Draw the active screen's images over the rows a view shows, `top` to
+/// `bottom`. `rows_of[v]` is the body row the view's row `v` is shown on,
+/// if it is shown; `cols` how many of its columns the body shows, from
+/// `tx`. The caches are `own`'s (the emulator's), `out` is `gpa`'s.
pub fn draw(
ti: *TerminalImages,
own: std.mem.Allocator,
gpa: std.mem.Allocator,
vt: *ghostty_vt.Terminal,
where: plain.term.ImagesAt,
+ top: ghostty_vt.Pin,
+ bottom: ghostty_vt.Pin,
rows_of: []const ?u16,
out: *std.ArrayList(plain.Placement),
frame: []plain.Cell,
@@ -184,8 +186,7 @@ pub fn draw(
const now_ms = where.now_ms;
ti.animation_due_ms = if (storage.animationTick(vt.io(), now_ms)) |delay| now_ms +| delay else null;
const pages = &screen.pages;
- const top = pages.getTopLeft(.viewport);
- const bottom = pages.getBottomRight(.viewport) orelse return;
+ const origin = pages.pointFromPin(.screen, top) orelse return;
const cw: u32 = @max(1, where.cell_w);
const ch: u32 = @max(1, where.cell_h);
const ctx: Ctx = .{ .ti = ti, .own = own, .gpa = gpa, .out = out, .pane = where.pane, .serial = where.serial, .tx = where.tx, .body_y = where.body_y, .cols = where.cols, .rows_of = rows_of, .cw = cw, .ch = ch, .glyph = where.petscii };
@@ -202,11 +203,12 @@ pub fn draw(
// them on a row at a time. The placeholders themselves are not text.
var runs: PlaceholderRuns = .init(top, bottom);
while (runs.next()) |run| {
- const at = pages.pointFromPin(.viewport, run.pin) orelse continue;
- const v = at.viewport.y;
+ const at = pages.pointFromPin(.screen, run.pin) orelse continue;
+ if (at.screen.y < origin.screen.y) continue;
+ const v = at.screen.y - origin.screen.y;
if (v >= rows_of.len) continue;
const row = rows_of[v] orelse continue;
- for (@as(usize, at.viewport.x)..@as(usize, at.viewport.x) + run.width) |x| {
+ for (@as(usize, at.screen.x)..@as(usize, at.screen.x) + run.width) |x| {
if (x >= where.cols) break;
const cell = &frame[@as(usize, where.body_y + row) * frame_cols + where.tx + x];
cell.text[0] = ' ';
@@ -217,7 +219,7 @@ pub fn draw(
const rp = run.renderPlacement(&target.placement, &img, cw, ch) catch continue;
if (rp.dest_width == 0 or rp.dest_height == 0 or rp.source_width == 0 or rp.source_height == 0) continue;
ctx.place(img, target.placement.z, .{ .x = rp.source_x, .y = rp.source_y, .w = rp.source_width, .h = rp.source_height }, .{
- .x = @as(i64, at.viewport.x) * cw + rp.offset_x,
+ .x = @as(i64, at.screen.x) * cw + rp.offset_x,
.y = @as(i64, v) * ch + rp.offset_y,
.w = rp.dest_width,
.h = rp.dest_height,
@@ -225,8 +227,7 @@ pub fn draw(
}
// Placements on a cell: they move with the text they were put on, and
- // go where it goes, above the viewport or off the screen.
- const origin = pages.pointFromPin(.screen, top) orelse return;
+ // go where it goes, above the view or off the screen.
var it = storage.placements.iterator();
while (it.next()) |entry| {
const placed = entry.value_ptr.*;