1
0
Fork 0

delete the bad

This commit is contained in:
namedkitten 2020-07-24 21:34:29 +01:00
parent bfcd22b329
commit ed1df85bee
3 changed files with 2 additions and 64 deletions

View file

@ -66,6 +66,7 @@ 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(&networkWidget.New(allocator, &br)), // 24.01KiB &Widget.init(&networkWidget.New(allocator, &br)), // 24.01KiB
&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

View file

@ -1,63 +0,0 @@
const std = @import("std");
const Info = @import("../../types/info.zig");
const MouseEvent = @import("../../types/mouseevent.zig");
const Bar = @import("../../types/bar.zig").Bar;
pub const MarqueeTextWidget = struct {
bar: *Bar,
texts: [][]const u8,
pub fn name(self: *MarqueeTextWidget) []const u8 {
return "mqtemp";
}
pub fn initial_info(self: *MarqueeTextWidget) Info {
return Info{
.name = "mqtemp",
.full_text = "mqtemp",
.markup = "pango",
};
}
pub fn mouse_event(self: *MarqueeTextWidget, event: MouseEvent) void {}
pub fn start(self: *MarqueeTextWidget) anyerror!void {
while (self.bar.keep_running()) {
for (self.texts) |y| {
try self.bar.add(Info{
.name = "mqtemp",
.full_text = y,
.markup = "pango",
});
std.time.sleep(std.time.ns_per_ms * 250);
}
}
}
};
pub inline fn New(bar: *Bar, comptime text: []const u8, comptime width: comptime_int) MarqueeTextWidget {
const marqueedtexts = comptime blk: {
@setEvalBranchQuota(100000000);
comptime var new_text: []const u8 = text;
while ((new_text.len % width) != 1) {
comptime new_text = new_text ++ " ";
}
new_text = new_text ++ new_text[0 .. width - 1];
comptime var new_texts: [new_text.len / width][width]u8 = undefined;
var result: [new_text.len][]const u8 = undefined;
comptime var i: i64 = 0;
while (true) {
result[i] = new_text[i .. i + width];
if (i + width == new_text.len) {
break;
} else {
i = i + 1;
}
}
//for (new_texts) |y, i| result[i] = y[0..];
break :blk result[0..];
};
return MarqueeTextWidget{
.bar = bar,
.texts = marqueedtexts,
};
}

View file

@ -205,7 +205,7 @@ pub const MemoryWidget = struct {
while (self.bar.keep_running()) { while (self.bar.keep_running()) {
self.update_bar() catch {}; self.update_bar() catch {};
std.time.sleep(500 * std.time.ns_per_ms); //std.time.sleep(500 * std.time.ns_per_ms);
} }
} }
}; };