mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-30 09:05:54 +00:00
Use 16 colors instead of 256
This commit is contained in:
1 parent
f6f41e76aa
commit
39a83021dc
1 file changed
+13
-11
+13
-11
@@ -8,19 +8,19 @@ use std::io::{self, prelude::*, StdoutLock};
|
|||||||
|
|
||||||
use clap::{App, AppSettings, Arg};
|
use clap::{App, AppSettings, Arg};
|
||||||
|
|
||||||
use ansi_term::Colour;
|
use ansi_term::Color;
|
||||||
use ansi_term::Colour::Fixed;
|
use ansi_term::Color::Fixed;
|
||||||
|
|
||||||
use atty::Stream;
|
use atty::Stream;
|
||||||
|
|
||||||
const BUFFER_SIZE: usize = 256;
|
const BUFFER_SIZE: usize = 256;
|
||||||
|
|
||||||
const COLOR_NULL: Colour = Fixed(242); // grey
|
const COLOR_NULL: Color = Fixed(242); // grey
|
||||||
const COLOR_OFFSET: Colour = Fixed(242); // grey
|
const COLOR_OFFSET: Color = Fixed(242); // grey
|
||||||
const COLOR_ASCII_PRINTABLE: Colour = Fixed(81); // cyan
|
const COLOR_ASCII_PRINTABLE: Color = Color::Cyan;
|
||||||
const COLOR_ASCII_WHITESPACE: Colour = Fixed(148); // green
|
const COLOR_ASCII_WHITESPACE: Color = Color::Green;
|
||||||
const COLOR_ASCII_OTHER: Colour = Fixed(197); // magenta
|
const COLOR_ASCII_OTHER: Color = Color::Purple;
|
||||||
const COLOR_NONASCII: Colour = Fixed(208); // orange
|
const COLOR_NONASCII: Color = Color::Yellow;
|
||||||
|
|
||||||
enum ByteCategory {
|
enum ByteCategory {
|
||||||
Null,
|
Null,
|
||||||
@@ -51,7 +51,7 @@ impl Byte {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn color(self) -> &'static Colour {
|
fn color(self) -> &'static Color {
|
||||||
use ByteCategory::*;
|
use ByteCategory::*;
|
||||||
|
|
||||||
match self.category() {
|
match self.category() {
|
||||||
@@ -238,8 +238,10 @@ fn run() -> Result<(), Box<::std::error::Error>> {
|
|||||||
.value_name("when")
|
.value_name("when")
|
||||||
.possible_values(&["always", "auto", "never"])
|
.possible_values(&["always", "auto", "never"])
|
||||||
.default_value("always")
|
.default_value("always")
|
||||||
.help("When to use colors. The auto-mode only displays colors if the output \
|
.help(
|
||||||
goes to an interactive terminal"),
|
"When to use colors. The auto-mode only displays colors if the output \
|
||||||
|
goes to an interactive terminal",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let matches = app.get_matches_safe()?;
|
let matches = app.get_matches_safe()?;
|
||||||
|
|||||||
Reference in new issue
Block a user