1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
// -----------------------------------------------------------------------------
// ๐จ EMOJI MAPPER - Bringing Life to File Types!
// -----------------------------------------------------------------------------
// This module provides a rich, context-aware emoji mapping system that makes
// Smart Tree's output more visually appealing and informative. We map file
// categories to beautiful emojis that help users quickly identify file types.
//
// The system supports both emoji and no-emoji modes, with descriptive text
// fallbacks for environments that don't support emojis.
// -----------------------------------------------------------------------------
use crate::scanner::{FileCategory, FileNode, FileType};
/// Get an emoji (or text representation) for a file based on its type and category
pub fn get_file_emoji(node: &FileNode, no_emoji: bool) -> &'static str {
// Handle permission denied with lock emoji
if node.permission_denied {
return if no_emoji { "[LOCK]" } else { "๐" };
}
// Special handling for directories
if node.is_dir {
return if no_emoji {
if node.size == 0 {
"[EMPTY_DIR]"
} else {
"[DIR]"
}
} else if node.size == 0 {
"๐"
} else {
"๐"
};
}
// Map based on file category for rich, semantic emojis
match node.category {
// Programming Languages
FileCategory::Rust => {
if no_emoji {
"[RUST]"
} else {
"๐ฆ"
}
}
FileCategory::Python => {
if no_emoji {
"[PY]"
} else {
"๐"
}
}
FileCategory::JavaScript => {
if no_emoji {
"[JS]"
} else {
"๐"
}
}
FileCategory::TypeScript => {
if no_emoji {
"[TS]"
} else {
"๐"
}
}
FileCategory::Java => {
if no_emoji {
"[JAVA]"
} else {
"โ"
}
}
FileCategory::C => {
if no_emoji {
"[C]"
} else {
"๐ท"
}
}
FileCategory::Cpp => {
if no_emoji {
"[CPP]"
} else {
"๐ท"
}
}
FileCategory::Go => {
if no_emoji {
"[GO]"
} else {
"๐น"
}
}
FileCategory::Ruby => {
if no_emoji {
"[RB]"
} else {
"๐"
}
}
FileCategory::PHP => {
if no_emoji {
"[PHP]"
} else {
"๐"
}
}
FileCategory::Shell => {
if no_emoji {
"[SH]"
} else {
"๐"
}
}
// Markup & Data
FileCategory::Markdown => {
if no_emoji {
"[MD]"
} else {
"๐"
}
}
FileCategory::Html => {
if no_emoji {
"[HTML]"
} else {
"๐"
}
}
FileCategory::Css => {
if no_emoji {
"[CSS]"
} else {
"๐จ"
}
}
FileCategory::Json => {
if no_emoji {
"[JSON]"
} else {
"๐"
}
}
FileCategory::Yaml => {
if no_emoji {
"[YAML]"
} else {
"๐"
}
}
FileCategory::Xml => {
if no_emoji {
"[XML]"
} else {
"๐ฐ"
}
}
FileCategory::Toml => {
if no_emoji {
"[TOML]"
} else {
"๐ง"
}
}
FileCategory::Csv => {
if no_emoji {
"[CSV]"
} else {
"๐"
}
}
// Build & Config
FileCategory::Makefile => {
if no_emoji {
"[MAKE]"
} else {
"๐จ"
}
}
FileCategory::Dockerfile => {
if no_emoji {
"[DOCKER]"
} else {
"๐ณ"
}
}
FileCategory::GitConfig => {
if no_emoji {
"[GIT]"
} else {
"๐"
}
}
FileCategory::Config => {
if no_emoji {
"[CFG]"
} else {
"โ๏ธ"
}
}
// Archives
FileCategory::Archive => {
if no_emoji {
"[ZIP]"
} else {
"๐ฆ"
}
}
// Media
FileCategory::Image => {
if no_emoji {
"[IMG]"
} else {
"๐ผ๏ธ "
}
}
FileCategory::Video => {
if no_emoji {
"[VID]"
} else {
"๐ฌ"
}
}
FileCategory::Audio => {
if no_emoji {
"[AUD]"
} else {
"๐ต"
}
}
// Office & Documents
FileCategory::Office => {
if no_emoji {
"[DOC]"
} else {
"๐"
}
}
FileCategory::Spreadsheet => {
if no_emoji {
"[XLS]"
} else {
"๐"
}
}
FileCategory::PowerPoint => {
if no_emoji {
"[PPT]"
} else {
"๐"
}
}
FileCategory::Pdf => {
if no_emoji {
"[PDF]"
} else {
"๐"
}
}
FileCategory::Ebook => {
if no_emoji {
"[BOOK]"
} else {
"๐"
}
}
// Text Variants
FileCategory::Txt => {
if no_emoji {
"[TXT]"
} else {
"๐"
}
}
FileCategory::Rtf => {
if no_emoji {
"[RTF]"
} else {
"๐"
}
}
FileCategory::Log => {
if no_emoji {
"[LOG]"
} else {
"๐"
}
}
FileCategory::License => {
if no_emoji {
"[LIC]"
} else {
"๐"
}
}
FileCategory::Readme => {
if no_emoji {
"[README]"
} else {
"๐"
}
}
// Security & Crypto
FileCategory::Certificate => {
if no_emoji {
"[CERT]"
} else {
"๐"
}
}
FileCategory::Encrypted => {
if no_emoji {
"[ENC]"
} else {
"๐"
}
}
// System & Binary
FileCategory::SystemFile => {
if no_emoji {
"[SYS]"
} else {
"โ๏ธ "
}
}
FileCategory::Binary => {
if no_emoji {
"[BIN]"
} else {
"โ๏ธ "
}
}
// Database
FileCategory::Database => {
if no_emoji {
"[DB]"
} else {
"๐๏ธ "
}
}
// Fonts
FileCategory::Font => {
if no_emoji {
"[FONT]"
} else {
"๐ค"
}
}
// Disk Images
FileCategory::DiskImage => {
if no_emoji {
"[DISK]"
} else {
"๐ฟ"
}
}
// 3D & CAD
FileCategory::Model3D => {
if no_emoji {
"[3D]"
} else {
"๐ฒ"
}
}
// Scientific & Data
FileCategory::Jupyter => {
if no_emoji {
"[JUPYTER]"
} else {
"๐"
}
}
FileCategory::RData => {
if no_emoji {
"[RDATA]"
} else {
"๐"
}
}
FileCategory::Matlab => {
if no_emoji {
"[MAT]"
} else {
"๐"
}
}
// Web Assets
FileCategory::WebAsset => {
if no_emoji {
"[WEB]"
} else {
"๐"
}
}
// Package & Dependencies
FileCategory::Package => {
if no_emoji {
"[PKG]"
} else {
"๐ฆ"
}
}
FileCategory::Lock => {
if no_emoji {
"[LOCK]"
} else {
"๐"
}
}
// Testing
FileCategory::Test => {
if no_emoji {
"[TEST]"
} else {
"๐งช"
}
}
// Memory Files (MEM|8!)
FileCategory::Memory => {
if no_emoji {
"[MEM8]"
} else {
"๐ง "
}
}
// Others
FileCategory::Backup => {
if no_emoji {
"[BAK]"
} else {
"๐พ"
}
}
FileCategory::Temp => {
if no_emoji {
"[TMP]"
} else {
"๐๏ธ"
}
}
FileCategory::Unknown => {
// Fall back to file type for unknowns
match node.file_type {
FileType::Symlink => {
if no_emoji {
"[LINK]"
} else {
"๐"
}
}
FileType::Executable => {
if no_emoji {
"[EXE]"
} else {
"โ๏ธ "
}
}
FileType::Socket => {
if no_emoji {
"[SOCK]"
} else {
"๐"
}
}
FileType::Pipe => {
if no_emoji {
"[PIPE]"
} else {
"๐ช"
}
}
FileType::BlockDevice => {
if no_emoji {
"[BLK]"
} else {
"๐พ"
}
}
FileType::CharDevice => {
if no_emoji {
"[CHR]"
} else {
"๐บ"
}
}
FileType::RegularFile => {
if node.size == 0 {
if no_emoji {
"[EMPTY]"
} else {
"๐ชน"
}
} else if no_emoji {
"[FILE]"
} else {
"๐"
}
}
FileType::Directory => {
if no_emoji {
"[DIR]"
} else {
"๐"
}
}
}
}
}
}
/// Get a descriptive name for a file category (used in stats and summaries)
pub fn get_category_name(category: &FileCategory) -> &'static str {
match category {
// Programming Languages
FileCategory::Rust => "Rust Source",
FileCategory::Python => "Python Source",
FileCategory::JavaScript => "JavaScript",
FileCategory::TypeScript => "TypeScript",
FileCategory::Java => "Java Source",
FileCategory::C => "C Source",
FileCategory::Cpp => "C++ Source",
FileCategory::Go => "Go Source",
FileCategory::Ruby => "Ruby Source",
FileCategory::PHP => "PHP Source",
FileCategory::Shell => "Shell Script",
// Markup & Data
FileCategory::Markdown => "Markdown",
FileCategory::Html => "HTML",
FileCategory::Css => "CSS",
FileCategory::Json => "JSON",
FileCategory::Yaml => "YAML",
FileCategory::Xml => "XML",
FileCategory::Toml => "TOML",
FileCategory::Csv => "CSV Data",
// Build & Config
FileCategory::Makefile => "Makefile",
FileCategory::Dockerfile => "Dockerfile",
FileCategory::GitConfig => "Git Config",
FileCategory::Config => "Configuration",
// Archives
FileCategory::Archive => "Archive",
// Media
FileCategory::Image => "Image",
FileCategory::Video => "Video",
FileCategory::Audio => "Audio",
// Office & Documents
FileCategory::Office => "Document",
FileCategory::Spreadsheet => "Spreadsheet",
FileCategory::PowerPoint => "Presentation",
FileCategory::Pdf => "PDF Document",
FileCategory::Ebook => "E-Book",
// Text Variants
FileCategory::Txt => "Text File",
FileCategory::Rtf => "Rich Text",
FileCategory::Log => "Log File",
FileCategory::License => "License",
FileCategory::Readme => "README",
// Security & Crypto
FileCategory::Certificate => "Certificate",
FileCategory::Encrypted => "Encrypted",
// System & Binary
FileCategory::SystemFile => "System File",
FileCategory::Binary => "Binary",
// Database
FileCategory::Database => "Database",
// Fonts
FileCategory::Font => "Font",
// Disk Images
FileCategory::DiskImage => "Disk Image",
// 3D & CAD
FileCategory::Model3D => "3D Model",
// Scientific & Data
FileCategory::Jupyter => "Jupyter Notebook",
FileCategory::RData => "R Data",
FileCategory::Matlab => "MATLAB",
// Web Assets
FileCategory::WebAsset => "Web Asset",
// Package & Dependencies
FileCategory::Package => "Package File",
FileCategory::Lock => "Lock File",
// Testing
FileCategory::Test => "Test File",
// Memory Files
FileCategory::Memory => "MEM|8 File",
// Others
FileCategory::Backup => "Backup",
FileCategory::Temp => "Temporary",
FileCategory::Unknown => "Unknown",
}
}
/// Get a color suggestion for terminal output (ANSI color codes)
pub fn get_category_color(category: &FileCategory) -> &'static str {
match category {
// Programming languages - bright colors
FileCategory::Rust => "\x1b[38;5;208m", // Orange
FileCategory::Python => "\x1b[38;5;226m", // Yellow
FileCategory::JavaScript => "\x1b[38;5;220m", // Gold
FileCategory::TypeScript => "\x1b[38;5;33m", // Blue
FileCategory::Java => "\x1b[38;5;166m", // Dark Orange
FileCategory::C | FileCategory::Cpp => "\x1b[38;5;39m", // Light Blue
FileCategory::Go => "\x1b[38;5;51m", // Cyan
FileCategory::Ruby => "\x1b[38;5;196m", // Red
FileCategory::PHP => "\x1b[38;5;99m", // Purple
FileCategory::Shell => "\x1b[38;5;28m", // Green
// Data formats - cool colors
FileCategory::Json | FileCategory::Yaml | FileCategory::Xml => "\x1b[38;5;45m",
FileCategory::Markdown => "\x1b[38;5;250m",
// Media - vibrant colors
FileCategory::Image => "\x1b[38;5;201m", // Magenta
FileCategory::Video => "\x1b[38;5;129m", // Purple
FileCategory::Audio => "\x1b[38;5;213m", // Pink
// System - muted colors
FileCategory::Binary | FileCategory::SystemFile => "\x1b[38;5;240m",
// Special files
FileCategory::Memory => "\x1b[38;5;93m", // Purple (for MEM|8!)
FileCategory::Database => "\x1b[38;5;94m", // Brown
// Default
_ => "\x1b[0m", // Reset
}
}