mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-29 21:47:42 +02:00
Merge pull request #122 from lilydjwg/color-filename
colorize filepath at the beginning of line too
This commit is contained in:
commit
c42f97b4da
@ -274,12 +274,7 @@ impl<W: Terminal + Send> Printer<W> {
|
|||||||
self.write_file_sep();
|
self.write_file_sep();
|
||||||
self.write_heading(path.as_ref());
|
self.write_heading(path.as_ref());
|
||||||
} else if !self.heading && self.with_filename {
|
} else if !self.heading && self.with_filename {
|
||||||
self.write_path(path.as_ref());
|
self.write_non_heading_path(path.as_ref());
|
||||||
if self.null {
|
|
||||||
self.write(b"\x00");
|
|
||||||
} else {
|
|
||||||
self.write(b":");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if let Some(line_number) = line_number {
|
if let Some(line_number) = line_number {
|
||||||
self.line_number(line_number, b':');
|
self.line_number(line_number, b':');
|
||||||
@ -361,6 +356,22 @@ impl<W: Terminal + Send> Printer<W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn write_non_heading_path<P: AsRef<Path>>(&mut self, path: P) {
|
||||||
|
if self.wtr.supports_color() {
|
||||||
|
let _ = self.wtr.fg(self.color_choice.heading);
|
||||||
|
let _ = self.wtr.attr(Attr::Bold);
|
||||||
|
}
|
||||||
|
self.write_path(path.as_ref());
|
||||||
|
if self.wtr.supports_color() {
|
||||||
|
let _ = self.wtr.reset();
|
||||||
|
}
|
||||||
|
if self.null {
|
||||||
|
self.write(b"\x00");
|
||||||
|
} else {
|
||||||
|
self.write(b":");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn line_number(&mut self, n: u64, sep: u8) {
|
fn line_number(&mut self, n: u64, sep: u8) {
|
||||||
if self.wtr.supports_color() {
|
if self.wtr.supports_color() {
|
||||||
let _ = self.wtr.fg(self.color_choice.line_number);
|
let _ = self.wtr.fg(self.color_choice.line_number);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user