diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-06-02 08:21:22 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-06-02 10:47:50 -0400 |
commit | 0d593c2de31b57664c43b6d075965ae4025c9228 (patch) | |
tree | 8e1603d820fe9b4df24de1ccc2620a62cd85c351 /src/delta.rs | |
parent | 728afaf2ea92505978c1acdccf243be0ed89d671 (diff) |
Implement compositional decoration attributes
Ref #205
Diffstat (limited to 'src/delta.rs')
-rw-r--r-- | src/delta.rs | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/src/delta.rs b/src/delta.rs index bf34e076..4fbeccdf 100644 --- a/src/delta.rs +++ b/src/delta.rs @@ -203,7 +203,22 @@ fn handle_commit_meta_header_line( DecorationStyle::Box(style) => { pad = true; decoration_ansi_term_style = style; - draw::write_boxed_with_line + draw::write_boxed + } + DecorationStyle::BoxWithUnderline(style) => { + pad = true; + decoration_ansi_term_style = style; + draw::write_boxed_with_underline + } + DecorationStyle::BoxWithOverline(style) => { + pad = true; + decoration_ansi_term_style = style; + draw::write_boxed // TODO: not implemented + } + DecorationStyle::BoxWithUnderOverline(style) => { + pad = true; + decoration_ansi_term_style = style; + draw::write_boxed // TODO: not implemented } DecorationStyle::Underline(style) => { decoration_ansi_term_style = style; @@ -213,7 +228,7 @@ fn handle_commit_meta_header_line( decoration_ansi_term_style = style; draw::write_overlined } - DecorationStyle::Underoverline(style) => { + DecorationStyle::UnderOverline(style) => { decoration_ansi_term_style = style; draw::write_underoverlined } @@ -262,7 +277,22 @@ fn handle_generic_file_meta_header_line( DecorationStyle::Box(style) => { pad = true; decoration_ansi_term_style = style; - draw::write_boxed_with_line + draw::write_boxed + } + DecorationStyle::BoxWithUnderline(style) => { + pad = true; + decoration_ansi_term_style = style; + draw::write_boxed_with_underline + } + DecorationStyle::BoxWithOverline(style) => { + pad = true; + decoration_ansi_term_style = style; + draw::write_boxed // TODO: not implemented + } + DecorationStyle::BoxWithUnderOverline(style) => { + pad = true; + decoration_ansi_term_style = style; + draw::write_boxed // TODO: not implemented } DecorationStyle::Underline(style) => { decoration_ansi_term_style = style; @@ -272,7 +302,7 @@ fn handle_generic_file_meta_header_line( decoration_ansi_term_style = style; draw::write_overlined } - DecorationStyle::Underoverline(style) => { + DecorationStyle::UnderOverline(style) => { decoration_ansi_term_style = style; draw::write_underoverlined } @@ -308,6 +338,18 @@ fn handle_hunk_header_line( decoration_ansi_term_style = style; draw::write_boxed } + DecorationStyle::BoxWithUnderline(style) => { + decoration_ansi_term_style = style; + draw::write_boxed_with_underline + } + DecorationStyle::BoxWithOverline(style) => { + decoration_ansi_term_style = style; + draw::write_boxed // TODO: not implemented + } + DecorationStyle::BoxWithUnderOverline(style) => { + decoration_ansi_term_style = style; + draw::write_boxed // TODO: not implemented + } DecorationStyle::Underline(style) => { decoration_ansi_term_style = style; draw::write_underlined @@ -316,7 +358,7 @@ fn handle_hunk_header_line( decoration_ansi_term_style = style; draw::write_overlined } - DecorationStyle::Underoverline(style) => { + DecorationStyle::UnderOverline(style) => { decoration_ansi_term_style = style; draw::write_underoverlined } @@ -341,8 +383,8 @@ fn handle_hunk_header_line( s if s.len() > 0 => format!("{} ", s), s => s, }; + writeln!(painter.writer)?; if !line.is_empty() { - writeln!(painter.writer)?; let lines = vec![line]; let syntax_style_sections = Painter::get_syntax_style_sections_for_lines( &lines, @@ -375,8 +417,8 @@ fn handle_hunk_header_line( } }; match config.hunk_header_style.decoration_ansi_term_style() { - Some(style) => writeln!(painter.writer, "\n{}", style.paint(line_number))?, - None => writeln!(painter.writer, "\n{}", line_number)?, + Some(style) => writeln!(painter.writer, "{}", style.paint(line_number))?, + None => writeln!(painter.writer, "{}", line_number)?, }; Ok(()) } |