mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-04 10:08:36 +00:00
printer: add hyperlinks
This commit represents the initial work to get hyperlinks working and was submitted as part of PR #2483. Subsequent commits largely retain the functionality and structure of the hyperlink support added here, but rejigger some things around.
This commit is contained in:
parent
86ef683308
commit
1a50324013
16 changed files with 1178 additions and 83 deletions
|
@ -1,6 +1,7 @@
|
|||
use std::io;
|
||||
|
||||
use termcolor;
|
||||
use termcolor::HyperlinkSpec;
|
||||
|
||||
use crate::is_tty_stdout;
|
||||
|
||||
|
@ -101,6 +102,16 @@ impl termcolor::WriteColor for StandardStream {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn supports_hyperlinks(&self) -> bool {
|
||||
use self::StandardStreamKind::*;
|
||||
|
||||
match self.0 {
|
||||
LineBuffered(ref w) => w.supports_hyperlinks(),
|
||||
BlockBuffered(ref w) => w.supports_hyperlinks(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_color(&mut self, spec: &termcolor::ColorSpec) -> io::Result<()> {
|
||||
use self::StandardStreamKind::*;
|
||||
|
@ -111,6 +122,16 @@ impl termcolor::WriteColor for StandardStream {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_hyperlink(&mut self, link: &HyperlinkSpec) -> io::Result<()> {
|
||||
use self::StandardStreamKind::*;
|
||||
|
||||
match self.0 {
|
||||
LineBuffered(ref mut w) => w.set_hyperlink(link),
|
||||
BlockBuffered(ref mut w) => w.set_hyperlink(link),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn reset(&mut self) -> io::Result<()> {
|
||||
use self::StandardStreamKind::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue