1
0
Fork 0

Fix memory widget on release-safe with terminal_version.

This commit is contained in:
namedkitten 2020-07-18 16:57:09 +01:00
parent 233e2eb8b6
commit 81f6ae9877
2 changed files with 6 additions and 7 deletions

View file

@ -32,11 +32,11 @@ pub fn main() !void {
const widgets = [_]*Widget{ const widgets = [_]*Widget{
//&Widget.init(&textWidget.New("owo", "potato")), // 4KiB //&Widget.init(&textWidget.New("owo", "potato")), // 4KiB
//&Widget.init(&textWidget.New("uwu", "tomato")), // 4KiB //&Widget.init(&textWidget.New("uwu", "tomato")), // 4KiB
//&Widget.init(&cpuWidget.New(&br)), // 4.08KiB &Widget.init(&cpuWidget.New(&br)), // 4.08KiB
&Widget.init(&memoryWidget.New(&br)), // 4.08KiB &Widget.init(&memoryWidget.New(&br)), // 4.08KiB
//&Widget.init(&weatherWidget.New(allocator, &br, @import("build_options").weather_location)), // 16.16KiB &Widget.init(&weatherWidget.New(allocator, &br, @import("build_options").weather_location)), // 16.16KiB
//&Widget.init(&batteryWidget.New(allocator, &br)), // 12.11KiB &Widget.init(&batteryWidget.New(allocator, &br)), // 12.11KiB
//&Widget.init(&timeWidget.New(allocator, &br)), // 32.46KiB &Widget.init(&timeWidget.New(allocator, &br)), // 32.46KiB
}; };
bar.widgets = widgets[0..]; bar.widgets = widgets[0..];
try br.start(); try br.start();

View file

@ -98,7 +98,7 @@ fn fetchTotalMemory() !MemInfo {
pub const MemoryWidget = struct { pub const MemoryWidget = struct {
bar: *Bar, bar: *Bar,
lc: *LoopingCounter(8), lc: LoopingCounter(8),
pub fn name(self: *MemoryWidget) []const u8 { pub fn name(self: *MemoryWidget) []const u8 {
return "mem"; return "mem";
} }
@ -123,7 +123,6 @@ pub const MemoryWidget = struct {
var text: []const u8 = " "; var text: []const u8 = " ";
// And this is why I love the looping counter. // And this is why I love the looping counter.
std.debug.print("num: {}\n", .{self.lc});
if (self.lc.get() == 0) { if (self.lc.get() == 0) {
text = try std.fmt.allocPrint(allocator, "{} {}", .{ text = try std.fmt.allocPrint(allocator, "{} {}", .{
comptimeColour("accentlight", "mem"), comptimeColour("accentlight", "mem"),
@ -191,6 +190,6 @@ pub const MemoryWidget = struct {
pub inline fn New(bar: *Bar) MemoryWidget { pub inline fn New(bar: *Bar) MemoryWidget {
return MemoryWidget{ return MemoryWidget{
.bar = bar, .bar = bar,
.lc = &LoopingCounter(8).init(), .lc = LoopingCounter(8).init(),
}; };
} }