| ... | @@ -123,34 +123,4 @@ pub const Config = union(enum) { | ... | @@ -123,34 +123,4 @@ pub const Config = union(enum) { |
| 123 | }, | 123 | }, |
| 124 | }; | 124 | }; |
| 125 | } | 125 | } |
| 126 | | | |
| 127 | pub fn writeDEC(conf: Config, writer: anytype, codepoint: u8) !void { | | |
| 128 | const bytes = switch (conf) { | | |
| 129 | .no_color, .windows_api => switch (codepoint) { | | |
| 130 | 0x50...0x5e => @as(*const [1]u8, &codepoint), | | |
| 131 | 0x6a => "+", // ┘ | | |
| 132 | 0x6b => "+", // ┐ | | |
| 133 | 0x6c => "+", // ┌ | | |
| 134 | 0x6d => "+", // └ | | |
| 135 | 0x6e => "+", // ┼ | | |
| 136 | 0x71 => "-", // ─ | | |
| 137 | 0x74 => "+", // ├ | | |
| 138 | 0x75 => "+", // ┤ | | |
| 139 | 0x76 => "+", // ┴ | | |
| 140 | 0x77 => "+", // ┬ | | |
| 141 | 0x78 => "|", // │ | | |
| 142 | else => " ", // TODO | | |
| 143 | }, | | |
| 144 | .escape_codes => switch (codepoint) { | | |
| 145 | // Here we avoid writing the DEC beginning sequence and | | |
| 146 | // ending sequence in separate syscalls by putting the | | |
| 147 | // beginning and ending sequence into the same string | | |
| 148 | // literals, to prevent terminals ending up in bad states | | |
| 149 | // in case a crash happens between syscalls. | | |
| 150 | inline 0x50...0x7f => |x| "\x1B\x28\x30" ++ [1]u8{x} ++ "\x1B\x28\x42", | | |
| 151 | else => unreachable, | | |
| 152 | }, | | |
| 153 | }; | | |
| 154 | return writer.writeAll(bytes); | | |
| 155 | } | | |
| 156 | }; | 126 | }; |