From fee780cff7f7be2b64208b4cdc65b166b2d1b680 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Fri, 9 Sep 2022 20:46:28 +0200 Subject: [PATCH] improve writeFiglet function --- scripts/mzteinit/src/figlet.zig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/mzteinit/src/figlet.zig b/scripts/mzteinit/src/figlet.zig index 0686ca2..cb04cd2 100644 --- a/scripts/mzteinit/src/figlet.zig +++ b/scripts/mzteinit/src/figlet.zig @@ -12,18 +12,18 @@ const figlet = pub fn writeFiglet(writer: anytype) !void { var style: ?at.style.Style = null; - var iter = std.mem.split(u8, figlet, "\n"); - while (iter.next()) |line| { - for (line) |char| { - if (char == 'r') { + for (figlet) |char| { + switch (char) { + 'r' => { try at.format.updateStyle(writer, .{ .foreground = .Red }, style); style = .{ .foreground = .Red }; - } else { - try writer.writeByte(char); - } + }, + '\n' => { + try at.format.updateStyle(writer, .{ .foreground = .Default }, style); + style = .{ .foreground = .Default }; + try writer.writeByte('\n'); + }, + else => try writer.writeByte(char), } - try at.format.updateStyle(writer, .{ .foreground = .Default }, style); - style = .{ .foreground = .Default }; - try writer.writeByte('\n'); } }