this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

render: use provided character width

As a pretty large optimization, use the provided width when possible to
avoid measuring glyphs each render

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+10 -2
+4
src/cell.zig
··· 6 6 7 7 pub const Character = struct { 8 8 grapheme: []const u8 = " ", 9 + /// width should only be provided when the application is sure the terminal 10 + /// will meeasure the same width. This can be ensure by using the gwidth method 11 + /// included in libvaxis. If width is 0, libvaxis will measure the glyph at 12 + /// render time 9 13 width: usize = 1, 10 14 }; 11 15
+6 -2
src/vaxis.zig
··· 294 294 const cell = self.screen.buf[i]; 295 295 defer { 296 296 // advance by the width of this char mod 1 297 - const method: gwidth.Method = if (self.caps.unicode) .unicode else .wcwidth; 298 - const w = gwidth.gwidth(cell.char.grapheme, method) catch 1; 297 + const w = blk: { 298 + if (cell.char.width != 0) break :blk cell.char.width; 299 + 300 + const method: gwidth.Method = if (self.caps.unicode) .unicode else .wcwidth; 301 + break :blk gwidth.gwidth(cell.char.grapheme, method) catch 1; 302 + }; 299 303 var j = i + 1; 300 304 while (j < i + w) : (j += 1) { 301 305 self.screen_last.buf[j].skipped = true;