5 Commits

Author SHA1 Message Date
utox39
da70f9ee06 build: bump version to 0.10.0 2025-08-11 02:35:28 +02:00
utox39
b6628c3135 Merge pull request #12 from utox39/feat-config/config-improvements
Feat config/config improvements
2025-08-11 02:34:16 +02:00
utox39
c66d127c4d feat(formatters): add formatter for the 'custom' module 2025-08-10 00:41:06 +02:00
utox39
f3c9b6e9a6 feat(config): add 'custom' module 2025-08-10 00:38:42 +02:00
utox39
d55af958e7 feat(utils): add workaround for start index greater than length 2025-08-10 00:37:37 +02:00
4 changed files with 9 additions and 1 deletions

View File

@@ -10,7 +10,7 @@
// This is a [Semantic Version](https://semver.org/). // This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication. // In a future version of Zig it will be used for package deduplication.
.version = "0.9.1", .version = "0.10.0",
// Together with name, this represents a globally unique package // Together with name, this represents a globally unique package
// identifier. This field is generated by the Zig toolchain when the // identifier. This field is generated by the Zig toolchain when the

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) {

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 }) };
}

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);