fix: improve alpha rendering on gutter

This commit is contained in:
CJ van den Berg 2024-12-12 19:11:54 +01:00
parent 62a4ec1400
commit fa25d250c6
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 12 additions and 3 deletions

View file

@ -114,6 +114,12 @@ pub fn home(self: *Plane) void {
self.col = 0; self.col = 0;
} }
pub fn fill(self: *Plane, egc: []const u8) void {
for (0..self.dim_y()) |y|
for (0..self.dim_x()) |x|
self.write_cell(x, y, egc);
}
pub fn fill_width(self: *Plane, comptime fmt: anytype, args: anytype) !usize { pub fn fill_width(self: *Plane, comptime fmt: anytype, args: anytype) !usize {
var buf: [fmt.len + 4096]u8 = undefined; var buf: [fmt.len + 4096]u8 = undefined;
var pos: usize = 0; var pos: usize = 0;

View file

@ -121,8 +121,11 @@ inline fn get_width(self: *Self) usize {
pub fn render(self: *Self, theme: *const Widget.Theme) bool { pub fn render(self: *Self, theme: *const Widget.Theme) bool {
const frame = tracy.initZone(@src(), .{ .name = "gutter render" }); const frame = tracy.initZone(@src(), .{ .name = "gutter render" });
defer frame.deinit(); defer frame.deinit();
self.plane.set_base_style(theme.editor_gutter); self.plane.set_base_style(theme.editor);
self.plane.erase(); self.plane.erase();
self.plane.home();
self.plane.set_style(theme.editor_gutter);
_ = self.plane.fill(" ");
if (self.linenum) { if (self.linenum) {
const relative = self.relative or if (tui.current().input_mode) |mode| mode.line_numbers == .relative else false; const relative = self.relative or if (tui.current().input_mode) |mode| mode.line_numbers == .relative else false;
if (relative) if (relative)
@ -160,10 +163,10 @@ pub fn render_linear(self: *Self, theme: *const Widget.Theme) void {
while (rows > 0) : (rows -= 1) { while (rows > 0) : (rows -= 1) {
if (linenum > self.lines) return; if (linenum > self.lines) return;
if (linenum == self.line + 1) { if (linenum == self.line + 1) {
self.plane.set_style(theme.editor_gutter_active); self.plane.set_style(.{ .fg = theme.editor_gutter_active.fg });
self.plane.on_styles(style.bold); self.plane.on_styles(style.bold);
} else { } else {
self.plane.set_style(theme.editor_gutter); self.plane.set_style(.{ .fg = theme.editor_gutter.fg });
self.plane.off_styles(style.bold); self.plane.off_styles(style.bold);
} }
_ = self.plane.print_aligned_right(@intCast(pos), "{s}", .{std.fmt.bufPrintZ(&buf, "{d} ", .{linenum}) catch return}) catch {}; _ = self.plane.print_aligned_right(@intCast(pos), "{s}", .{std.fmt.bufPrintZ(&buf, "{d} ", .{linenum}) catch return}) catch {};