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,14 +208,15 @@ 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(),
|
||||||
|
@ -236,7 +237,6 @@ impl<W> ColorFormatter<W> {
|
||||||
_ => b"\x1b[0m".to_vec(),
|
_ => b"\x1b[0m".to_vec(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<W: Write> Write for ColorFormatter<W> {
|
impl<W: Write> Write for ColorFormatter<W> {
|
||||||
fn write(&mut self, data: &[u8]) -> Result<usize, Error> {
|
fn write(&mut self, data: &[u8]) -> Result<usize, Error> {
|
||||||
|
|
Loading…
Reference in a new issue