fix: custom label and bind ordering (#951)

## What are the changes about?

Fixes the order of custom labels and binds because of a HashMap shenanigan (no guaranteed order), so we use `ArrayHashMap` instead which preserves insertion order.  They should now be shown in the order they are declared in the config.

![image](/attachments/7a928c5f-fbbe-4a60-b120-3feddbcdfdb6)

![image](/attachments/22afe011-00a0-4a29-90ab-060e1d059c75)

## What existing issue does this resolve?

!950

## Pre-requisites

- [x] I have tested & confirmed the changes work locally
- [x] I have run `zig fmt` throughout my changes

Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/951
Reviewed-by: AnErrupTion <anerruption+codeberg@disroot.org>
Co-authored-by: RadsammyT <radsammyt@gmail.com>
Co-committed-by: RadsammyT <radsammyt@gmail.com>
This commit is contained in:
RadsammyT
2026-03-27 22:46:37 +01:00
committed by AnErrupTion
parent 5b7c7dfdf5
commit fe6942d406
2 changed files with 20 additions and 20 deletions

View File

@@ -21,5 +21,5 @@ pub const CustomCommandInfo = struct {
counter: u32 = 0,
};
pub var binds: std.StringHashMap(CustomCommandBind) = undefined;
pub var labels: std.StringHashMap(CustomCommandInfo) = undefined;
pub var binds: std.StringArrayHashMap(CustomCommandBind) = undefined;
pub var labels: std.StringArrayHashMap(CustomCommandInfo) = undefined;

View File

@@ -1907,11 +1907,11 @@ fn positionWidgets(ptr: *anyopaque) !void {
}
for (state.custom_info.items, 0..) |*item, i| {
item.lbl.positionXY(state.edge_margin
.addY(@intCast(i))
.invertX(state.buffer.width)
.removeX(item.lbl.text.len)
.invertY(state.buffer.height)
.removeY(1));
.removeY(state.custom_info.items.len)
.addY(i));
}
state.battery_label.positionXY(state.edge_margin