ignore zero-width characters for now

This commit is contained in:
Mitchell Hashimoto
2022-08-24 13:48:22 -07:00
parent d0f888daae
commit 46bbab5d10
2 changed files with 16 additions and 3 deletions

View File

@ -63,8 +63,7 @@ pub const Cell = struct {
bg: ?color.RGB = null,
/// On/off attributes that can be set
/// TODO: pack it
attrs: struct {
attrs: packed struct {
bold: u1 = 0,
underline: u1 = 0,
inverse: u1 = 0,
@ -82,12 +81,22 @@ pub const Cell = struct {
/// wide character (tail) or following (head).
wide_spacer_tail: u1 = 0,
wide_spacer_head: u1 = 0,
_padding: u1 = 0,
} = .{},
/// True if the cell should be skipped for drawing
pub fn empty(self: Cell) bool {
return self.char == 0;
}
test {
// We use this test to ensure we always get the right size of the attrs
const cell: Cell = .{ .char = 0 };
try std.testing.expectEqual(1, @sizeOf(@TypeOf(cell.attrs)));
log.warn("CELL={}", .{@sizeOf(Cell)});
}
};
pub const RowIterator = struct {

View File

@ -346,7 +346,11 @@ pub fn print(self: *Terminal, c: u21) !void {
// Determine the width of this character so we can handle
// non-single-width characters properly.
const width = utf8proc.charwidth(c);
assert(width == 1 or width == 2);
assert(width <= 2);
// For now, we ignore zero-width characters. When we support ligatures,
// this will have to change.
if (width == 0) return;
// If we're soft-wrapping, then handle that first.
if (self.screen.cursor.pending_wrap and self.modes.autowrap == 1)