feat(terminal): resolve ansi terminal colors from theme
This commit is contained in:
parent
c8f60ef62a
commit
2bc8e0ac18
2 changed files with 29 additions and 2 deletions
|
|
@ -22,8 +22,8 @@
|
|||
.hash = "thespian-0.0.1-owFOjlgiBgC8w4XqkCOegxz5vMy6kNErcssWQWf2QHeE",
|
||||
},
|
||||
.themes = .{
|
||||
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-8fee56fed587a41140e0f1e3df5f133eaba30fff/flow-themes.tar.gz",
|
||||
.hash = "N-V-__8AAFIGKQDuxnfMFMdD88ByPHnt2fKAixmNcZPyfZQD",
|
||||
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-32b5be45c4c001902fc8ff226d2e790e462148ed/flow-themes.tar.gz",
|
||||
.hash = "N-V-__8AAP_iKgB6QFdA6p7L0Yvz2GpIbDtM80oD5lebig9_",
|
||||
},
|
||||
.fuzzig = .{
|
||||
.url = "https://github.com/fjebaker/fuzzig/archive/4251fe4230d38e721514394a485db62ee1667ff3.tar.gz",
|
||||
|
|
|
|||
|
|
@ -388,6 +388,24 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
|||
std.log.err("terminal_view: draw failed: {}", .{e});
|
||||
};
|
||||
|
||||
// Resolve ANSI colour indices 0–15 to theme RGB values
|
||||
{
|
||||
const palette = theme.ansi_palette;
|
||||
const win = self.plane.window;
|
||||
const scr = win.screen;
|
||||
const y_off: usize = @intCast(win.y_off);
|
||||
const x_off: usize = @intCast(win.x_off);
|
||||
for (0..win.height) |row| {
|
||||
const row_base = (y_off + row) * scr.width + x_off;
|
||||
if (row_base >= scr.buf.len) break;
|
||||
const row_end = @min(row_base + win.width, scr.buf.len);
|
||||
for (scr.buf[row_base..row_end]) |*cell| {
|
||||
resolve_color(&cell.style.fg, palette);
|
||||
resolve_color(&cell.style.bg, palette);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!software_cursor and self.focused and tui.terminal_has_focus()) {
|
||||
const scr = &tui.rdr().vx.screen;
|
||||
if (scr.cursor_vis)
|
||||
|
|
@ -397,6 +415,15 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
|||
return false;
|
||||
}
|
||||
|
||||
fn resolve_color(c: *vaxis.Cell.Color, palette: [16][3]u8) void {
|
||||
switch (c.*) {
|
||||
.index => |idx| if (idx < 16) {
|
||||
c.* = .{ .rgb = palette[idx] };
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_child_exit(self: *Self, code: u8) void {
|
||||
switch (self.vt.on_exit) {
|
||||
.hold => self.show_exit_message(code),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue