mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-30 09:05:54 +00:00
Remove Ctrl-C handler, fixes #84
This commit is contained in:
1 parent
3b01d0ce19
commit
f71ad1e00d
4 files changed
+3
-70
No files matched your search
+2
-14
@@ -1,16 +1,12 @@
|
||||
pub mod squeezer;
|
||||
|
||||
use std::io::{self, Read, Write};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
use ansi_term::Color;
|
||||
use ansi_term::Color::Fixed;
|
||||
|
||||
use crate::squeezer::{SqueezeAction, Squeezer};
|
||||
|
||||
type Cancelled = Arc<AtomicBool>;
|
||||
|
||||
const BUFFER_SIZE: usize = 256;
|
||||
|
||||
const COLOR_NULL: Color = Fixed(242); // grey
|
||||
@@ -408,11 +404,10 @@ impl<'a, Writer: Write> Printer<'a, Writer> {
|
||||
}
|
||||
|
||||
/// Loop through the given `Reader`, printing until the `Reader` buffer
|
||||
/// is exhausted, or the optional `cancelled` bool is set to true.
|
||||
/// is exhausted.
|
||||
pub fn print_all<Reader: Read>(
|
||||
&mut self,
|
||||
mut reader: Reader,
|
||||
canceller: Option<Cancelled>,
|
||||
mut reader: Reader
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut buffer = [0; BUFFER_SIZE];
|
||||
'mainloop: loop {
|
||||
@@ -421,13 +416,6 @@ impl<'a, Writer: Write> Printer<'a, Writer> {
|
||||
break;
|
||||
}
|
||||
|
||||
if let Some(cancelled) = &canceller {
|
||||
if cancelled.load(Ordering::SeqCst) {
|
||||
eprintln!("hexyl has been cancelled.");
|
||||
std::process::exit(130); // Set exit code to 128 + SIGINT
|
||||
}
|
||||
}
|
||||
|
||||
for b in &buffer[..size] {
|
||||
let res = self.print_byte(*b);
|
||||
|
||||
|
||||
Reference in new issue
Block a user