feat: use solid alpha dimmed background color for highlight column

This commit is contained in:
CJ van den Berg 2025-04-18 20:51:04 +02:00
parent a9b902ab6c
commit 376ca8c9fc
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 42 additions and 38 deletions

View file

@ -23,6 +23,7 @@ const Allocator = std.mem.Allocator;
allocator: Allocator,
rdr_: renderer,
config_: @import("config"),
highlight_columns_: [3]u16,
frame_time: usize, // in microseconds
frame_clock: tp.metronome,
frame_clock_running: bool = false,
@ -123,6 +124,7 @@ fn init(allocator: Allocator) InitError!*Self {
self.* = .{
.allocator = allocator,
.config_ = conf,
.highlight_columns_ = @splat(0),
.rdr_ = try renderer.init(allocator, self, tp.env.get().is("no-alternate"), dispatch_initialized),
.frame_time = frame_time,
.frame_clock = frame_clock,
@ -142,6 +144,16 @@ fn init(allocator: Allocator) InitError!*Self {
instance_ = self;
defer instance_ = null;
if (conf.highlight_columns.len > 0) {
var it = std.mem.splitScalar(u8, conf.highlight_columns, ' ');
var idx: usize = 0;
while (it.next()) |arg| {
if (idx >= self.highlight_columns_.len) break;
self.highlight_columns_[idx] = std.fmt.parseInt(u16, arg, 10) catch 0;
idx += 1;
}
}
self.default_cursor = std.meta.stringToEnum(keybind.CursorShape, conf.default_cursor) orelse .default;
self.config_.default_cursor = @tagName(self.default_cursor);
self.rdr_.handler_ctx = self;
@ -1091,6 +1103,10 @@ pub fn config() *const @import("config") {
return &current().config_;
}
pub fn highlight_columns() []const u16 {
return &current().highlight_columns_;
}
pub fn config_mut() *@import("config") {
return &current().config_;
}