fix: always treat control codes as width 1 characters

closes: #64
This commit is contained in:
CJ van den Berg 2024-11-18 10:50:46 +01:00
parent 93302c0325
commit a680f50771
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -374,7 +374,22 @@ inline fn set_font_style(style: *vaxis.Cell.Style, fs: FontStyle) void {
}
}
inline fn is_control_code(c: u8) bool {
return switch (c) {
0...8, 10...31 => true,
else => false,
};
}
pub fn egc_length(self: *const Plane, egcs: []const u8, colcount: *c_int, abs_col: usize, tab_width: usize) usize {
if (egcs.len == 0) {
colcount.* = 0;
return 0;
}
if (is_control_code(egcs[0])) {
colcount.* = 1;
return 1;
}
if (egcs[0] == '\t') {
colcount.* = @intCast(tab_width - (abs_col % tab_width));
return 1;