feat(display): add render_ascii function for text-only output
Swadhin Biswas committed 7 months ago
5b0417d
1 parent 4910c5d
commit 5b0417d
1 file changed
+50 -0
Showing 1 changed file+50-0
▼src/display/mod.rs
+50-0
| @@ -498,3 +498,53 @@ impl Display { | ||
498 | 498 | if self.config.show_gpu { |
499 | 499 | for (i, gpu_entry) in sys.gpu.iter().enumerate() { |
500 | 500 | if gpu_entry != "Unknown" && !gpu_entry.is_empty() { |
501 | + let label = if sys.gpu.len() > 1 { | |
502 | + format!("GPU{}", i) | |
503 | + } else { | |
504 | + "GPU".to_string() | |
505 | + }; | |
506 | + lines.push(field(&label, "\u{f4bd}", gpu_entry)); | |
507 | + } | |
508 | + } | |
509 | + } | |
510 | + | |
511 | + // Memory — optionally with progress bar | |
512 | + if self.config.show_memory && sys.memory != "Unknown" && !sys.memory.is_empty() { | |
513 | + if self.config.memory_bar { | |
514 | + let bar = colors::progress_bar( | |
515 | + sys.memory_percent, | |
516 | + self.config.bar_width, | |
517 | + &scheme.c[0], | |
518 | + ); | |
519 | + lines.push(field("Memory", "\u{f85a}", &format!("{} {}", sys.memory, bar))); | |
520 | + } else { | |
521 | + lines.push(field("Memory", "\u{f85a}", &sys.memory)); | |
522 | + } | |
523 | + } | |
524 | + | |
525 | + // Disk — optionally with progress bar | |
526 | + if self.config.show_disk && sys.disk != "Unknown" && !sys.disk.is_empty() { | |
527 | + if self.config.disk_bar { | |
528 | + let bar = colors::progress_bar( | |
529 | + sys.disk_percent, | |
530 | + self.config.bar_width, | |
531 | + &scheme.c[0], | |
532 | + ); | |
533 | + lines.push(field("Disk", "\u{f0a0}", &format!("{} {}", sys.disk, bar))); | |
534 | + } else { | |
535 | + lines.push(field("Disk", "\u{f0a0}", &sys.disk)); | |
536 | + } | |
537 | + } | |
538 | + | |
539 | + add_field!( | |
540 | + self.config.show_battery, | |
541 | + "Battery", | |
542 | + "\u{f240}", | |
543 | + &sys.battery | |
544 | + ); // | |
545 | + add_field!( | |
546 | + self.config.show_local_ip, | |
547 | + "Local IP", | |
548 | + "\u{f6ff}", | |
549 | + &sys.local_ip | |
550 | + ); // | |
501 | 551 | |