mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-21 04:54:18 +02:00
Review
This commit is contained in:
parent
5d51f46db9
commit
54cc513fa1
4 changed files with 29 additions and 23 deletions
|
|
@ -388,7 +388,7 @@ xsessions = $PREFIX_DIRECTORY/share/xsessions
|
|||
# Comments preceding with '#' comment out the example INI.
|
||||
|
||||
##---
|
||||
# Declare a command with the F8 binding.
|
||||
## Declare a command with the F8 binding.
|
||||
#[cmd:F8]
|
||||
## The name of the command to show up in Ly.
|
||||
## Note: "$" in "$brightness_up" fetches the appropriate string from the specified locale file
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ brightness_down = decrease brightness
|
|||
brightness_up = increase brightness
|
||||
capslock = capslock
|
||||
custom = custom
|
||||
|
||||
|
||||
|
||||
custom_info_err_output_long = output too long
|
||||
custom_info_err_no_output = no output
|
||||
custom_info_err_no_output_error = , possible error
|
||||
err_alloc = failed memory allocation
|
||||
err_args = unable to parse command line arguments
|
||||
err_autologin_session = autologin session not found
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
|
|||
}
|
||||
if (std.mem.eql(u8, field.key, "refresh")) {
|
||||
label.refresh = std.fmt.parseInt(u32, field.value, 10) catch 0;
|
||||
label.refresh += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
src/main.zig
47
src/main.zig
|
|
@ -64,9 +64,16 @@ fn ttyControlTransferSignalHandler(_: c_int) callconv(.c) void {
|
|||
TerminalBuffer.shutdown();
|
||||
}
|
||||
|
||||
const CustomBindLabel = struct { cmd: custom.CustomCommandBind, key: []const u8, lbl: Label };
|
||||
const CustomBindLabel = struct {
|
||||
cmd: custom.CustomCommandBind,
|
||||
key: []const u8,
|
||||
lbl: Label,
|
||||
};
|
||||
|
||||
const CustomInfoLabel = struct { info: custom.CustomCommandInfo, lbl: Label };
|
||||
const CustomInfoLabel = struct {
|
||||
info: custom.CustomCommandInfo,
|
||||
lbl: Label,
|
||||
};
|
||||
|
||||
const UiState = struct {
|
||||
allocator: Allocator,
|
||||
|
|
@ -217,8 +224,7 @@ pub fn main() !void {
|
|||
custom.labels = .init(state.allocator);
|
||||
var config_parser = try IniParser(Config).init(state.allocator, config_path, migrator.configFieldHandler);
|
||||
defer config_parser.deinit();
|
||||
defer {
|
||||
if (!shutdown or !restart) {
|
||||
defer if (!shutdown or !restart) {
|
||||
var iter = custom.binds.iterator();
|
||||
while (iter.next()) |i| {
|
||||
temporary_allocator.free(i.key_ptr.*);
|
||||
|
|
@ -233,8 +239,7 @@ pub fn main() !void {
|
|||
temporary_allocator.free(cmd);
|
||||
}
|
||||
custom.labels.deinit();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
state.config = config_parser.structure;
|
||||
|
||||
|
|
@ -1068,25 +1073,28 @@ pub fn main() !void {
|
|||
|
||||
// Layer 2
|
||||
var layer2: std.ArrayList(*Widget) = .empty;
|
||||
state.custom_binds = .empty;
|
||||
state.custom_info = .empty;
|
||||
defer state.custom_binds.deinit(state.allocator);
|
||||
defer state.custom_info.deinit(state.allocator);
|
||||
defer layer2.deinit(state.allocator);
|
||||
|
||||
state.custom_binds = .empty;
|
||||
defer state.custom_binds.deinit(state.allocator);
|
||||
|
||||
state.custom_info = .empty;
|
||||
defer state.custom_info.deinit(state.allocator);
|
||||
|
||||
var lblIter = custom.labels.iterator();
|
||||
while (lblIter.next()) |i| {
|
||||
try state.custom_info.append(state.allocator, .{ .info = i.value_ptr.*, .lbl = .init("", null, state.buffer.fg, state.buffer.bg, &updateCustomInfo, null) });
|
||||
try state.custom_info.append(state.allocator, .{
|
||||
.info = i.value_ptr.*,
|
||||
.lbl = .init("", null, state.buffer.fg, state.buffer.bg, &updateCustomInfo, null),
|
||||
});
|
||||
var latest = &state.custom_info.items[state.custom_info.items.len - 1];
|
||||
latest.info.id = latest.lbl.widget().id;
|
||||
latest.info.counter = 2;
|
||||
latest.info.counter = 1;
|
||||
}
|
||||
defer {
|
||||
for (state.custom_info.items) |*item| {
|
||||
defer for (state.custom_info.items) |*item| {
|
||||
state.allocator.free(item.lbl.text);
|
||||
item.lbl.deinit();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var iter = custom.binds.iterator();
|
||||
while (iter.next()) |i| {
|
||||
|
|
@ -1110,11 +1118,9 @@ pub fn main() !void {
|
|||
});
|
||||
state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator;
|
||||
}
|
||||
defer {
|
||||
for (state.custom_binds.items) |*i| {
|
||||
defer for (state.custom_binds.items) |*i| {
|
||||
i.lbl.deinit();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!state.config.hide_key_hints) {
|
||||
try layer2.append(state.allocator, state.shutdown_label.widget());
|
||||
|
|
@ -1738,6 +1744,7 @@ fn updateCustomInfo(lbl: *Label, ptr: *anyopaque) !void {
|
|||
const wid = lbl.widget().id;
|
||||
var stdout = std.ArrayList(u8).empty;
|
||||
defer stdout.deinit(state.allocator);
|
||||
|
||||
var stderr = std.ArrayList(u8).empty;
|
||||
defer stderr.deinit(state.allocator);
|
||||
for (state.custom_info.items) |*i| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue