mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-15 23:30:35 +01:00
Move colors to printer module
This commit is contained in:
parent
120b33a9db
commit
ee43377a9c
@ -1,7 +1,6 @@
|
|||||||
use ansi_term::Style;
|
use ansi_term::Style;
|
||||||
use diff::LineChange;
|
use diff::LineChange;
|
||||||
use printer::Printer;
|
use printer::{Colors, Printer};
|
||||||
use Colors;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DecorationText {
|
pub struct DecorationText {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use ansi_term::Colour::{Fixed, Green, Red, White, Yellow};
|
||||||
|
use ansi_term::Style;
|
||||||
use app::Config;
|
use app::Config;
|
||||||
use console::AnsiCodeIterator;
|
use console::AnsiCodeIterator;
|
||||||
use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
|
use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
|
||||||
@ -9,7 +11,6 @@ use std::vec::Vec;
|
|||||||
use style::OutputWrap;
|
use style::OutputWrap;
|
||||||
use syntect::highlighting;
|
use syntect::highlighting;
|
||||||
use terminal::as_terminal_escaped;
|
use terminal::as_terminal_escaped;
|
||||||
use Colors;
|
|
||||||
|
|
||||||
pub struct Printer<'a> {
|
pub struct Printer<'a> {
|
||||||
handle: &'a mut Write,
|
handle: &'a mut Write,
|
||||||
@ -252,3 +253,33 @@ impl<'a> Printer<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GRID_COLOR: u8 = 238;
|
||||||
|
const LINE_NUMBER_COLOR: u8 = 244;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct Colors {
|
||||||
|
pub grid: Style,
|
||||||
|
pub filename: Style,
|
||||||
|
pub git_added: Style,
|
||||||
|
pub git_removed: Style,
|
||||||
|
pub git_modified: Style,
|
||||||
|
pub line_number: Style,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Colors {
|
||||||
|
fn plain() -> Self {
|
||||||
|
Colors::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn colored() -> Self {
|
||||||
|
Colors {
|
||||||
|
grid: Fixed(GRID_COLOR).normal(),
|
||||||
|
filename: White.bold(),
|
||||||
|
git_added: Green.normal(),
|
||||||
|
git_removed: Red.normal(),
|
||||||
|
git_modified: Yellow.normal(),
|
||||||
|
line_number: Fixed(LINE_NUMBER_COLOR).normal(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user