13 Commits
Author SHA1 Message Date
sharkdp 98311282e5 Fix #25 2019-01-10 09:03:39 +01:00
Lily Ballard afb6669477 Replace all uses of format!()
Previously we were allocating 2 strings per byte, plus another for the
offset. Instead we can just write all this directly to stdout.

Also replace the calculation of the ANSI escape code for every single
byte. This produces a significant speedup.
2019-01-10 09:00:44 +01:00
sharkdp 0dad8bf481 Bump version 2019-01-10 08:36:45 +01:00
sharkdp 612a227a81 Update dependencies 2019-01-10 08:34:28 +01:00
sharkdp 351fcf0aea Add note about Windows
closes #22
2019-01-10 08:32:46 +01:00
sharkdp 3c3d91cd51 Use 8-bit colors instead of 24-bit truecolor 2019-01-10 08:32:27 +01:00
Lily Ballard 7b7a0ff32d Get rid of the use of str.repeat()
This allocates a string. Instead we can (ab)use format specifiers to do
the repetitions for us.
2019-01-10 07:56:42 +01:00
Sebastian Thiel 2e403a2d11 Make clear we didn't accidentally forget to handle Results 2019-01-09 23:41:29 +01:00
Tobias Kortkamp 155b14e865 Add FreeBSD install instructions to README.md
I've just packaged hexyl for FreeBSD. It should be available in a couple of days from the `latest` package repository.

https://svnweb.freebsd.org/changeset/ports/489825
2019-01-09 23:07:50 +01:00
sharkdp 8429b87594 Re-enable Windows build 2019-01-09 20:20:37 +01:00
Thomas Schneider 1cddf395a8 Update README.md
changed yaourt to 
could be pakku, pikaur, aurman or something 
But yaourt is out of date, insecure and not recommended anymore
2019-01-09 19:55:14 +01:00
Yasuaki Uechi 2a1ae1d295 Add macOS installation guide 2019-01-07 10:09:37 +01:00
sharkdp 57e1c67bfb Disable Windows build 2018-12-30 13:27:21 +01:00
5 changed files with 78 additions and 55 deletions

No files matched your search

