diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-08-28 20:10:50 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-08-28 21:36:57 -0400 |
commit | 23e88e55676ec094098bdb5dfbb2bb167c08f994 (patch) | |
tree | b15e861870325d7743cac740c4fade3830aa41f9 /src | |
parent | 2b8a894489c00f426d9d29d0c18f749d2508c8e6 (diff) |
Refactor: eliminate format module
Diffstat (limited to 'src')
-rw-r--r-- | src/delta.rs | 12 | ||||
-rw-r--r-- | src/format.rs | 13 | ||||
-rw-r--r-- | src/main.rs | 1 |
3 files changed, 11 insertions, 15 deletions
diff --git a/src/delta.rs b/src/delta.rs index 53e2add8..bb8c1afc 100644 --- a/src/delta.rs +++ b/src/delta.rs @@ -138,7 +138,7 @@ impl<'a> StateMachine<'a> { writeln!( self.painter.writer, "{}", - format::format_raw_line(&self.raw_line, self.config) + format_raw_line(&self.raw_line, self.config) )?; } } @@ -633,6 +633,16 @@ impl<'a> StateMachine<'a> { } } +/// If output is going to a tty, emit hyperlinks if requested. +// Although raw output should basically be emitted unaltered, we do this. +fn format_raw_line<'a>(line: &'a str, config: &Config) -> Cow<'a, str> { + if config.hyperlinks && atty::is(atty::Stream::Stdout) { + features::hyperlinks::format_commit_line_with_osc8_commit_hyperlink(line, config) + } else { + Cow::from(line) + } +} + /// Write `line` with FileMeta styling. fn _write_generic_file_meta_header_line( line: &str, diff --git a/src/format.rs b/src/format.rs index 5c1bf39f..8b137891 100644 --- a/src/format.rs +++ b/src/format.rs @@ -1,14 +1 @@ -use std::borrow::Cow; -use crate::config::Config; -use crate::features; - -/// If output is going to a tty, emit hyperlinks if requested. -// Although raw output should basically be emitted unaltered, we do this. -pub fn format_raw_line<'a>(line: &'a str, config: &Config) -> Cow<'a, str> { - if config.hyperlinks && atty::is(atty::Stream::Stdout) { - features::hyperlinks::format_commit_line_with_osc8_commit_hyperlink(line, config) - } else { - Cow::from(line) - } -} diff --git a/src/main.rs b/src/main.rs index ccf82661..07e87e7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,6 @@ mod draw; mod edits; mod env; mod features; -mod format; mod git_config; mod hunk_header; mod options; |