Update files
This commit is contained in:
1 parent
ca918a4a34
commit
3bdf874584
4 files changed
+146
-31
No files matched your search
+56
-6
@@ -127,6 +127,50 @@ pub fn render_info_lines(
|
||||
lines
|
||||
}
|
||||
|
||||
///|
|
||||
fn render_logo_line(line : String, logo : Logo, no_color : Bool) -> String {
|
||||
if line.is_empty() {
|
||||
return ""
|
||||
}
|
||||
let buf = StringBuilder()
|
||||
let mut has_color = false
|
||||
if !no_color &&
|
||||
!logo.primary_color.is_empty() &&
|
||||
!line.has_prefix("$1") &&
|
||||
!line.has_prefix("$2") {
|
||||
buf.write_string(logo.primary_color)
|
||||
has_color = true
|
||||
}
|
||||
let mut i = 0
|
||||
let len = line.length()
|
||||
while i < len {
|
||||
if i + 1 < len && line[i] == '$' {
|
||||
let next = line[i + 1]
|
||||
if next == '1' {
|
||||
if !no_color && !logo.primary_color.is_empty() {
|
||||
buf.write_string(logo.primary_color)
|
||||
has_color = true
|
||||
}
|
||||
i += 2
|
||||
continue
|
||||
} else if next == '2' {
|
||||
if !no_color && !logo.secondary_color.is_empty() {
|
||||
buf.write_string(logo.secondary_color)
|
||||
has_color = true
|
||||
}
|
||||
i += 2
|
||||
continue
|
||||
}
|
||||
}
|
||||
buf.write_char(Int32::unsafe_to_char(line[i].to_int()))
|
||||
i += 1
|
||||
}
|
||||
if has_color {
|
||||
buf.write_string("\u001b[0m")
|
||||
}
|
||||
buf.to_string()
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn render_fetch(info : SystemInfo, opts : CliOptions) -> String {
|
||||
if opts.json {
|
||||
@@ -146,26 +190,32 @@ pub fn render_fetch(info : SystemInfo, opts : CliOptions) -> String {
|
||||
if opts.no_logo {
|
||||
return info_lines.join("\n")
|
||||
}
|
||||
let rendered_logo : Array[String] = []
|
||||
let mut logo_width = 0
|
||||
for l in logo.lines {
|
||||
let w = visible_len(l)
|
||||
let rl = render_logo_line(l, logo, opts.no_color)
|
||||
rendered_logo.push(rl)
|
||||
let w = visible_len(rl)
|
||||
if w > logo_width {
|
||||
logo_width = w
|
||||
}
|
||||
}
|
||||
let gap = 3
|
||||
let total_rows = if logo.lines.length() > info_lines.length() {
|
||||
logo.lines.length()
|
||||
let total_rows = if rendered_logo.length() > info_lines.length() {
|
||||
rendered_logo.length()
|
||||
} else {
|
||||
info_lines.length()
|
||||
}
|
||||
let out : Array[String] = []
|
||||
for i in 0..<total_rows {
|
||||
let left_raw = if i < logo.lines.length() { logo.lines[i] } else { "" }
|
||||
let left_raw = if i < rendered_logo.length() {
|
||||
rendered_logo[i]
|
||||
} else {
|
||||
""
|
||||
}
|
||||
let left_padded = pad_right_visible(left_raw, logo_width + gap)
|
||||
let left_colored = colorize(left_padded, logo.primary_color, opts.no_color)
|
||||
let right = if i < info_lines.length() { info_lines[i] } else { "" }
|
||||
out.push("\{left_colored}\{right}")
|
||||
out.push("\{left_padded}\{right}")
|
||||
}
|
||||
out.join("\n")
|
||||
}
|
||||
Reference in new issue
Block a user