+1 -1
View File
@@ -72,7 +72,7 @@ deploy:
# deploy only if we push a tag
tags: true
# deploy only on stable channel that has TARGET env variable sets
condition: $TRAVIS_RUST_VERSION = stable && $TARGET != ""
condition: $TRAVIS_RUST_VERSION = stable && $TARGET != "x86_64-pc-windows-msvc"
notifications:
email:
Generated
+10 -10
View File
@@ -11,7 +11,7 @@ name = "atty"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -38,7 +38,7 @@ dependencies = [
[[package]]
name = "hexyl"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -55,12 +55,12 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.45"
version = "0.2.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "redox_syscall"
version = "0.1.49"
version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -68,7 +68,7 @@ name = "redox_termios"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"redox_syscall 0.1.49 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -82,7 +82,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -91,8 +91,8 @@ name = "termion"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.49 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -150,8 +150,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74"
"checksum redox_syscall 0.1.49 (registry+https://github.com/rust-lang/crates.io-index)" = "f22c50afdcf3f0a31ebb6b47697f6a7c5e5a24967e842858118bce0615f0afad"
"checksum libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)" = "023a4cd09b2ff695f9734c1934145a315594b7986398496841c7031a5a1bbdbd"
"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327"
+1 -1
View File
@@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
name = "hexyl"
readme = "README.md"
repository = "https://github.com/sharkdp/hexyl"
version = "0.3.0"
version = "0.3.1"
[dependencies]
ansi_term = "0.11"
+19 -3
View File
@@ -22,8 +22,8 @@ of bytes (NULL bytes, printable ASCII characters, ASCII whitespace characters, o
### On Debian-based systems
``` bash
wget "https://github.com/sharkdp/hexyl/releases/download/v0.3.0/hexyl_0.3.0_amd64.deb"
sudo dpkg -i hexyl_0.3.0_amd64.deb
wget "https://github.com/sharkdp/hexyl/releases/download/v0.3.1/hexyl_0.3.1_amd64.deb"
sudo dpkg -i hexyl_0.3.1_amd64.deb
```
### On Arch Linux
@@ -31,14 +31,30 @@ sudo dpkg -i hexyl_0.3.0_amd64.deb
You can install `hexyl` from [this AUR package](https://aur.archlinux.org/packages/hexyl/):
```
yaourt -S hexyl
yay -S hexyl
```
### On macOS
```
brew install hexyl
```
### On FreeBSD
```
pkg install hexyl
```
### On other distributions
Check out the [release page](https://github.com/sharkdp/hexyl/releases) for binary builds.
### On Windows
For now, you will have to install from source via `cargo` (see below). Make sure that
you use a terminal that supports ANSI escape sequences (like PowerShell on Windows 10).
### Via cargo
If you have Rust 1.29 or higher, you can install `hexyl` from source via `cargo`:
+47 -40
View File
@@ -8,16 +8,16 @@ use std::io::{self, prelude::*, StdoutLock};
use clap::{App, AppSettings, Arg};
use ansi_term::Colour;
use ansi_term::Colour::RGB;
use ansi_term::Colour::Fixed;
const BUFFER_SIZE: usize = 64;
const COLOR_NULL: Colour = RGB(117, 113, 94); // grey
const COLOR_OFFSET: Colour = RGB(117, 113, 94); // grey
const COLOR_ASCII_PRINTABLE: Colour = RGB(102, 217, 239); // cyan
const COLOR_ASCII_WHITESPACE: Colour = RGB(166, 226, 46); // green
const COLOR_ASCII_OTHER: Colour = RGB(249, 38, 114); // magenta
const COLOR_NONASCII: Colour = RGB(253, 151, 31); // orange
const COLOR_NULL: Colour = Fixed(242); // grey
const COLOR_OFFSET: Colour = Fixed(242); // grey
const COLOR_ASCII_PRINTABLE: Colour = Fixed(81); // cyan
const COLOR_ASCII_WHITESPACE: Colour = Fixed(148); // green
const COLOR_ASCII_OTHER: Colour = Fixed(197); // magenta
const COLOR_NONASCII: Colour = Fixed(208); // orange
enum ByteCategory {
Null,
@@ -78,6 +78,8 @@ struct Printer<'a> {
idx: usize,
line: Vec<u8>,
stdout: StdoutLock<'a>,
byte_hex_table: Vec<String>,
byte_char_table: Vec<String>,
}
impl<'a> Printer<'a> {
@@ -86,41 +88,51 @@ impl<'a> Printer<'a> {
idx: 1,
line: vec![],
stdout,
byte_hex_table: (0u8..=u8::max_value())
.map(|i| format!("{} ", Byte(i).color().paint(format!("{:02x}", i))))
.collect(),
byte_char_table: (0u8..=u8::max_value())
.map(|i| {
format!(
"{}",
Byte(i).color().paint(format!("{}", Byte(i).as_char()))
)
})
.collect(),
}
}
fn header(&mut self) {
writeln!(
self.stdout,
"┌{}┬{}┬{}┬{}┬{}┐",
"─".repeat(8),
"─".repeat(3 * 8 + 1),
"─".repeat(3 * 8 + 1),
"─".repeat(8),
"─".repeat(8)
);
"┌{0:─<8}┬{0:─<25}┬{0:─<25}┬{0:─<8}┬{0:─<8}┐",
""
)
.ok();
}
fn footer(&mut self) {
writeln!(
self.stdout,
"└{}┴{}┴{}┴{}┴{}┘",
"─".repeat(8),
"─".repeat(3 * 8 + 1),
"─".repeat(3 * 8 + 1),
"─".repeat(8),
"─".repeat(8)
);
"└{0:─<8}┴{0:─<25}┴{0:─<25}┴{0:─<8}┴{0:─<8}┘",
""
)
.ok();
}
fn print_byte(&mut self, b: u8) -> io::Result<()> {
if self.idx % 16 == 1 {
let offset_str = format!("{:08x}", self.idx - 1);
write!(self.stdout, "│{}│ ", COLOR_OFFSET.paint(offset_str))?;
let style = COLOR_OFFSET.normal();
write!(
self.stdout,
"│{}{:08x}{}│ ",
style.prefix(),
self.idx - 1,
style.suffix()
)?;
}
let byte_str = format!("{:02x} ", b);
write!(self.stdout, "{}", Byte(b).color().paint(byte_str))?;
write!(self.stdout, "{}", self.byte_hex_table[b as usize])?;
self.line.push(b);
match self.idx % 16 {
@@ -146,35 +158,30 @@ impl<'a> Printer<'a> {
if len < 8 {
write!(
self.stdout,
"{}┊{}│",
" ".repeat(3 * (8 - len)),
" ".repeat(1 + 3 * 8)
"{0:1$}┊{0:2$}│",
"",
3 * (8 - len),
1 + 3 * 8
)?;
} else {
write!(self.stdout, "{}│", " ".repeat(3 * (16 - len)))?;
write!(self.stdout, "{0:1$}│", "", 3 * (16 - len))?;
}
let mut idx = 1;
for b in self.line.iter().map(|b| Byte(*b)) {
let chr = format!("{}", b.as_char());
write!(self.stdout, "{}", b.color().paint(chr)).ok();
for &b in self.line.iter() {
write!(self.stdout, "{}", self.byte_char_table[b as usize])?;
if idx == 8 {
write!(self.stdout, "┊");
write!(self.stdout, "┊").ok();
}
idx += 1;
}
if len < 8 {
writeln!(
self.stdout,
"{}┊{}│ ",
" ".repeat(8 - len),
" ".repeat(8)
)?;
writeln!(self.stdout, "{0:1$}┊{0:2$}│ ", "", 8 - len, 8)?;
} else {
writeln!(self.stdout, "{}│", " ".repeat(16 - len))?;
writeln!(self.stdout, "{0:1$}│", "", 16 - len)?;
}
self.line.clear();