1
0
Fork 0
zar/src/main.zig

43 lines
1.5 KiB
Zig
Raw Normal View History

2020-07-09 01:16:31 +01:00
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");
2020-07-09 20:50:06 +01:00
const timeWidget = @import("widgets/time/time.zig");
2020-07-10 00:13:07 +01:00
const batteryWidget = @import("widgets/battery/battery.zig");
2020-07-09 01:16:31 +01:00
2020-07-09 20:50:06 +01:00
const DebugAllocator = @import("debug_allocator.zig");
2020-07-09 19:22:01 +01:00
const Info = @import("types/info.zig").Info;
2020-07-09 01:16:31 +01:00
pub fn main() !void {
2020-07-10 12:08:45 +01:00
const debug: bool = false;
2020-07-09 20:50:06 +01:00
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;
2020-07-09 19:22:01 +01:00
}
2020-07-09 17:01:59 +01:00
2020-07-09 01:16:31 +01:00
var bar = barImpl.InitBar(allocator);
var br = Bar.init(&bar);
2020-07-09 11:44:36 +01:00
2020-07-09 01:16:31 +01:00
const widgets = [_]*Widget{
2020-07-10 12:08:45 +01:00
&Widget.init(&textWidget.New("owo", "potato")), // 4KiB
&Widget.init(&textWidget.New("uwu", "tomato")), // 4KiB
&Widget.init(&weatherWidget.New(allocator, &br, "London")), // 16KiB
&Widget.init(&batteryWidget.New(allocator, &br)), // 12.11KiB
&Widget.init(&timeWidget.New(allocator, &br)), // 32.46KiB
2020-07-09 01:16:31 +01:00
};
bar.widgets = widgets[0..];
try br.start();
2020-07-09 20:50:06 +01:00
if (debug) {
std.debug.print("Finished cleanup, last allocation info.\n", .{});
std.debug.print("\n{}\n", .{dbgAlloc.info});
dbgAlloc.printRemainingStackTraces();
dbgAlloc.deinit();
}
2020-07-09 01:16:31 +01:00
}