Merge pull request #12 from utox39/feat-config/config-improvements

Feat config/config improvements
This commit is contained in:
utox39 authored and GitHub committed 2025-08-11 02:34:16 +02:00
commit b6628c3135
3 files changed
+8

No files matched your search

+1
View File
@@ -26,6 +26,7 @@ pub const ModuleType = enum {
net, net,
terminal, terminal,
locale, locale,
custom,
}; };
pub fn getModulesTypes(allocator: std.mem.Allocator, config: ?std.json.Parsed(Config)) !std.ArrayList(ModuleType) { pub fn getModulesTypes(allocator: std.mem.Allocator, config: ?std.json.Parsed(Config)) !std.ArrayList(ModuleType) {
+5
View File
@@ -22,6 +22,7 @@ pub const formatters = [_]*const fn (allocator: std.mem.Allocator, key: []const
&getFormattedNetInfo, &getFormattedNetInfo,
&getFormattedTerminalNameInfo, &getFormattedTerminalNameInfo,
&getFormattedLocaleInfo, &getFormattedLocaleInfo,
&getFormattedCustom,
}; };
pub const default_formatters = [_]*const fn (allocator: std.mem.Allocator) anyerror!Result{ pub const default_formatters = [_]*const fn (allocator: std.mem.Allocator) anyerror!Result{
@@ -207,3 +208,7 @@ pub fn getFormattedNetInfo(allocator: std.mem.Allocator, key: []const u8, key_co
return Result{ .string_arraylist = formatted_net_info_list }; return Result{ .string_arraylist = formatted_net_info_list };
} }
pub fn getFormattedCustom(allocator: std.mem.Allocator, key: []const u8, key_color: []const u8) !Result {
return Result{ .string = try std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ key_color, key, ascii.Reset }) };
}
+2
View File
@@ -62,6 +62,8 @@ pub fn getLongestSysInfoStringLen(strings: []const []const u8) usize {
if (ansi_restet_index != null) { if (ansi_restet_index != null) {
// `start` is the index of the last character of the ANSI reset escape sequence + 1 // `start` is the index of the last character of the ANSI reset escape sequence + 1
start = ansi_restet_index.? + ansi_reset.len + 1; start = ansi_restet_index.? + ansi_reset.len + 1;
if (start > s.len) continue;
} }
longest_len = @max(longest_len, s[start..].len); longest_len = @max(longest_len, s[start..].len);