tangled
alpha
login
or
join now
rockorager.dev
/
comlink
2
fork
atom
an experimental irc client
2
fork
atom
overview
issues
pulls
pipelines
ui(Scrollbar): update style
rockorager.dev
1 year ago
81555bd7
f9716842
+5
-2
1 changed file
expand all
collapse all
unified
split
src
Scrollbar.zig
+5
-2
src/Scrollbar.zig
···
5
5
const Scrollbar = @This();
6
6
7
7
/// character to use for the scrollbar
8
8
-
character: vaxis.Cell.Character = .{ .grapheme = "▐", .width = 1 },
8
8
+
const character: vaxis.Cell.Character = .{ .grapheme = "▐", .width = 1 };
9
9
+
const empty: vaxis.Cell = .{ .char = character, .style = .{ .fg = .{ .index = 8 } } };
9
10
10
11
/// style to draw the bar character with
11
12
style: vaxis.Style = .{},
···
54
55
// don't draw when all items can be shown
55
56
if (self.view_size >= self.total) return surface;
56
57
58
58
+
@memset(surface.buffer, empty);
59
59
+
57
60
// (view_size / total) * window height = size of the scroll bar
58
61
const bar_height = @max(std.math.divCeil(usize, self.view_size * max.height, self.total) catch unreachable, 1);
59
62
···
62
65
63
66
var i: usize = 0;
64
67
while (i <= bar_height) : (i += 1)
65
65
-
surface.writeCell(0, @intCast(bar_bottom -| i), .{ .char = self.character, .style = self.style });
68
68
+
surface.writeCell(0, @intCast(bar_bottom -| i), .{ .char = character, .style = self.style });
66
69
67
70
return surface;
68
71
}