this repo has no description
13
fork

Configure Feed

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

vxfw(Text and RichtText): render tabs as 8 spaces

+22 -1
+10
src/vxfw/RichText.zig
··· 162 162 var iter = ctx.graphemeIterator(span.text); 163 163 while (iter.next()) |grapheme| { 164 164 const char = grapheme.bytes(span.text); 165 + if (std.mem.eql(u8, char, "\t")) { 166 + const cell: vaxis.Cell = .{ 167 + .char = .{ .grapheme = " ", .width = 1 }, 168 + .style = span.style, 169 + }; 170 + for (0..8) |_| { 171 + try list.append(cell); 172 + } 173 + continue; 174 + } 165 175 const width = ctx.stringWidth(char); 166 176 const cell: vaxis.Cell = .{ 167 177 .char = .{ .grapheme = char, .width = @intCast(width) },
+12 -1
src/vxfw/Text.zig
··· 57 57 var char_iter = ctx.graphemeIterator(line.bytes); 58 58 while (char_iter.next()) |char| { 59 59 const grapheme = char.bytes(line.bytes); 60 + if (std.mem.eql(u8, grapheme, "\t")) { 61 + for (0..8) |i| { 62 + surface.writeCell(@intCast(col + i), row, .{ 63 + .char = .{ .grapheme = " ", .width = 1 }, 64 + .style = self.style, 65 + }); 66 + } 67 + col += 8; 68 + continue; 69 + } 60 70 const grapheme_width: u8 = @intCast(ctx.stringWidth(grapheme)); 61 71 surface.writeCell(col, row, .{ 62 72 .char = .{ .grapheme = grapheme, .width = grapheme_width }, ··· 69 79 var line_iter: LineIterator = .{ .buf = self.text }; 70 80 while (line_iter.next()) |line| { 71 81 if (row >= container_size.height) break; 72 - const line_width = ctx.stringWidth(line); 82 + // \t is default 1 wide. We add 7x the count of tab characters to get the full width 83 + const line_width = ctx.stringWidth(line) + 7 * std.mem.count(u8, line, "\t"); 73 84 defer row += 1; 74 85 const resolved_line_width = @min(container_size.width, line_width); 75 86 var col: u16 = switch (self.text_align) {