Fast and reasonably complete (framebuffer) terminal emulator (Zig fork)
at trunk 1.2 kB view raw
1const std = @import("std"); 2 3pub const Palette = extern struct { 4 black: u32, 5 red: u32, 6 green: u32, 7 yellow: u32, 8 blue: u32, 9 magenta: u32, 10 cyan: u32, 11 white: u32, 12}; 13 14/// Used for escape sequences 15pub const Color = enum(u8) { 16 black = 30, 17 red = 31, 18 green = 32, 19 yellow = 33, 20 blue = 34, 21 magenta = 35, 22 cyan = 36, 23 white = 37, 24 default = 39, 25 bright_black = 90, 26 bright_red = 91, 27 bright_green = 92, 28 bright_yellow = 93, 29 bright_blue = 94, 30 bright_magenta = 95, 31 bright_cyan = 96, 32 bright_white = 97, 33 34 pub fn esc_seq(comptime self: Color) []const u8 { 35 if (self == .default) return "\x1b[0m"; 36 return std.fmt.comptimePrint("\x1b[{}m", .{@intFromEnum(self)}); 37 } 38}; 39 40pub var default_colors: Palette = .{ 41 .black = 0x000000, 42 .red = 0xff0000, 43 .green = 0x37dd21, 44 .yellow = 0xfee409, 45 .blue = 0x1460d2, 46 .magenta = 0xff005d, 47 .cyan = 0x00bbbb, 48 .white = 0xbbbbbb, 49}; 50 51pub var default_bold_colors: Palette = .{ 52 .black = 0x545454, 53 .red = 0xf40d17, 54 .green = 0x3bcf1d, 55 .yellow = 0xecc809, 56 .blue = 0x5555ff, 57 .magenta = 0xff55ff, 58 .cyan = 0x6ae3f9, 59 .white = 0xffffff, 60};