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");
|
|
|
|
const DebugAllocator = @import("debug_allocator.zig");
|
|
|
|
const colour = @import("formatting/colour.zig").colour;
|
|
|
|
|
2020-07-09 19:22:01 +01:00
|
|
|
const Info = @import("types/info.zig").Info;
|
|
|
|
|
|
|
|
pub const SpamWidget = struct {
|
|
|
|
name: []const u8,
|
|
|
|
bar: *Bar,
|
|
|
|
|
|
|
|
pub fn name(self: *SpamWidget) []const u8 {
|
|
|
|
return self.name;
|
|
|
|
}
|
|
|
|
pub fn initial_info(self: *SpamWidget) Info {
|
|
|
|
return Info{
|
|
|
|
.name = self.name,
|
|
|
|
.full_text = "uwu",
|
|
|
|
.markup = "pango",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
pub fn info(self: *SpamWidget) Info {
|
|
|
|
return self.initial_info();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn start(self: *SpamWidget) anyerror!void {
|
|
|
|
var h: bool = true;
|
|
|
|
while (self.bar.keep_running()) {
|
|
|
|
h = !h;
|
|
|
|
if (h) {
|
|
|
|
try self.bar.add(Info{
|
|
|
|
.name = self.name,
|
|
|
|
.full_text = "uwu",
|
|
|
|
.markup = "pango",
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
try self.bar.add(Info{
|
|
|
|
.name = self.name,
|
|
|
|
.full_text = "owo",
|
|
|
|
.markup = "pango",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
pub inline fn NewSpam(bar: *Bar, name: []const u8) SpamWidget {
|
|
|
|
return SpamWidget{
|
|
|
|
.name = name,
|
|
|
|
.bar = bar,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-09 01:16:31 +01:00
|
|
|
pub fn main() !void {
|
2020-07-09 19:22:01 +01:00
|
|
|
const dbgAlloc = &DebugAllocator.init(std.heap.page_allocator, 8192 * 512);
|
|
|
|
defer {
|
|
|
|
std.debug.print("Finished cleanup, last allocation info.\n", .{});
|
|
|
|
std.debug.print("\n{}\n", .{dbgAlloc.info});
|
|
|
|
dbgAlloc.printRemainingStackTraces();
|
|
|
|
dbgAlloc.deinit();
|
|
|
|
}
|
|
|
|
var allocator = &dbgAlloc.allocator;
|
|
|
|
//var allocator = std.heap.page_allocator;
|
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 19:22:01 +01:00
|
|
|
&Widget.init(&textWidget.New("uwu", "potato")),
|
|
|
|
&Widget.init(&NewSpam(&br, "h")),
|
2020-07-09 17:01:59 +01:00
|
|
|
&Widget.init(&weatherWidget.New(allocator, &br, "London")),
|
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();
|
|
|
|
}
|