forked from mirrors/jj
formatter: make color_for_name()
a free function
The function doesn't use its `&self` argument anyway.
This commit is contained in:
parent
efd652d7ea
commit
8db8da5990
1 changed files with 21 additions and 21 deletions
|
@ -208,33 +208,33 @@ impl<W> ColorFormatter<W> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let color = self.color_for_name(best_match.1);
|
let color = color_for_name(best_match.1);
|
||||||
self.cached_colors
|
self.cached_colors
|
||||||
.insert(self.labels.clone(), color.clone());
|
.insert(self.labels.clone(), color.clone());
|
||||||
color
|
color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn color_for_name(&self, color_name: &str) -> Vec<u8> {
|
fn color_for_name(color_name: &str) -> Vec<u8> {
|
||||||
match color_name {
|
match color_name {
|
||||||
"black" => b"\x1b[30m".to_vec(),
|
"black" => b"\x1b[30m".to_vec(),
|
||||||
"red" => b"\x1b[31m".to_vec(),
|
"red" => b"\x1b[31m".to_vec(),
|
||||||
"green" => b"\x1b[32m".to_vec(),
|
"green" => b"\x1b[32m".to_vec(),
|
||||||
"yellow" => b"\x1b[33m".to_vec(),
|
"yellow" => b"\x1b[33m".to_vec(),
|
||||||
"blue" => b"\x1b[34m".to_vec(),
|
"blue" => b"\x1b[34m".to_vec(),
|
||||||
"magenta" => b"\x1b[35m".to_vec(),
|
"magenta" => b"\x1b[35m".to_vec(),
|
||||||
"cyan" => b"\x1b[36m".to_vec(),
|
"cyan" => b"\x1b[36m".to_vec(),
|
||||||
"white" => b"\x1b[37m".to_vec(),
|
"white" => b"\x1b[37m".to_vec(),
|
||||||
"bright black" => b"\x1b[1;30m".to_vec(),
|
"bright black" => b"\x1b[1;30m".to_vec(),
|
||||||
"bright red" => b"\x1b[1;31m".to_vec(),
|
"bright red" => b"\x1b[1;31m".to_vec(),
|
||||||
"bright green" => b"\x1b[1;32m".to_vec(),
|
"bright green" => b"\x1b[1;32m".to_vec(),
|
||||||
"bright yellow" => b"\x1b[1;33m".to_vec(),
|
"bright yellow" => b"\x1b[1;33m".to_vec(),
|
||||||
"bright blue" => b"\x1b[1;34m".to_vec(),
|
"bright blue" => b"\x1b[1;34m".to_vec(),
|
||||||
"bright magenta" => b"\x1b[1;35m".to_vec(),
|
"bright magenta" => b"\x1b[1;35m".to_vec(),
|
||||||
"bright cyan" => b"\x1b[1;36m".to_vec(),
|
"bright cyan" => b"\x1b[1;36m".to_vec(),
|
||||||
"bright white" => b"\x1b[1;37m".to_vec(),
|
"bright white" => b"\x1b[1;37m".to_vec(),
|
||||||
_ => b"\x1b[0m".to_vec(),
|
_ => b"\x1b[0m".to_vec(),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue