Skip to content

Commit 35aa0ff

Browse files
committed
bg_colour for [info, important, warn] files
1 parent e921501 commit 35aa0ff

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

src/main.rs

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ const MB: u64 = 1024_u64.pow(2);
1818
const GB: u64 = 1024_u64.pow(3);
1919
const TB: u64 = 1024_u64.pow(4);
2020

21+
// on white
22+
const NOTES_INFO: &[&'static str] = &["todo", "info"];
2123
// on yellow
22-
const IMPORTANT: &[&'static str] = &["todo", "fixme", "readme", "important"];
24+
const NOTES_IMPORTANT: &[&'static str] = &["readme", "important"];
25+
// on red
26+
const NOTES_WARN: &[&'static str] = &["fixme", "warn", "warning"];
2327
// red
2428
const EXECUTABLE: &[&'static str] = &["exe", "msi", "bat"];
2529
// yellow
@@ -580,7 +584,18 @@ fn print_output_short(name_or_path: String, filetype: &str, file_extension: Stri
580584
match filetype {
581585
"file" => {
582586
let mut name = String::new();
583-
if IMPORTANT
587+
if NOTES_INFO
588+
.iter()
589+
.any(|it| name_or_path.to_lowercase().contains(it))
590+
{
591+
let cstr = format!(
592+
"{}",
593+
name_or_path
594+
.on_truecolor(198, 200, 209)
595+
.truecolor(30, 33, 50)
596+
);
597+
name.push_str(&cstr);
598+
} else if NOTES_IMPORTANT
584599
.iter()
585600
.any(|it| name_or_path.to_lowercase().contains(it))
586601
{
@@ -591,6 +606,17 @@ fn print_output_short(name_or_path: String, filetype: &str, file_extension: Stri
591606
.truecolor(30, 33, 50)
592607
);
593608
name.push_str(&cstr);
609+
} else if NOTES_WARN
610+
.iter()
611+
.any(|it| name_or_path.to_lowercase().contains(it))
612+
{
613+
let cstr = format!(
614+
"{}",
615+
name_or_path
616+
.on_truecolor(226, 120, 120)
617+
.truecolor(30, 33, 50)
618+
);
619+
name.push_str(&cstr);
594620
} else if EXECUTABLE.iter().any(|it| &file_extension == it) {
595621
let cstr = format!("{}", name_or_path.bold().truecolor(226, 120, 120));
596622
name.push_str(&cstr);
@@ -655,7 +681,18 @@ fn print_output_long(
655681
"file" => {
656682
ftype.push_str(".");
657683
if colour {
658-
if IMPORTANT
684+
if NOTES_INFO
685+
.iter()
686+
.any(|it| name_or_path.to_lowercase().contains(it))
687+
{
688+
let cstr = format!(
689+
"{}",
690+
name_or_path
691+
.on_truecolor(198, 200, 209)
692+
.truecolor(30, 33, 50)
693+
);
694+
name.push_str(&cstr);
695+
} else if NOTES_IMPORTANT
659696
.iter()
660697
.any(|it| name_or_path.to_lowercase().contains(it))
661698
{
@@ -666,6 +703,17 @@ fn print_output_long(
666703
.truecolor(30, 33, 50)
667704
);
668705
name.push_str(&cstr);
706+
} else if NOTES_WARN
707+
.iter()
708+
.any(|it| name_or_path.to_lowercase().contains(it))
709+
{
710+
let cstr = format!(
711+
"{}",
712+
name_or_path
713+
.on_truecolor(226, 120, 120)
714+
.truecolor(30, 33, 50)
715+
);
716+
name.push_str(&cstr);
669717
} else if EXECUTABLE.iter().any(|it| &file_extension == it) {
670718
let cstr = format!("{}", name_or_path.bold().truecolor(226, 120, 120));
671719
name.push_str(&cstr);

0 commit comments

Comments
 (0)