Final fixes, adding fg_ini as field

This commit is contained in:
0xNiffin 2024-07-19 23:36:22 +01:00
parent 3dc1482603
commit 0badcd4a7e
4 changed files with 11 additions and 4 deletions

View File

@ -44,6 +44,9 @@ bg = 0
# Foreground color id
fg = 8
# CMatrix animation foreground color id
cmatrix_fg = 3
# Border color
border_fg = 8
@ -164,4 +167,4 @@ xsessions = /usr/share/xsessions
# Brightness control
brightness_down_key = F5
brightness_up_key = F6
Brightness_change = 10
Brightness_change = 10

View File

@ -34,8 +34,9 @@ dots: []Dot,
lines: []Line,
frame: u64,
count: u64,
fg_ini: u16,
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Matrix {
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, fg_ini: u16) !Matrix {
const dots = try allocator.alloc(Dot, terminal_buffer.width * (terminal_buffer.height + 1));
const lines = try allocator.alloc(Line, terminal_buffer.width);
@ -48,6 +49,7 @@ pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Matrix {
.lines = lines,
.frame = 3,
.count = 0,
.fg_ini = fg_ini,
};
}
@ -145,7 +147,8 @@ pub fn draw(self: *Matrix) void {
var y: u64 = 1;
while (y <= self.terminal_buffer.height) : (y += 1) {
const dot = self.dots[buf_width * y + x];
var fg: u16 = @intCast(termbox.TB_GREEN);
var fg: u16 = self.fg_ini;
if (dot.value == -1 or dot.value == ' ') {
_ = termbox.tb_set_cell(@intCast(x), @intCast(y - 1), ' ', fg, termbox.TB_DEFAULT);

View File

@ -16,6 +16,7 @@ clock: ?[:0]const u8 = null,
console_dev: [:0]const u8 = "/dev/console",
default_input: Input = .login,
fg: u8 = 8,
cmatrix_fg: u8 = 3,
hide_borders: bool = false,
hide_key_hints: bool = false,
initial_info_text: ?[]const u8 = null,

View File

@ -230,7 +230,7 @@ pub fn main() !void {
switch (config.animation) {
.none => {},
.doom => doom = try Doom.init(allocator, &buffer),
.matrix => matrix = try Matrix.init(allocator, &buffer),
.matrix => matrix = try Matrix.init(allocator, &buffer, config.cmatrix_fg),
}
defer {
switch (config.animation) {