Merge pull request #12 from utox39/feat-config/config-improvements
Feat config/config improvements
This commit is contained in:
@@ -26,6 +26,7 @@ pub const ModuleType = enum {
|
||||
net,
|
||||
terminal,
|
||||
locale,
|
||||
custom,
|
||||
};
|
||||
|
||||
pub fn getModulesTypes(allocator: std.mem.Allocator, config: ?std.json.Parsed(Config)) !std.ArrayList(ModuleType) {
|
||||
|
||||
@@ -22,6 +22,7 @@ pub const formatters = [_]*const fn (allocator: std.mem.Allocator, key: []const
|
||||
&getFormattedNetInfo,
|
||||
&getFormattedTerminalNameInfo,
|
||||
&getFormattedLocaleInfo,
|
||||
&getFormattedCustom,
|
||||
};
|
||||
|
||||
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 };
|
||||
}
|
||||
|
||||
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 }) };
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ pub fn getLongestSysInfoStringLen(strings: []const []const u8) usize {
|
||||
if (ansi_restet_index != null) {
|
||||
// `start` is the index of the last character of the ANSI reset escape sequence + 1
|
||||
start = ansi_restet_index.? + ansi_reset.len + 1;
|
||||
|
||||
if (start > s.len) continue;
|
||||
}
|
||||
|
||||
longest_len = @max(longest_len, s[start..].len);
|
||||
|
||||
Reference in New Issue
Block a user