mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-17 11:09:13 +02:00
you didn't see anything...
This commit is contained in:
parent
6dc4875da7
commit
54a322e1e5
1 changed files with 0 additions and 119 deletions
119
out.diff
119
out.diff
|
|
@ -1,119 +0,0 @@
|
|||
diff --git a/build.zig b/build.zig
|
||||
index c53b905..960e649 100644
|
||||
--- a/build.zig
|
||||
+++ b/build.zig
|
||||
@@ -95,6 +95,9 @@ pub fn build(b: *std.Build) !void {
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
+ const check_step = b.step("check", "Check for any errors");
|
||||
+ check_step.dependOn(&exe.step);
|
||||
+
|
||||
const installexe_step = b.step("installexe", "Install Ly and the selected init system service");
|
||||
installexe_step.makeFn = Installer(true).make;
|
||||
installexe_step.dependOn(b.getInstallStep());
|
||||
diff --git a/ly-ui/src/Widget.zig b/ly-ui/src/Widget.zig
|
||||
index d66fce8..07f76c3 100644
|
||||
--- a/ly-ui/src/Widget.zig
|
||||
+++ b/ly-ui/src/Widget.zig
|
||||
@@ -12,6 +12,8 @@ const VTable = struct {
|
||||
calculate_timeout_fn: ?*const fn (ptr: *anyopaque, ctx: *anyopaque) anyerror!?usize,
|
||||
};
|
||||
|
||||
+pub var idCounter: u64 = 0;
|
||||
+
|
||||
id: u64,
|
||||
display_name: []const u8,
|
||||
keybinds: ?TerminalBuffer.KeybindMap,
|
||||
@@ -101,8 +103,9 @@ pub fn init(
|
||||
};
|
||||
};
|
||||
|
||||
+ idCounter += 1;
|
||||
return .{
|
||||
- .id = @intFromPtr(Impl.vtable.draw_fn),
|
||||
+ .id = idCounter,
|
||||
.display_name = display_name,
|
||||
.keybinds = keybinds,
|
||||
.pointer = pointer,
|
||||
diff --git a/ly-ui/src/components/Label.zig b/ly-ui/src/components/Label.zig
|
||||
index 83c651b..86603bb 100644
|
||||
--- a/ly-ui/src/components/Label.zig
|
||||
+++ b/ly-ui/src/components/Label.zig
|
||||
@@ -8,9 +8,8 @@ const Position = @import("../Position.zig");
|
||||
const TerminalBuffer = @import("../TerminalBuffer.zig");
|
||||
const Widget = @import("../Widget.zig");
|
||||
|
||||
-lid: u64, // HACK: we need to differenciate between labels in `updateCustomInfo`.
|
||||
- // The underlying widget ID doesn't have the properties needed.
|
||||
allocator: ?Allocator,
|
||||
+instance: ?Widget,
|
||||
text: []const u8,
|
||||
max_width: ?usize,
|
||||
fg: u32,
|
||||
@@ -32,8 +31,8 @@ pub fn init(
|
||||
) Label {
|
||||
lidCounter += 1;
|
||||
return .{
|
||||
- .lid = lidCounter,
|
||||
.allocator = null,
|
||||
+ .instance = null,
|
||||
.text = text,
|
||||
.max_width = max_width,
|
||||
.fg = fg,
|
||||
@@ -50,7 +49,8 @@ pub fn deinit(self: *Label) void {
|
||||
}
|
||||
|
||||
pub fn widget(self: *Label) Widget {
|
||||
- return Widget.init(
|
||||
+ if (self.instance) |inst| return inst;
|
||||
+ self.instance = Widget.init(
|
||||
"Label",
|
||||
null,
|
||||
self,
|
||||
@@ -61,6 +61,7 @@ pub fn widget(self: *Label) Widget {
|
||||
null,
|
||||
calculateTimeout,
|
||||
);
|
||||
+ return self.instance.?; // We already created the Widget.
|
||||
}
|
||||
|
||||
pub fn setTextAlloc(
|
||||
diff --git a/src/main.zig b/src/main.zig
|
||||
index c049be2..2428f84 100644
|
||||
--- a/src/main.zig
|
||||
+++ b/src/main.zig
|
||||
@@ -1084,14 +1084,14 @@ pub fn main() !void {
|
||||
|
||||
var lblIter = custom.labels.iterator();
|
||||
while (lblIter.next()) |i| {
|
||||
- const w = Label.init("",
|
||||
+ var w = Label.init("",
|
||||
null,
|
||||
state.buffer.fg,
|
||||
state.buffer.bg,
|
||||
&updateCustomInfo,
|
||||
null,
|
||||
);
|
||||
- i.value_ptr.id = w.lid;
|
||||
+ i.value_ptr.id = w.widget().id;
|
||||
i.value_ptr.counter = 2;
|
||||
try state.custom_info.append(state.allocator, .{
|
||||
.info = i.value_ptr.*,
|
||||
@@ -1763,7 +1763,7 @@ fn updateClock(self: *Label, ptr: *anyopaque) !void {
|
||||
|
||||
fn updateCustomInfo(lbl: *Label, ptr: *anyopaque) !void {
|
||||
const state: *UiState = @ptrCast(@alignCast(ptr));
|
||||
- const wid = lbl.lid;
|
||||
+ const wid = lbl.widget().id;
|
||||
var stdout = std.ArrayList(u8).empty;
|
||||
defer stdout.deinit(state.allocator);
|
||||
var stderr = std.ArrayList(u8).empty;
|
||||
@@ -1925,6 +1925,7 @@ fn positionWidgets(ptr: *anyopaque) !void {
|
||||
.addY(@intCast(i)));
|
||||
}
|
||||
for (state.custom_info.items, 0..) |*item, i| {
|
||||
+ std.log.info("{s}: {}", .{item.info.name, item.lbl.widget().id});
|
||||
item.lbl.positionXY(state.edge_margin
|
||||
.addY(@intCast(i))
|
||||
.invertX(state.buffer.width)
|
||||
Loading…
Add table
Add a link
Reference in a new issue