diff --git a/build.zig b/build.zig index 0767875..9cdce66 100644 --- a/build.zig +++ b/build.zig @@ -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", diff --git a/src/formatting/colour.zig b/src/formatting/colour.zig index 29b2c26..ad36f5c 100644 --- a/src/formatting/colour.zig +++ b/src/formatting/colour.zig @@ -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")) { diff --git a/src/main.zig b/src/main.zig index 0e9844a..1489993 100644 --- a/src/main.zig +++ b/src/main.zig @@ -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 diff --git a/src/widgets/cpu/cpu.zig b/src/widgets/cpu/cpu.zig new file mode 100644 index 0000000..b2af4fd --- /dev/null +++ b/src/widgets/cpu/cpu.zig @@ -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, + }; +}