Skip to main content

plot/lib/display/
anchored_paths_datum.rs

1use super::DrawTree;
2use crate::lib::logic::{AnchoredPathsDatum, PathNode};
3
4impl std::fmt::Display for PathNode {
5	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6		// Domyślnie pokazujemy znormalizowany ciąg
7		write!(f, "{}", self.str)
8	}
9}
10
11impl std::fmt::Display for AnchoredPathsDatum {
12	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13		let mut lines = Vec::new();
14
15		// 1. Sekcja CWD
16		lines.push("🅰️ 📍 execut_dir (CWD)".to_string());
17		lines.push(format!("{} buf: {}", DrawTree::ENTRY_BRANCH, self.execution_dir.buf.display()));
18		lines.push(format!("{} str: {}", DrawTree::ENTRY_TERMINAL, self.execution_dir.str));
19
20		// 2. Sekcja TARGET
21		lines.push("🅱️ 🎯 select_dir (TARGET)".to_string());
22		lines.push(format!("{} buf: {}", DrawTree::ENTRY_BRANCH, self.workspace_dir.buf.display()));
23		lines.push(format!("{} str: {}", DrawTree::ENTRY_TERMINAL, self.workspace_dir.str));
24
25		// 3. Sekcja RELATIVE
26		lines.push("🆎🔗 relat_path (RELATIVE, BETWEEN CWD & TARGET)".to_string());
27		lines.push(format!("{} str: {}", DrawTree::ENTRY_TERMINAL, self.to_relative_path()));
28
29		// Sklejamy wszystko znakiem nowej linii i wypisujemy zwykłym write!
30		write!(f, "{}", lines.join("\n"))
31	}
32}