1
0
Fork 0
zar/src/main.zig
2020-07-15 14:37:00 +01:00

43 lines
1.7 KiB
Zig

const std = @import("std");
const Bar = @import("types/bar.zig").Bar;
const Widget = @import("types/widget.zig").Widget;
const barImpl = @import("bar/bar.zig");
const textWidget = @import("widgets/text/text.zig");
const weatherWidget = @import("widgets/weather/weather.zig");
const timeWidget = @import("widgets/time/time.zig");
const batteryWidget = @import("widgets/battery/battery.zig");
const memoryWidget = @import("widgets/memory/memory.zig");
const DebugAllocator = @import("debug_allocator.zig");
const Info = @import("types/info.zig");
pub fn main() !void {
const debug: bool = false;
var allocator: *std.mem.Allocator = undefined;
var dbgAlloc: *DebugAllocator = undefined;
if (debug) {
dbgAlloc = &DebugAllocator.init(std.heap.page_allocator, 8192 * 8192);
allocator = &dbgAlloc.allocator;
} else {
allocator = std.heap.page_allocator;
}
var bar = barImpl.InitBar(allocator);
var br = Bar.init(&bar);
const widgets = [_]*Widget{
//&Widget.init(&textWidget.New("owo", "potato")), // 4KiB
//&Widget.init(&textWidget.New("uwu", "tomato")), // 4KiB
&Widget.init(&memoryWidget.New(&br)), // 4.08KiB
&Widget.init(&weatherWidget.New(allocator, &br, "Stockholm")), // 16.16KiB
&Widget.init(&batteryWidget.New(allocator, &br)), // 12.11KiB
&Widget.init(&timeWidget.New(allocator, &br)), // 32.46KiB
};
bar.widgets = widgets[0..];
try br.start();
if (debug) {
std.debug.print("Finished cleanup, last allocation info.\n", .{});
std.debug.print("\n{}\n", .{dbgAlloc.info});
dbgAlloc.printRemainingStackTraces();
dbgAlloc.deinit();
}
}