summaryrefslogtreecommitdiff
path: root/src/draw.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/draw.zig')
-rw-r--r--src/draw.zig52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/draw.zig b/src/draw.zig
index e141ce31..8503197c 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -96,12 +96,10 @@ pub fn place(p: *Pardes, s: *Surface) void {
if (r.h <= pane.tag_rows) continue;
const tx = r.x + config.GUTTER;
const tw = r.w - config.GUTTER;
- var leader_buf: [16]u8 = undefined;
for (0..pane.notices.len) |i| {
- const text = Messages.noticeText(p, pane, i, &leader_buf);
- const chip = Messages.noticeCols(p, text, tw);
- if (chip == 0) continue;
- pane.notices.left[i] = tx + tw - chip;
+ const left = pane.notices.left[i];
+ if (left == std.math.maxInt(u16)) continue;
+ const chip = tx + tw - left;
s.addRegion(.{ .kind = .notice, .owner = owner, .serial = pane.serial, .active = active, .notice = @intCast(i), .rect = .{ .x = tx + tw - chip, .y = body_y + @as(u16, pane.notices.row[i]), .w = chip, .h = BOX_H } });
}
}
@@ -135,7 +133,7 @@ pub fn place(p: *Pardes, s: *Surface) void {
// frame's own time, not the stepped animations' 16 ms grid. A grid
// snaps (it has no in-between), and so does nothing that shows it.
const shown = lift != .off or inactiveDim(p) != 0;
- const motion = animation.Motion.of(if (shown and builtins.capabilities.lift) p.settings.motion else .off);
+ const motion = animation.Motion.of(if (shown and builtins.frontend.lift) p.settings.motion else .off);
// A flavour exaggerates what is only a few pixels (Motion.gain).
spring.retarget(if (id == p.active) animation.Motion.of(p.settings.motion).gain else 0, p.now_ns, motion);
_ = spring.step(p.now_ns);
@@ -226,7 +224,7 @@ fn glideCursor(p: *Pardes, s: *Surface) void {
s.chrome.cursor_glide = 0;
s.chrome.cursor_alpha = 1;
s.chrome.cursor_idle_ms = std.math.maxInt(u32);
- if (!builtins.capabilities.lift) return;
+ if (!builtins.frontend.lift) return;
const box = focusedCursorBox(p, s) orelse {
// No cursor drawn (a PDF or picture took focus, a program hid its
// own): a glide under way has nowhere to land, and its springs,
@@ -521,6 +519,10 @@ fn resolved(color: Color, default: ?[3]u8, palette: ?[16][3]u8) ?[3]u8 {
}
pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
+ const taped = pardes.tape.enter(p, .render);
+ defer pardes.tape.leave(p, taped);
+ panes.terminal.drawing = true;
+ defer panes.terminal.drawing = false;
panes.File.refreshHighlights(p);
const s = &p.surface;
const ncells = @as(usize, p.screen_w) * p.screen_h;
@@ -606,9 +608,6 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
for (&p.panes, 0..) |*slot, id| {
const pane = slot.* orelse continue;
- pane.body_rows = 0;
- pane.body_visible_rows = 0;
- pane.context_row_limit = null;
s.body_layers[id].rows = 0;
try renderPane(p, s, arena, pane, p.rects[id], id, id == p.active);
}
@@ -961,6 +960,9 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
}
try body_layer.joinBody(p, s, arena, pane, r, id, active, rail.*);
+ // A terminal panned to its cursor in a view shorter than it: an arrow
+ // in the gutter's first body row says rows are above (views.zig).
+ if (pane.pan > 0) s.set(r.x, p.bodyTop(pane, r), "↑", .{ .fg = .{ .rgb = chrome.box } });
// A query's places' ticks, each in the track's cell of its row: chrome,
// painted with the rail (a pixel shell draws its own from the same list).
for (s.rail_ticks[0..s.nrail_ticks]) |tick| {
@@ -976,7 +978,6 @@ pub fn paintHeaders(p: *Pardes, s: *Surface, arena: std.mem.Allocator) !void {
const chrome = p.chromeTheme();
// global tagbar: full width, top rows — unless a native shell has
// taken its commands over, in which case the rows are not ours to draw
- tagline.revealHeader(p);
if (s.region(.workspace_tag, Region.none)) |region| {
const top = if (p.header_focus and p.header_column == null) p.header_top else 0;
const layer = &s.tag_layers[MAX_PANES + MAX_COLS];
@@ -1736,7 +1737,7 @@ test "a lift is sampled at each frame's own time, and asks for frames only while
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
defer p.deinit();
// A grid has no in-between: there a lift snaps.
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
_ = try p.setTestFile("text\n");
p.newScratchBelow(0);
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -1911,7 +1912,7 @@ test "with no lift, no dim and no motion a focus switch asks for no frames" {
test "each Motion flavour reaches the lift as its own trajectory" {
// A grid snaps; the flavours are a pixel shell's.
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile("text\n");
@@ -1950,7 +1951,7 @@ test "each Motion flavour reaches the lift as its own trajectory" {
}
test "the caret is its own body: a page leaves it still under the moving text, a wheel scroll lands its springs on its line's new row" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 30 });
defer p.deinit();
var text: std.ArrayList(u8) = .empty;
@@ -1994,7 +1995,7 @@ test "the caret is its own body: a page leaves it still under the moving text, a
}
test "the focused cursor glides a jump, eases a step, the thin caret too, and is exact at rest" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 30 });
defer p.deinit();
_ = try p.setTestFile(std.mem.asBytes(&@as([20][20]u8, @splat("some text on a line\n".*))));
@@ -2077,7 +2078,7 @@ test "the focused cursor glides a jump, eases a step, the thin caret too, and is
}
test "a tag caret past its row's end glides to the tag's right edge, where the layer's is" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 16 });
defer p.deinit();
p.update(.{ .resize = .{ .cols = 60, .rows = 16, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 } } });
@@ -2127,7 +2128,7 @@ test "a tag caret past its row's end glides to the tag's right edge, where the l
}
test "a terminal's cursor lands with scrolling output, never gliding against it" {
- if (!builtins.capabilities.lift or !pardes.terminal_panes) return error.SkipZigTest;
+ if (!builtins.frontend.lift or !pardes.terminal_panes) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 12 });
defer p.deinit();
while (p.nextEffect()) |_| {}
@@ -2286,12 +2287,9 @@ test "a body with context rows is painted once, and the grid's rows are what a p
const cells = try arena.allocator().alloc(Cell, s.cells.len);
@memset(cells, .{});
var plain: Surface = .{ .cols = s.cols, .rows = s.rows, .cells = cells };
- const saved = .{ pane.body_rows, pane.body_visible_rows, pane.context_row_limit };
- pane.body_rows = 0;
- pane.body_visible_rows = 0;
- pane.context_row_limit = null;
+ pane.view.layered = false;
try body_layer.renderBody(p, &plain, arena.allocator(), pane, p.rects[0], 0, true, null, null);
- pane.body_rows, pane.body_visible_rows, pane.context_row_limit = saved;
+ pane.view.layered = true;
for (0..body.rect.h) |row| {
const y = body.rect.y + row;
for (0..body.rect.w) |col| {
@@ -2325,7 +2323,7 @@ fn twoColumns(p: *Pardes, arena: *std.heap.ArenaAllocator) !void {
}
test "while its pane slides the cursor rides with it, at the same cell of the pane every frame" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 });
defer p.deinit();
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -2378,7 +2376,7 @@ test "while its pane slides the cursor rides with it, at the same cell of the pa
}
test "focus moved to another column glides from where the cursor was drawn" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 });
defer p.deinit();
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -2414,7 +2412,7 @@ test "focus moved to another column glides from where the cursor was drawn" {
}
test "a click that takes focus glides the cursor once, to where it lands on release" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 });
defer p.deinit();
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -2448,7 +2446,7 @@ test "a click that takes focus glides the cursor once, to where it lands on rele
}
test "focus moving to a pane with no cursor while the cursor glides lets the session go idle" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 });
defer p.deinit();
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -2477,7 +2475,7 @@ test "focus moving to a pane with no cursor while the cursor glides lets the ses
}
test "a pane focus reaches brightens on the same spring the one it leaves dims on, and Motion off snaps" {
- if (!builtins.capabilities.lift) return error.SkipZigTest;
+ if (!builtins.frontend.lift) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile(std.mem.asBytes(&@as([4][20]u8, @splat("some text on a line\n".*))));