summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/File.zig2
-rw-r--r--core/ansi.zig35
-rw-r--r--core/term/terminal.zig19
3 files changed, 19 insertions, 37 deletions
diff --git a/core/File.zig b/core/File.zig
index 0f9178ac..332499b4 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -2942,7 +2942,7 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes.
// A row whose first byte names a hue (syntax.ground_add, _del): its
// grounds, the theme's, worked out once a frame and only for one.
var grounds: ?Colors.Grounds = null;
- const ink = ansi.inkOf(p.theme());
+ const ink = ansi.inkOf(p);
var filtered_storage: pardes.Term.Filter = undefined;
const filtered: ?*pardes.Term.Filter = if (pane.tty_filter and spans.len > 0) blk: {
filtered_storage = pardes.Term.filter(&ink, &p.tty_filter_palette);
diff --git a/core/ansi.zig b/core/ansi.zig
index 3772de43..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;
diff --git a/core/term/terminal.zig b/core/term/terminal.zig
index 88eb1443..1c2310b1 100644
--- a/core/term/terminal.zig
+++ b/core/term/terminal.zig
@@ -418,10 +418,10 @@ pub const min_contrast: f64 = 1.5;
/// `generate256Color` over the theme's sixteen), made again only when the
/// theme's are not the ones `cache` was made of.
pub fn filterPalette(cache: *FilterPalette, ink: *const Ink) *const [256][3]u8 {
- const wanted: FilterPalette.Key = .{ .bg = ink.bg orelse ink.tag_bg, .fg = ink.fg orelse ink.tag_fg, .base = ink.base };
+ const wanted: FilterPalette.Key = .{ .bg = ink.bg, .fg = ink.fg, .ansi = ink.ansi };
if (cache.key) |old| if (std.meta.eql(old, wanted)) return &cache.colors;
var seed = GColor.default;
- for (ink.base, 0..) |rgb, i| seed[i] = asGhostRgb(rgb);
+ for (ink.ansi, 0..) |rgb, i| seed[i] = asGhostRgb(rgb);
const colors = GColor.generate256Color(seed, .empty, asGhostRgb(wanted.bg), asGhostRgb(wanted.fg), false);
for (&cache.colors, colors) |*dst, src| dst.* = asTriple(src);
cache.key = wanted;
@@ -1333,6 +1333,12 @@ fn cellStyle(ink: *const Ink, ci: ghostty_vt.PageList.Cell, filtered: ?*Filter,
},
else => {},
};
+ // SGR faint on the page's text is the page's dim ink (DESIGN.md R15):
+ // toward the page, so as faint on a light theme as on a dark one.
+ if (cs.dim and std.meta.eql(cs.fg, plain.Color{ .rgb = ink.fg })) {
+ cs.fg = .{ .rgb = ink.dim };
+ cs.dim = false;
+ }
return cs;
}
@@ -1353,8 +1359,8 @@ pub fn filterOf(ink: *const Ink, palette: *FilterPalette, vt: ?*const ghostty_vt
for (&source, 0..) |*rgb, i|
rgb.* = t.colorForXterm(.{ .palette = @intCast(i) }) orelse rgb.*;
}
- var theme_bg = asGhostRgb(ink.bg orelse ink.tag_bg);
- var theme_fg = asGhostRgb(ink.fg orelse ink.tag_fg);
+ var theme_bg = asGhostRgb(ink.bg);
+ var theme_fg = asGhostRgb(ink.fg);
var dynamic_bg = if (vt) |t| t.colorForXterm(.{ .dynamic = .background }) else null;
var dynamic_fg = if (vt) |t| t.colorForXterm(.{ .dynamic = .foreground }) else null;
if (vt != null and vt.?.modes.get(.reverse_colors)) {
@@ -1504,10 +1510,7 @@ fn colorDistance(a: GColor.RGB, b: GColor.RGB) u32 {
fn ghostColor(ink: *const Ink, color: ghostty_vt.Style.Color, is_bg: bool) plain.Color {
return switch (color) {
- .none => blk: {
- const t = if (is_bg) ink.bg else ink.fg;
- break :blk if (t) |c| .{ .rgb = c } else .default;
- },
+ .none => if (ink.host) .default else .{ .rgb = if (is_bg) ink.bg else ink.fg },
.palette => |idx| ink.palColor(idx),
.rgb => |rgb| .{ .rgb = .{ rgb.r, rgb.g, rgb.b } },
};