gardesk/gartop / be86402

Browse files

Add emoji indicators for containerized processes in list

Authored by espadonne
SHA
be864020205de58055fbf977b0cdc7598318ac30
Parents
2a7e3ff
Tree
90fd76d

1 changed file

StatusFile+-
M gartop/src/gui/process_list.rs 30 8
gartop/src/gui/process_list.rsmodified
@@ -505,19 +505,41 @@ impl ProcessList {
505505
             // PID
506506
             renderer.text(&process.pid.to_string(), col_pid, text_y, &dim_style)?;
507507
 
508
-            // Name with tree prefix
508
+            // Container indicator prefix
509
+            let container_prefix = process.container.as_ref().map(|c| {
510
+                if c.starts_with("docker:") { "🐳" }
511
+                else if c.starts_with("podman:") { "🦭" }
512
+                else if c.starts_with("k8s:") { "☸" }
513
+                else if c.starts_with("lxc:") { "📦" }
514
+                else { "" }
515
+            }).unwrap_or("");
516
+
517
+            // Name with tree prefix and container indicator
509518
             let name_with_prefix = if tree_view && indent > 0 {
510
-                let prefix = "  ".repeat(indent.saturating_sub(1)) + "├─";
511
-                let max_name_len = 18usize.saturating_sub(prefix.len());
519
+                let tree_prefix = "  ".repeat(indent.saturating_sub(1)) + "├─";
520
+                let full_prefix = if container_prefix.is_empty() {
521
+                    tree_prefix
522
+                } else {
523
+                    format!("{}{}", container_prefix, tree_prefix)
524
+                };
525
+                let max_name_len = 18usize.saturating_sub(full_prefix.chars().count());
512526
                 if process.name.len() > max_name_len {
513
-                    format!("{}{:.width$}..", prefix, process.name, width = max_name_len.saturating_sub(2))
527
+                    format!("{}{:.width$}..", full_prefix, process.name, width = max_name_len.saturating_sub(2))
514528
                 } else {
515
-                    format!("{}{}", prefix, process.name)
529
+                    format!("{}{}", full_prefix, process.name)
516530
                 }
517
-            } else if process.name.len() > 18 {
518
-                format!("{}...", &process.name[..15])
519531
             } else {
520
-                process.name.clone()
532
+                let display_name = if !container_prefix.is_empty() {
533
+                    format!("{}{}", container_prefix, process.name)
534
+                } else {
535
+                    process.name.clone()
536
+                };
537
+                if display_name.chars().count() > 18 {
538
+                    let truncated: String = display_name.chars().take(15).collect();
539
+                    format!("{}...", truncated)
540
+                } else {
541
+                    display_name
542
+                }
521543
             };
522544
             renderer.text(&name_with_prefix, col_name, text_y, &text_style)?;
523545