Skip to main content

plot/
api.rs

1pub mod lib {
2	pub mod job {
3		pub mod config;
4		pub use config::*;
5		pub mod step1;
6		pub use step1::*;
7		pub mod gens {
8			pub mod item_icon;
9			pub mod item_list;
10			pub use item_icon::*;
11			pub use item_list::*;
12		}
13		pub mod step2;
14		pub use step2::*;
15		pub mod step3;
16		pub use step3::*;
17	}
18	pub mod logic {
19		pub mod anchored_paths_datum;
20		pub use anchored_paths_datum::{AnchoredPathsDatum, PathNode};
21		pub mod path_patterns;
22		pub use path_patterns::{PattEnvIndex, PattExp, PattRaw, PatternsQueries};
23		pub mod path_context;
24		pub use path_context::PathContext;
25		pub mod fs_scanner;
26		pub use fs_scanner::{
27			MatchLabel,
28			MatchedDir,
29			MatchedFile,
30			MismatchedDir,
31			MismatchedFile,
32			NodeIs,
33			Partition,
34			PartitionScanned,
35			ScannedDirNode,
36			ScannedFileNode,
37			ScannedNode,
38			StatsPartitioning,
39			StatsScannedTreeFs,
40			is_binary_file,
41		};
42		pub mod path_sort;
43		pub use path_sort::SortQueries;
44		// pub mod paths_table;
45		// pub use paths_table::{FileKind, TableData, TableRow, TableSotcTreeOutput};
46		// pub mod paths_result;
47		// pub use paths_result::{Matched, Mismatched,PartitioningResult};
48
49		pub mod specification;
50		pub use specification::{
51			JobMode,
52			JobSpec,
53			ScanSpec,
54			TabColumn,
55			TabPathStructure,
56			TabSortBy,
57			TabSortOrder,
58			TabSpec,
59		};
60		pub mod tag_time;
61		pub use tag_time::{TagTime, tag_time};
62		pub mod mapper_lang_type;
63		pub use mapper_lang_type::LangMapper;
64		// pub mod engine;
65		// pub use engine::{JobEngine, MX, RenderFlags};
66		// pub mod engine_multiple;
67		// pub use engine_multiple::DocEngineMultiple;
68		pub mod config_model;
69		pub use config_model::{
70			ConfigExport,
71			ConfigJob,
72			ConfigLayout,
73			ConfigManifest,
74			ConfigSpec,
75			ConfigTrimming,
76			ScanRawJobNew,
77		};
78		pub mod file_toml_config;
79		pub use file_toml_config::IoConfig;
80	}
81	// pub mod command {
82	// 	pub mod args;
83	// 	pub mod help;
84	// }
85	pub mod display {
86
87		pub mod anchored_paths_datum;
88		pub mod config;
89		pub mod job_spec;
90		// pub mod fs_scanner;
91		// pub mod paths_patterns;
92		// pub mod paths_result;
93		// pub mod table_data;
94
95		use colored::*;
96
97		pub struct Color;
98		impl Color {
99			pub fn tree(s: &str) -> ColoredString { s.truecolor(41, 211, 152) }
100			pub fn num(s: &str) -> ColoredString { s.bright_magenta() }
101			pub fn size(s: &str) -> ColoredString { s.cyan() }
102			pub fn date(s: &str) -> ColoredString { s.truecolor(140, 120, 100) }
103			pub fn time(s: &str) -> ColoredString { s.truecolor(100, 70, 100) }
104			pub fn folder(s: &str) -> ColoredString { s.truecolor(200, 200, 50).bold() }
105			pub fn file(s: &str) -> ColoredString { s.bright_white() }
106			pub fn binary(s: &str) -> ColoredString { s.bright_red() }
107			pub fn border(s: &str) -> ColoredString { s.truecolor(20, 20, 20).dimmed() }
108		}
109
110		/// [POL]: Scentralizowane symbole formatowania dla projektu.
111		pub struct Icon;
112
113		impl Icon {
114			pub const EMPTY: &'static str = "β­•";
115			// --- Symbole zasobΓ³w ---
116			pub const ENTRY: &'static str = "πŸ—ƒοΈ ";
117			// --- Symbole dla Entry (TwΓ³j styl z obrazka) ---
118			pub const EXPAND: &'static str = "πŸ”€";
119			pub const BOOL_FALSE: &'static str = "βœ–οΈ ";
120			pub const FILE: &'static str = "πŸ“";
121			pub const FOLDER: &'static str = "πŸ“‚";
122			// --- Symbole sekcji ---
123			pub const H2: &'static str = "πŸ“š";
124			pub const FILE2: &'static str = "πŸ“„";
125			pub const FILE2_HIDDEN: &'static str = "βš™οΈ ";
126			// ⚑ --- Symbole zasobów (Rozszerzone - z wersji OLD) ---
127			pub const FOLDER2: &'static str = "πŸ“";
128			pub const FOLDER2_HIDDEN: &'static str = "πŸ—ƒοΈ";
129			pub const LANG_RUST: &'static str = "πŸ¦€";
130			// --- Symbole logiczne (Bool) ---
131			pub const BOOL_TRUE: &'static str = "βœ”οΈ ";
132
133			#[inline]
134			pub fn bool(val: bool) -> &'static str { if val { Self::BOOL_TRUE } else { Self::BOOL_FALSE } }
135		}
136
137		/// [POL]: Rozszerzenie dla bool, aby pisać `val.as_symbol()`.
138		pub trait BoolExt {
139			fn as_symbol(&self) -> &'static str;
140		}
141
142		impl BoolExt for bool {
143			fn as_symbol(&self) -> &'static str { Icon::bool(*self) }
144		}
145		pub struct TreeLast;
146		impl TreeLast {
147			pub const DIR_NO_CHILDREN: &'static str = "└───";
148			pub const DIR_WITH_CHILDREN: &'static str = "└──┬";
149			pub const FILE: &'static str = "└──‒";
150			pub const INDENT: &'static str = "   ";
151		}
152		pub struct TreeMid;
153		impl TreeMid {
154			pub const DIR_NO_CHILDREN: &'static str = "β”œβ”€β”€β”€";
155			pub const DIR_WITH_CHILDREN: &'static str = "β”œβ”€β”€β”¬";
156			pub const FILE: &'static str = "β”œβ”€β”€β€’";
157			pub const INDENT: &'static str = "β”‚  ";
158		}
159
160		pub struct DrawTree;
161		impl DrawTree {
162			pub const ENTRY_BRANCH: &'static str = "  β”œβ”€β”€β”€";
163			// view::fs::entry
164			pub const ENTRY_TERMINAL: &'static str = "  └───";
165			// view::fs::entry
166			pub const ITEM: &'static str = "     β€’";
167			// view::path::pattern
168			pub const ITEM_BETWEEN: &'static str = "  β”œβ”€β”€β€’";
169			// self
170			pub const ITEM_FIRST: &'static str = "  β”Œβ”€β”€β€’";
171			// view::fs::filter
172			pub const ITEM_LAST: &'static str = "  └──‒";
173			// self
174			pub const ITEM_ONEFOLD: &'static str = "   ──‒";
175
176			// self
177
178			/// Automatycznie dobiera symbol gaΕ‚Δ™zi na podstawie indeksu i
179			/// rozmiaru listy.
180			pub fn list(index: usize, total: usize) -> &'static str {
181				if total == 1 {
182					Self::ITEM_ONEFOLD
183				} else if index == 0 {
184					Self::ITEM_FIRST
185				} else if index == total - 1 {
186					Self::ITEM_LAST
187				} else {
188					Self::ITEM_BETWEEN
189				}
190			}
191
192			/// Zwraca krotkΔ™: (symbol_gaΕ‚Δ™zi_dla_siebie, wciΔ™cie_dla_dzieci)
193			pub fn tree(is_dir: bool, is_last: bool, has_children: bool) -> (&'static str, &'static str) {
194				let branch = if is_dir {
195					match (is_last, has_children) {
196						(true, true) => TreeLast::DIR_WITH_CHILDREN,
197						(false, true) => TreeMid::DIR_WITH_CHILDREN,
198						(true, false) => TreeLast::DIR_NO_CHILDREN,
199						(false, false) => TreeMid::DIR_NO_CHILDREN,
200					}
201				} else if is_last {
202					TreeLast::FILE
203				} else {
204					TreeMid::FILE
205				};
206
207				let next_indent = if is_last { TreeLast::INDENT } else { TreeMid::INDENT };
208
209				(branch, next_indent)
210			}
211		}
212	}
213}