mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
connect fg/bg of cell to renderer
This commit is contained in:
42
src/Grid.zig
42
src/Grid.zig
@ -268,7 +268,8 @@ pub fn updateCells(self: *Grid, term: Terminal) !void {
|
|||||||
if (term.screen.items.len == 0) return;
|
if (term.screen.items.len == 0) return;
|
||||||
try self.cells.ensureTotalCapacity(
|
try self.cells.ensureTotalCapacity(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
term.screen.items.len * term.cols,
|
(term.screen.items.len * term.cols * 2) + 1, // * 2 for background modes and cursor
|
||||||
|
// + 1 for cursor
|
||||||
);
|
);
|
||||||
|
|
||||||
// Build each cell
|
// Build each cell
|
||||||
@ -281,7 +282,34 @@ pub fn updateCells(self: *Grid, term: Terminal) !void {
|
|||||||
// TODO: if we add a glyph, I think we need to rerender the texture.
|
// TODO: if we add a glyph, I think we need to rerender the texture.
|
||||||
const glyph = try self.font_atlas.addGlyph(self.alloc, cell.char);
|
const glyph = try self.font_atlas.addGlyph(self.alloc, cell.char);
|
||||||
|
|
||||||
// TODO: for background colors, add another cell with mode = 1
|
if (cell.bg) |rgb| {
|
||||||
|
self.cells.appendAssumeCapacity(.{
|
||||||
|
.mode = 1,
|
||||||
|
.grid_col = @intCast(u16, x),
|
||||||
|
.grid_row = @intCast(u16, y),
|
||||||
|
.glyph_x = glyph.atlas_x,
|
||||||
|
.glyph_y = glyph.atlas_y,
|
||||||
|
.glyph_width = glyph.width,
|
||||||
|
.glyph_height = glyph.height,
|
||||||
|
.glyph_offset_x = glyph.offset_x,
|
||||||
|
.glyph_offset_y = glyph.offset_y,
|
||||||
|
.fg_r = 0,
|
||||||
|
.fg_g = 0,
|
||||||
|
.fg_b = 0,
|
||||||
|
.fg_a = 0,
|
||||||
|
.bg_r = rgb.r,
|
||||||
|
.bg_g = rgb.g,
|
||||||
|
.bg_b = rgb.b,
|
||||||
|
.bg_a = 0xFF,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const fg = cell.fg orelse Terminal.RGB{
|
||||||
|
.r = 0xFF,
|
||||||
|
.g = 0xA5,
|
||||||
|
.b = 0,
|
||||||
|
};
|
||||||
|
|
||||||
self.cells.appendAssumeCapacity(.{
|
self.cells.appendAssumeCapacity(.{
|
||||||
.mode = 2,
|
.mode = 2,
|
||||||
.grid_col = @intCast(u16, x),
|
.grid_col = @intCast(u16, x),
|
||||||
@ -292,12 +320,12 @@ pub fn updateCells(self: *Grid, term: Terminal) !void {
|
|||||||
.glyph_height = glyph.height,
|
.glyph_height = glyph.height,
|
||||||
.glyph_offset_x = glyph.offset_x,
|
.glyph_offset_x = glyph.offset_x,
|
||||||
.glyph_offset_y = glyph.offset_y,
|
.glyph_offset_y = glyph.offset_y,
|
||||||
.fg_r = 0xFF,
|
.fg_r = fg.r,
|
||||||
.fg_g = 0xA5,
|
.fg_g = fg.g,
|
||||||
.fg_b = 0,
|
.fg_b = fg.b,
|
||||||
.fg_a = 255,
|
.fg_a = 255,
|
||||||
.bg_r = 0x0,
|
.bg_r = 0,
|
||||||
.bg_g = 0xA5,
|
.bg_g = 0,
|
||||||
.bg_b = 0,
|
.bg_b = 0,
|
||||||
.bg_a = 0,
|
.bg_a = 0,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user