diff options
| author | 2024-12-13 15:14:15 -0500 | |
|---|---|---|
| committer | 2025-03-20 20:17:07 -0400 | |
| commit | f37875c6c4e42055735f1cda9fdbcb7ab11b80bc (patch) | |
| tree | c889b4287d9d6d7db4fca9fda475c9fd90b33adc /codegen | |
| parent | Update LICENSE, add CONTRIBUTORS.md (diff) | |
| download | zg-f37875c6c4e42055735f1cda9fdbcb7ab11b80bc.tar.gz zg-f37875c6c4e42055735f1cda9fdbcb7ab11b80bc.tar.xz zg-f37875c6c4e42055735f1cda9fdbcb7ab11b80bc.zip | |
Add c0 and c1 control width options
This allows a build of DisplayWidth to give characters in those classes
a width, for cases where they'll be printed with a substitute in the
final display. It also raises the size of possible characters from an
i3 to an i4, to accommodate printing C1s as e.g. <80> or \u{80}.
Diffstat (limited to 'codegen')
| -rw-r--r-- | codegen/dwp.zig | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/codegen/dwp.zig b/codegen/dwp.zig index c581eb6..5e5bf6a 100644 --- a/codegen/dwp.zig +++ b/codegen/dwp.zig | |||
| @@ -4,7 +4,7 @@ const builtin = @import("builtin"); | |||
| 4 | const options = @import("options"); | 4 | const options = @import("options"); |
| 5 | 5 | ||
| 6 | const block_size = 256; | 6 | const block_size = 256; |
| 7 | const Block = [block_size]i3; | 7 | const Block = [block_size]i4; |
| 8 | 8 | ||
| 9 | const BlockMap = std.HashMap( | 9 | const BlockMap = std.HashMap( |
| 10 | Block, | 10 | Block, |
| @@ -17,7 +17,7 @@ const BlockMap = std.HashMap( | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | pub fn eql(_: @This(), a: Block, b: Block) bool { | 19 | pub fn eql(_: @This(), a: Block, b: Block) bool { |
| 20 | return std.mem.eql(i3, &a, &b); | 20 | return std.mem.eql(i4, &a, &b); |
| 21 | } | 21 | } |
| 22 | }, | 22 | }, |
| 23 | std.hash_map.default_max_load_percentage, | 23 | std.hash_map.default_max_load_percentage, |
| @@ -28,7 +28,7 @@ pub fn main() !void { | |||
| 28 | defer arena.deinit(); | 28 | defer arena.deinit(); |
| 29 | const allocator = arena.allocator(); | 29 | const allocator = arena.allocator(); |
| 30 | 30 | ||
| 31 | var flat_map = std.AutoHashMap(u21, i3).init(allocator); | 31 | var flat_map = std.AutoHashMap(u21, i4).init(allocator); |
| 32 | defer flat_map.deinit(); | 32 | defer flat_map.deinit(); |
| 33 | 33 | ||
| 34 | var line_buf: [4096]u8 = undefined; | 34 | var line_buf: [4096]u8 = undefined; |
| @@ -147,10 +147,10 @@ pub fn main() !void { | |||
| 147 | var stage1 = std.ArrayList(u16).init(allocator); | 147 | var stage1 = std.ArrayList(u16).init(allocator); |
| 148 | defer stage1.deinit(); | 148 | defer stage1.deinit(); |
| 149 | 149 | ||
| 150 | var stage2 = std.ArrayList(i3).init(allocator); | 150 | var stage2 = std.ArrayList(i4).init(allocator); |
| 151 | defer stage2.deinit(); | 151 | defer stage2.deinit(); |
| 152 | 152 | ||
| 153 | var block: Block = [_]i3{0} ** block_size; | 153 | var block: Block = [_]i4{0} ** block_size; |
| 154 | var block_len: u16 = 0; | 154 | var block_len: u16 = 0; |
| 155 | 155 | ||
| 156 | for (0..0x110000) |i| { | 156 | for (0..0x110000) |i| { |
| @@ -163,8 +163,8 @@ pub fn main() !void { | |||
| 163 | 0x2e3b => width = 3, | 163 | 0x2e3b => width = 3, |
| 164 | 164 | ||
| 165 | // C0/C1 control codes | 165 | // C0/C1 control codes |
| 166 | 0...0x20, | 166 | 0...0x20 => width = if (options.c0_width) |c0| c0 else 0, |
| 167 | 0x80...0xa0, | 167 | 0x80...0x9f => width = if (options.c1_width) |c1| c1 else 0, |
| 168 | 168 | ||
| 169 | // Line separator | 169 | // Line separator |
| 170 | 0x2028, | 170 | 0x2028, |
| @@ -204,7 +204,7 @@ pub fn main() !void { | |||
| 204 | if (cp == 0xad) width = 1; | 204 | if (cp == 0xad) width = 1; |
| 205 | 205 | ||
| 206 | // Backspace and delete | 206 | // Backspace and delete |
| 207 | if (cp == 0x8 or cp == 0x7f) width = -1; | 207 | if (cp == 0x8 or cp == 0x7f) width = if (options.c0_width) |c0| c0 else -1; |
| 208 | 208 | ||
| 209 | // Process block | 209 | // Process block |
| 210 | block[block_len] = width; | 210 | block[block_len] = width; |