1
0
Fork 0
zar/src/main.zig

46 lines
1.6 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-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-09 22:14:47 +01:00
std.debug.print("{}\n", .{@import("builtin").link_libc});
2020-07-09 20:50:06 +01:00
const debug: bool = true;
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{
&Widget.init(&textWidget.New("owo", "potato")),
2020-07-09 20:50:06 +01:00
&Widget.init(&textWidget.New("uwu", "tomato")),
2020-07-09 17:01:59 +01:00
&Widget.init(&weatherWidget.New(allocator, &br, "London")),
2020-07-09 20:50:06 +01:00
&Widget.init(&timeWidget.New(allocator, &br)),
//&Widget.init(&weatherWidget.New(allocator, &br, "Oxford")),
2020-07-09 19:22:01 +01:00
//&Widget.init(&weatherWidget.New(allocator, &br, "Newcastle")),
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
}