Skip to content

Commit

Permalink
Make epilogue a provided method
Browse files Browse the repository at this point in the history
It should be the same for all colors, but can be overwritten this way.
  • Loading branch information
hanmertens committed Aug 17, 2020
1 parent 67c2cf8 commit ed81de8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ use core::fmt;

pub trait Color {
fn prelude(&self, f: &mut fmt::Formatter, canvas: Canvas) -> fmt::Result;
fn epilogue(&self, f: &mut fmt::Formatter, canvas: Canvas) -> fmt::Result;
fn epilogue(&self, f: &mut core::fmt::Formatter, _canvas: crate::Canvas) -> core::fmt::Result {
f.write_str("\x1B[0m")
}
}
3 changes: 0 additions & 3 deletions src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ impl Color for RGB8 {
Canvas::Background => write!(f, "\x1B[48;2;{};{};{}m", self.r, self.g, self.b),
}
}
fn epilogue(&self, f: &mut core::fmt::Formatter, _canvas: crate::Canvas) -> core::fmt::Result {
write!(f, "\x1B[0m")
}
}

/// Makes <code style="color: black; background: #FFFFFF">white</code>
Expand Down

0 comments on commit ed81de8

Please sign in to comment.