Start initial work on CPUWidget.
This commit is contained in:
parent
8dec84876e
commit
cc27e75f20
|
@ -31,7 +31,6 @@ pub fn build(b: *Builder) void {
|
|||
exe.addBuildOption([]const u8, "weather_location", weather_location);
|
||||
|
||||
|
||||
|
||||
//exe.strip = true;
|
||||
exe.addPackage(.{
|
||||
.name = "interfaces",
|
||||
|
|
|
@ -28,7 +28,7 @@ const TerminalYellowColour = "\u{001b}[33m";
|
|||
const TerminalGreenColour = "\u{001b}[32m";
|
||||
const TerminalPurpleColour = "\u{001b}[35m";
|
||||
|
||||
fn getColourFromColour(clr: []const u8) []const u8 {
|
||||
inline fn getColourFromColour(clr: []const u8) []const u8 {
|
||||
if (clr[0] == '#' or clr[0] == '\u{001b}') {
|
||||
return clr;
|
||||
} else if (eql(u8, clr, "text")) {
|
||||
|
|
|
@ -9,6 +9,8 @@ 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 cpuWidget = @import("widgets/memory/memory.zig");
|
||||
|
||||
const DebugAllocator = @import("debug_allocator.zig");
|
||||
const Info = @import("types/info.zig");
|
||||
|
||||
|
@ -30,6 +32,7 @@ pub fn main() !void {
|
|||
const widgets = [_]*Widget{
|
||||
//&Widget.init(&textWidget.New("owo", "potato")), // 4KiB
|
||||
//&Widget.init(&textWidget.New("uwu", "tomato")), // 4KiB
|
||||
&Widget.init(&cpuWidget.New(&br)), // Unknown
|
||||
&Widget.init(&memoryWidget.New(&br)), // 4.08KiB
|
||||
&Widget.init(&weatherWidget.New(allocator, &br, @import("build_options").weather_location)), // 16.16KiB
|
||||
&Widget.init(&batteryWidget.New(allocator, &br)), // 12.11KiB
|
||||
|
|
39
src/widgets/cpu/cpu.zig
Normal file
39
src/widgets/cpu/cpu.zig
Normal file
|
@ -0,0 +1,39 @@
|
|||
const std = @import("std");
|
||||
const Info = @import("../../types/info.zig");
|
||||
const Bar = @import("../../types/bar.zig").Bar;
|
||||
const colour = @import("../../formatting/colour.zig").colour;
|
||||
const comptimeColour = @import("../../formatting/colour.zig").comptimeColour;
|
||||
const MouseEvent = @import("../../types/mouseevent.zig");
|
||||
const LoopingCounter = @import("../../types/loopingcounter.zig").LoopingCounter;
|
||||
|
||||
|
||||
pub const CPUWidget = struct {
|
||||
bar: *Bar,
|
||||
pub fn name(self: *CPUWidget) []const u8 {
|
||||
return "cpu";
|
||||
}
|
||||
pub fn initial_info(self: *CPUWidget) Info {
|
||||
return Info{
|
||||
.name = "cpu",
|
||||
.full_text = "cpu",
|
||||
.markup = "pango",
|
||||
};
|
||||
}
|
||||
|
||||
pub fn mouse_event(self: *CPUWidget, event: MouseEvent) void {}
|
||||
|
||||
fn update_bar(self: *CPUWidget) !void {
|
||||
}
|
||||
|
||||
pub fn start(self: *CPUWidget) anyerror!void {
|
||||
//while (self.bar.keep_running()) {
|
||||
// self.update_bar() catch {};
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
pub inline fn New(bar: *Bar) CPUWidget {
|
||||
return CPUWidget{
|
||||
.bar = bar,
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue