mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
hack
This commit is contained in:
+14
-4
@@ -9,12 +9,12 @@ use unicode_width::UnicodeWidthStr;
|
|||||||
|
|
||||||
use stfu8::encode_u8;
|
use stfu8::encode_u8;
|
||||||
|
|
||||||
use std::io::{Write};
|
|
||||||
use chrono::{DateTime, Local, TimeZone, Utc};
|
use chrono::{DateTime, Local, TimeZone, Utc};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Stdout;
|
use std::io::Stdout;
|
||||||
|
use std::io::Write;
|
||||||
use std::iter::repeat_n;
|
use std::iter::repeat_n;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use thousands::Separable;
|
use thousands::Separable;
|
||||||
@@ -224,15 +224,25 @@ fn find_longest_dir_name(
|
|||||||
.fold(longest, max)
|
.fold(longest, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_node(node: &DisplayNode,
|
fn display_node(
|
||||||
|
node: &DisplayNode,
|
||||||
stdout: &mut RawTerminal<Stdout>,
|
stdout: &mut RawTerminal<Stdout>,
|
||||||
draw_data: &DrawData, is_biggest: bool, is_last: bool) {
|
draw_data: &DrawData,
|
||||||
|
is_biggest: bool,
|
||||||
|
is_last: bool,
|
||||||
|
) {
|
||||||
// hacky way of working out how deep we are in the tree
|
// hacky way of working out how deep we are in the tree
|
||||||
let indent = draw_data.get_new_indent(!node.children.is_empty(), is_last);
|
let indent = draw_data.get_new_indent(!node.children.is_empty(), is_last);
|
||||||
let level = ((indent.chars().count() - 1) / 2) - 1;
|
let level = ((indent.chars().count() - 1) / 2) - 1;
|
||||||
let bar_text = draw_data.generate_bar(node, level);
|
let bar_text = draw_data.generate_bar(node, level);
|
||||||
|
|
||||||
let to_print = format_string(node, &indent, &bar_text, is_biggest, &draw_data.display_data);
|
let to_print = format_string(
|
||||||
|
node,
|
||||||
|
&indent,
|
||||||
|
&bar_text,
|
||||||
|
is_biggest,
|
||||||
|
&draw_data.display_data,
|
||||||
|
);
|
||||||
|
|
||||||
if !draw_data.display_data.initial.is_reversed {
|
if !draw_data.display_data.initial.is_reversed {
|
||||||
write!(stdout, "{to_print}").unwrap()
|
write!(stdout, "{to_print}").unwrap()
|
||||||
|
|||||||
+22
-13
@@ -20,25 +20,25 @@ use display::InitialDisplayData;
|
|||||||
use filter::AggregateData;
|
use filter::AggregateData;
|
||||||
use progress::PIndicator;
|
use progress::PIndicator;
|
||||||
use regex::Error;
|
use regex::Error;
|
||||||
use termion::raw::RawTerminal;
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::io::Stdout;
|
||||||
use std::io::stdin;
|
use std::io::stdin;
|
||||||
use std::io::stdout;
|
use std::io::stdout;
|
||||||
use std::io::Stdout;
|
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::{System, SystemExt};
|
||||||
|
use termion::raw::RawTerminal;
|
||||||
use utils::canonicalize_absolute_path;
|
use utils::canonicalize_absolute_path;
|
||||||
|
|
||||||
use termion::event::{Key, Event};
|
use std::io::Write;
|
||||||
use termion::input::{TermRead};
|
use termion::event::{Event, Key};
|
||||||
|
use termion::input::TermRead;
|
||||||
use termion::raw::IntoRawMode;
|
use termion::raw::IntoRawMode;
|
||||||
use std::io::{Write};
|
|
||||||
|
|
||||||
use self::display::draw_it;
|
use self::display::draw_it;
|
||||||
use config::get_config;
|
use config::get_config;
|
||||||
@@ -321,7 +321,13 @@ fn main() {
|
|||||||
let stdin = stdin();
|
let stdin = stdin();
|
||||||
let mut out = stdout().into_raw_mode().unwrap();
|
let mut out = stdout().into_raw_mode().unwrap();
|
||||||
|
|
||||||
write!(out, "{}{}Dust interactive (q to quit)", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap();
|
write!(
|
||||||
|
out,
|
||||||
|
"{}{}Dust interactive (q to quit)",
|
||||||
|
termion::clear::All,
|
||||||
|
termion::cursor::Goto(1, 1)
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
write!(out, "{}", termion::cursor::Goto(1, 2)).unwrap();
|
write!(out, "{}", termion::cursor::Goto(1, 2)).unwrap();
|
||||||
print_output(
|
print_output(
|
||||||
&config,
|
&config,
|
||||||
@@ -334,20 +340,26 @@ fn main() {
|
|||||||
out.flush().unwrap();
|
out.flush().unwrap();
|
||||||
|
|
||||||
for c in stdin.events() {
|
for c in stdin.events() {
|
||||||
write!(out, "{}{}Dust interactive (q to quit)", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap();
|
write!(
|
||||||
|
out,
|
||||||
|
"{}{}Dust interactive (q to quit)",
|
||||||
|
termion::clear::All,
|
||||||
|
termion::cursor::Goto(1, 1)
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
write!(out, "{}", termion::cursor::Goto(1, 2)).unwrap();
|
write!(out, "{}", termion::cursor::Goto(1, 2)).unwrap();
|
||||||
let evt = c.unwrap();
|
let evt = c.unwrap();
|
||||||
match evt {
|
match evt {
|
||||||
Event::Key(Key::Char('q')) => break,
|
Event::Key(Key::Char('q')) => break,
|
||||||
Event::Key(Key::Char(x)) => {
|
Event::Key(Key::Char(x)) => {
|
||||||
// println!("{}key ", x);
|
// println!("{}key ", x);
|
||||||
},
|
}
|
||||||
Event::Key(Key::Left) => {
|
Event::Key(Key::Left) => {
|
||||||
// println!("left ");
|
// println!("left ");
|
||||||
}
|
}
|
||||||
Event::Key(Key::Right) => {
|
Event::Key(Key::Right) => {
|
||||||
// println!("right ");
|
// println!("right ");
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
print_output(
|
print_output(
|
||||||
@@ -359,10 +371,7 @@ fn main() {
|
|||||||
&mut out,
|
&mut out,
|
||||||
);
|
);
|
||||||
out.flush().unwrap();
|
out.flush().unwrap();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_output(
|
fn print_output(
|
||||||
@@ -371,7 +380,7 @@ fn print_output(
|
|||||||
tree: &DisplayNode,
|
tree: &DisplayNode,
|
||||||
is_colors: bool,
|
is_colors: bool,
|
||||||
terminal_width: usize,
|
terminal_width: usize,
|
||||||
stdout: &mut RawTerminal<Stdout>
|
stdout: &mut RawTerminal<Stdout>,
|
||||||
) {
|
) {
|
||||||
let output_format = config.get_output_format(&options);
|
let output_format = config.get_output_format(&options);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user