summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/animation.zig13
-rw-r--r--src/body_layer.zig10
-rw-r--r--src/draw.zig35
3 files changed, 24 insertions, 34 deletions
diff --git a/src/animation.zig b/src/animation.zig
index 1738ba7d..ae116e27 100644
--- a/src/animation.zig
+++ b/src/animation.zig
@@ -211,9 +211,9 @@ pub const Track = extern struct {
pub fn visualBox(track: Track) Box {
return switch (track.effect) {
.slide, .zoom, .vertical => track.presented(),
- .off, .dissolve => track.to,
- // Every character effect stays inside the pane's final rectangle.
- .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => track.to,
+ // A fade, a dissolve and every character effect stay inside the
+ // pane's final rectangle.
+ .off, .dissolve, .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => track.to,
};
}
@@ -244,10 +244,9 @@ pub fn openingBox(effect: Transition, target: Box, screen_width: u16) Box {
from.y += target.h;
break :blk from;
},
- .off, .dissolve => target,
- // Character effects own the glyphs inside a fixed rectangle, so their
- // panel opens at exactly its final geometry.
- .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => target,
+ // A dissolve and the character effects own the glyphs inside a fixed
+ // rectangle, so their panel opens at exactly its final geometry.
+ .off, .dissolve, .ascii, .edges, .fall, .wave, .curtain, .scramble, .typewriter => target,
};
}
diff --git a/src/body_layer.zig b/src/body_layer.zig
index 027dfffb..b514cabe 100644
--- a/src/body_layer.zig
+++ b/src/body_layer.zig
@@ -169,14 +169,14 @@ pub fn buttonInks(th: *const colors.Theme) [3][3]u8 {
/// rows the grid cannot show, and is painted straight onto the grid. The
/// rail is the grid's alone.
pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rail: pardes.Region) !void {
- if (pane.file == null) return renderBody(p, s, arena, pane, r, id, active, rail, null);
+ if (pane.file == null) return renderBody(p, s, arena, pane, r, id, active, rail);
// The pane's geometry as it is (File.geometry): made by the step that
// moved it if one read it, else here, and the same either way.
panes.File.geometry(pane);
// Which rows are context rows is decided by the text the body shows: a
// layer taller than the grid's rows when there are any.
if (!p.settings.tree_context_tag_style or pane.collapsed or r.h <= pane.tag_rows or pane.body_rows == 0)
- return renderBody(p, s, arena, pane, r, id, active, rail, null);
+ return renderBody(p, s, arena, pane, r, id, active, rail);
const viewport_rows = r.h - pane.tag_rows;
const logical_rows: usize = pane.body_rows;
const width = r.w - config.GUTTER;
@@ -187,7 +187,7 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
@memset(temporary_cells, .{});
var temporary: Surface = .{ .cols = r.w, .rows = @intCast(logical_rows + pane.tag_rows), .cells = temporary_cells };
const synthetic: Rect = .{ .x = 0, .y = 0, .w = r.w, .h = @intCast(logical_rows + pane.tag_rows) };
- try renderBody(p, &temporary, arena, pane, synthetic, id, active, null, null);
+ try renderBody(p, &temporary, arena, pane, synthetic, id, active, null);
const first_row: usize = if (p.settings.tag_bottom) 0 else pane.tag_rows;
for (0..logical_rows) |row| {
const start = (row + first_row) * r.w + config.GUTTER;
@@ -229,7 +229,7 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
}
}
-pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rail: ?pardes.Region, built: ?[]const u8) !void {
+pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rail: ?pardes.Region) !void {
const th = p.theme();
const chrome = p.chromeTheme();
const tx = r.x + config.GUTTER;
@@ -250,7 +250,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
};
const tz_body = tracy.zone(@src(), "bodyText");
const probe_text = pardes.FrameStats.nowNs();
- const body = built orelse try bodyText(p, arena, pane);
+ const body = try bodyText(p, arena, pane);
p.frames.zone(.body_text, probe_text);
tz_body.end();
// A select sweep begun on the tag and dragged into the body marks the
diff --git a/src/draw.zig b/src/draw.zig
index 1e17df3d..38080c92 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -171,7 +171,7 @@ fn gripBg(p: *const Pardes, active: bool) [3]u8 {
}
/// An unfocused grip's ring, and a dirty one's fill (colors.Theme).
-pub fn boxBorder(p: *const Pardes) [3]u8 {
+fn boxBorder(p: *const Pardes) [3]u8 {
return p.theme().box_border orelse p.chromeTheme().box_dim;
}
pub fn boxDirty(p: *const Pardes) [3]u8 {
@@ -362,7 +362,7 @@ pub fn liftStyle(p: *const Pardes) config.Runtime.LiftStyle {
/// How far, in percent, the unfocused panes' text fades toward its ground:
/// InactiveDim, or under `Lift auto` on a dark page `auto_dim` while that
/// is unset.
-pub fn inactiveDim(p: *const Pardes) u8 {
+fn inactiveDim(p: *const Pardes) u8 {
if (p.settings.inactive_dim != 0) return p.settings.inactive_dim;
return if (p.settings.lift == .auto and darkPage(p)) config.Runtime.auto_dim else 0;
}
@@ -626,7 +626,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
if (amount > 0.001) recede(p, s, id, amount, id == p.active);
}
- try paintHeaders(p, s, arena);
+ try paintHeaders(p, s);
switch (p.drag) {
.border_v => |d| {
@@ -974,7 +974,7 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
/// The workspace and column tags: each line a tag layer, and the grid's
/// rows copies of those; the column grips, which are the grid's alone.
-pub fn paintHeaders(p: *Pardes, s: *Surface, arena: std.mem.Allocator) !void {
+fn paintHeaders(p: *Pardes, s: *Surface) !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
@@ -986,7 +986,7 @@ pub fn paintHeaders(p: *Pardes, s: *Surface, arena: std.mem.Allocator) !void {
s.fill(viewport.x, viewport.y, inset, viewport.h, .{ .bg = .{ .rgb = chrome.tag_bg }, .fg = .{ .rgb = chrome.tag_fg }, .font_role = .tagline });
viewport.x += inset;
viewport.w -= inset;
- try renderHeaderLayer(p, arena, layer, .workspace, 0, viewport, tagline.topbar(p), top, chrome.tag_bg, chrome.tag_fg);
+ try renderHeaderLayer(p, layer, .workspace, 0, viewport, tagline.topbar(p), top, chrome.tag_bg, chrome.tag_fg);
joinHeaderRows(s, layer, chrome.tag_fg);
}
const column_rows = p.columnBarHeight();
@@ -1003,15 +1003,14 @@ pub fn paintHeaders(p: *Pardes, s: *Surface, arena: std.mem.Allocator) !void {
const inset = @min(TAG_TEXT_INSET, p.col_w[c]);
const grabbed = p.drag == .column_move and layout.columnBySerial(p, p.drag.column_move.serial) == c;
const grip_bg = if (grabbed) chrome.column_box else chrome.column_box_dim;
- const lum = (@as(u16, grip_bg[0]) * 3 + @as(u16, grip_bg[1]) * 6 + @as(u16, grip_bg[2])) / 10;
- const ink: [3]u8 = if (lum > 140) .{ 0, 0, 0 } else .{ 255, 255, 255 };
+ const ink = inkOn(grip_bg);
s.fill(p.col_x[c], region.rect.y, grip, @min(1, column_rows), .{ .bg = .{ .rgb = grip_bg }, .fg = .{ .rgb = ink }, .font_role = .tagline });
s.fill(p.col_x[c], region.rect.y + 1, grip, column_rows -| 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
s.fill(p.col_x[c] + grip, region.rect.y, inset - grip, column_rows, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
}
const top = if (p.header_focus and p.header_column == c) p.header_top else 0;
const layer = &s.tag_layers[MAX_PANES + c];
- try renderHeaderLayer(p, arena, layer, .column, @intCast(c), region.rect, tagline.columnTag(p, c), top, bg, fg);
+ try renderHeaderLayer(p, layer, .column, @intCast(c), region.rect, tagline.columnTag(p, c), top, bg, fg);
if (p.col_x[c] < s.cols) joinHeaderRows(s, layer, fg);
// Laid out at its full width; only shown short of the rail.
layer.viewport.w -|= region.clip;
@@ -1081,8 +1080,7 @@ fn tagTintRange(pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct {
/// A header or a notice band as a tag layer: `viewport.h` rows, line `top`
/// of `text` and on, laid out at the tagline's pitch -- as wide as its
/// widest line and never narrower than its viewport.
-fn renderHeaderLayer(p: *Pardes, arena: std.mem.Allocator, layer: *pardes.Layer, kind: TagKind, id: u16, viewport: Rect, text: []const u8, top: usize, bg: [3]u8, fg: [3]u8) !void {
- _ = arena;
+fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, viewport: Rect, text: []const u8, top: usize, bg: [3]u8, fg: [3]u8) !void {
if (viewport.w == 0 or viewport.h == 0) {
// No layer, and nothing of an earlier frame's left in it.
layer.rows = 0;
@@ -1187,7 +1185,7 @@ fn renderHeaderLayer(p: *Pardes, arena: std.mem.Allocator, layer: *pardes.Layer,
fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void {
const capacity = p.tagCapacity(r.w -| TAG_TEXT_INSET);
// Too narrow for a layer: only the grid's gap cell.
- if (r.w <= TAG_TEXT_INSET) return paintPaneTag(p, s, arena, pane, r, id, active, capacity);
+ if (r.w <= TAG_TEXT_INSET) return paintPaneTag(p, s, arena, pane, r, id, active);
const chrome = p.chromeTheme();
const region = s.region(.tag, id).?;
const tag = (try tagline.shownTag(p, arena, pane)).text;
@@ -1203,7 +1201,7 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
const storage = try arena.alloc(Cell, pitch * rows);
@memset(storage, .{});
var temporary: Surface = .{ .cols = columns + TAG_TEXT_INSET, .rows = rows, .cells = storage };
- try paintPaneTag(p, &temporary, arena, pane, .{ .x = 0, .y = 0, .w = columns + TAG_TEXT_INSET, .h = rows }, id, active, capacity);
+ try paintPaneTag(p, &temporary, arena, pane, .{ .x = 0, .y = 0, .w = columns + TAG_TEXT_INSET, .h = rows }, id, active);
// Window mode (layout.windowKey): the outlined pane's tag in the
// selection's colours.
if (p.window_pick == id) {
@@ -1292,7 +1290,7 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
@memset(line[0..pad], ' ');
@memcpy(line[pad..], kept);
const layer = &s.tag_layers[NOTICE_LAYER_BASE + id * Pane.Notices.max + i];
- try renderHeaderLayer(p, arena, layer, .notice, @intCast(id), region.rect, line, 0, bg, fg);
+ try renderHeaderLayer(p, layer, .notice, @intCast(id), region.rect, line, 0, bg, fg);
layer.slide = motion.slide;
layer.fade = motion.alpha;
// The caret rides the band, where the prompt's glyphs are.
@@ -1317,7 +1315,7 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
layer.viewport.w -|= region.clip;
}
-pub fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, capacity: u16) !void {
+fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void {
const th = p.theme();
const chrome = p.chromeTheme();
const tx = r.x + @min(TAG_TEXT_INSET, r.w);
@@ -1369,7 +1367,6 @@ pub fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pa
break :caret .{ .row = row, .at = @min(lines[row].len, at.col) };
} else null;
// Its rows are wrapped to fit: a pane tag never scrolls sideways.
- _ = capacity;
pane.tag_scroll = 0;
for (lines[0..rows], 0..) |line, row| {
// The scroll is the caret's line's: a shorter row shows nothing.
@@ -1395,12 +1392,6 @@ pub fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pa
s.at(tx + @as(u16, @intCast(col)), y).style.fg = .{ .rgb = name_fg };
}
};
- if (p.look_hover_preview) |preview| {
- if (preview.pane == id and preview.serial == pane.serial) if (preview.sel) |sel| if (@min(sel.r0, sel.r1) < rows) {
- const preview_bg = colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg));
- body_layer.paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sel, 0, preview_bg, null);
- };
- }
// The tag's own selections, while it has the keyboard, a line at a
// time. A range of one grapheme is the block cursor, not a selection.
if (pane.focus == .tag) {
@@ -2288,7 +2279,7 @@ test "a body with context rows is painted once, and the grid's rows are what a p
@memset(cells, .{});
var plain: Surface = .{ .cols = s.cols, .rows = s.rows, .cells = cells };
pane.view.layered = false;
- try body_layer.renderBody(p, &plain, arena.allocator(), pane, p.rects[0], 0, true, null, null);
+ try body_layer.renderBody(p, &plain, arena.allocator(), pane, p.rects[0], 0, true, null);
pane.view.layered = true;
for (0..body.rect.h) |row| {
const y = body.rect.y + row;