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