Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da70f9ee06 | ||
|
|
b6628c3135 | ||
|
|
c66d127c4d | ||
|
|
f3c9b6e9a6 | ||
|
|
d55af958e7 | ||
|
|
3bcfff5bdc | ||
|
|
42edc5c24b |
@@ -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.0",
|
.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
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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 }) };
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ pub const TermSize = struct {
|
|||||||
pub fn getTerminalSize() !TermSize {
|
pub fn getTerminalSize() !TermSize {
|
||||||
// https://github.com/softprops/zig-termsize (https://github.com/softprops/zig-termsize/blob/main/src/main.zig)
|
// https://github.com/softprops/zig-termsize (https://github.com/softprops/zig-termsize/blob/main/src/main.zig)
|
||||||
|
|
||||||
const stdout = std.io.getStdIn();
|
const stdout = std.io.getStdOut();
|
||||||
|
|
||||||
switch (builtin.os.tag) {
|
switch (builtin.os.tag) {
|
||||||
.windows => {
|
.windows => {
|
||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user