summaryrefslogtreecommitdiff
path: root/core/ansi.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/ansi.zig')
-rw-r--r--core/ansi.zig43
1 files changed, 11 insertions, 32 deletions
diff --git a/core/ansi.zig b/core/ansi.zig
index e4fbf5da..3fb866fc 100644
--- a/core/ansi.zig
+++ b/core/ansi.zig
@@ -20,33 +20,12 @@ const Surface = pardes.Surface;
const BodyWalk = @import("body_layer.zig").BodyWalk;
const EditBuffer = panes.Text.EditBuffer;
-/// The theme's colours as a terminal's paint takes them.
-pub fn inkOf(theme: *const pardes.LegacyTheme) Term.Ink {
- return .{
- .fg = theme.fg,
- .bg = theme.bg,
- .tag_fg = theme.tag_fg,
- .tag_bg = theme.tag_bg,
- .palette = theme.palette,
- .base = theme.palette orelse .{
- theme.bg orelse theme.tag_bg,
- theme.kw,
- theme.str,
- theme.num,
- theme.box,
- theme.sel_bg,
- theme.comment,
- theme.fg orelse theme.tag_fg,
- theme.lineno,
- theme.kw,
- theme.str,
- theme.num,
- theme.scroll_thumb,
- theme.sel_fg,
- theme.tag_fg,
- theme.fg orelse theme.tag_fg,
- },
- };
+/// The theme's colours as a terminal's paint takes them (Chrome's: its page,
+/// text, faint and sixteen); a theme that leaves them to the host (`dark`)
+/// leaves them to a tty, and a window draws its own (DESIGN.md R14).
+pub fn inkOf(p: *const Pardes) Term.Ink {
+ const c = p.chrome();
+ return .{ .fg = c.page.text, .bg = c.page.ground, .dim = c.page.dim, .ansi = c.ansi, .host = c.host_page and !p.view().frontend.windowed };
}
/// Its program's colours over the body's rows, through the theme's filter
@@ -85,7 +64,7 @@ pub fn recolor(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw
{
const tz_paint = tracy.zone(@src(), "termPaint");
defer tz_paint.end();
- const ink = inkOf(p.theme());
+ const ink = inkOf(p);
Term.paint(state, &ink, &p.tty_filter_palette, pane.tty_filter, pane.scrolled_to, @intCast(lo), cols, cells, rows);
}
const filtered = pane.tty_filter;
@@ -453,15 +432,15 @@ pub fn recolorDiffOutput(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, t
}
if (lo > hi) return;
const styles = syntax.highlightDiffRows(arena, flat, lo, hi, true) catch return;
- const tints: Colors.Grounds = .of(p.theme());
- const ink = p.theme().fg orelse p.theme().tag_fg;
+ const chrome = p.chrome();
const body_y = p.bodyTop(pane, r);
shown = std.mem.splitScalar(u8, body, '\n');
for (views, 0..) |maybe, vr| {
const line = shown.next() orelse break;
const view = maybe orelse continue;
const base = @intFromPtr(rows[view.row].ptr) - flat_start - lo;
- const tint = if (base < styles.len) tints.forStyle(styles[base]) else null;
+ const lead: u8 = if (base < styles.len) styles[base] else 0;
+ const tint: ?Colors.Chrome.Diff = if (lead & syntax.ground_add != 0) chrome.add else if (lead & syntax.ground_del != 0) chrome.del else null;
if (tint) |t| s.tint(tx, body_y + @as(u16, @intCast(vr)), tw, t.row, null);
var c: usize = 0;
var screen_c: usize = 0;
@@ -478,7 +457,7 @@ pub fn recolorDiffOutput(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, t
else if (panes.File.synStyle(p, @fromBackingInt(@intCast(style & syntax.syn_bits)))) |ss|
ss
else if (tint != null)
- .{ .fg = ink, .bold = false }
+ .{ .fg = chrome.page.text, .bold = false }
else
null;
if (paint) |ss| {