mirror of
https://github.com/bootandy/dust.git
synced 2025-12-12 15:49:58 -08:00
hack
This commit is contained in:
@@ -9,12 +9,12 @@ use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use stfu8::encode_u8;
|
||||
|
||||
use std::io::{Write};
|
||||
use chrono::{DateTime, Local, TimeZone, Utc};
|
||||
use std::cmp::max;
|
||||
use std::cmp::min;
|
||||
use std::fs;
|
||||
use std::io::Stdout;
|
||||
use std::io::Write;
|
||||
use std::iter::repeat_n;
|
||||
use std::path::Path;
|
||||
use thousands::Separable;
|
||||
@@ -224,15 +224,25 @@ fn find_longest_dir_name(
|
||||
.fold(longest, max)
|
||||
}
|
||||
|
||||
fn display_node(node: &DisplayNode,
|
||||
fn display_node(
|
||||
node: &DisplayNode,
|
||||
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
|
||||
let indent = draw_data.get_new_indent(!node.children.is_empty(), is_last);
|
||||
let level = ((indent.chars().count() - 1) / 2) - 1;
|
||||
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 {
|
||||
write!(stdout, "{to_print}").unwrap()
|
||||
@@ -241,7 +251,7 @@ fn display_node(node: &DisplayNode,
|
||||
let dd = DrawData {
|
||||
indent: clean_indentation_string(&indent),
|
||||
percent_bar: bar_text,
|
||||
display_data:draw_data.display_data,
|
||||
display_data: draw_data.display_data,
|
||||
};
|
||||
|
||||
let num_siblings = node.num_siblings();
|
||||
@@ -252,7 +262,7 @@ fn display_node(node: &DisplayNode,
|
||||
{
|
||||
let is_biggest = dd.display_data.is_biggest(count, num_siblings);
|
||||
let was_i_last = dd.display_data.is_last(count, num_siblings);
|
||||
display_node( c, stdout, &dd, is_biggest, was_i_last);
|
||||
display_node(c, stdout, &dd, is_biggest, was_i_last);
|
||||
}
|
||||
|
||||
if draw_data.display_data.initial.is_reversed {
|
||||
|
||||
59
src/main.rs
59
src/main.rs
@@ -20,25 +20,25 @@ use display::InitialDisplayData;
|
||||
use filter::AggregateData;
|
||||
use progress::PIndicator;
|
||||
use regex::Error;
|
||||
use termion::raw::RawTerminal;
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
use std::fs::read_to_string;
|
||||
use std::io;
|
||||
use std::io::Stdout;
|
||||
use std::io::stdin;
|
||||
use std::io::stdout;
|
||||
use std::io::Stdout;
|
||||
use std::panic;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use sysinfo::{System, SystemExt};
|
||||
use termion::raw::RawTerminal;
|
||||
use utils::canonicalize_absolute_path;
|
||||
|
||||
use termion::event::{Key, Event};
|
||||
use termion::input::{TermRead};
|
||||
use std::io::Write;
|
||||
use termion::event::{Event, Key};
|
||||
use termion::input::TermRead;
|
||||
use termion::raw::IntoRawMode;
|
||||
use std::io::{Write};
|
||||
|
||||
use self::display::draw_it;
|
||||
use config::get_config;
|
||||
@@ -321,33 +321,45 @@ fn main() {
|
||||
let stdin = stdin();
|
||||
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, "{}", termion::cursor::Goto(1, 2)).unwrap();
|
||||
print_output(
|
||||
&config,
|
||||
&options,
|
||||
&tree,
|
||||
is_colors,
|
||||
terminal_width,
|
||||
&mut out,
|
||||
);
|
||||
out.flush().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();
|
||||
print_output(
|
||||
&config,
|
||||
&options,
|
||||
&tree,
|
||||
is_colors,
|
||||
terminal_width,
|
||||
&mut out,
|
||||
);
|
||||
out.flush().unwrap();
|
||||
|
||||
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();
|
||||
let evt = c.unwrap();
|
||||
match evt {
|
||||
Event::Key(Key::Char('q')) => break,
|
||||
Event::Key(Key::Char(x)) => {
|
||||
// println!("{}key ", x);
|
||||
},
|
||||
Event::Key(Key::Left) =>{
|
||||
}
|
||||
Event::Key(Key::Left) => {
|
||||
// println!("left ");
|
||||
}
|
||||
Event::Key(Key::Right) =>{
|
||||
Event::Key(Key::Right) => {
|
||||
// println!("right ");
|
||||
},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
print_output(
|
||||
@@ -359,10 +371,7 @@ fn main() {
|
||||
&mut out,
|
||||
);
|
||||
out.flush().unwrap();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn print_output(
|
||||
@@ -371,7 +380,7 @@ fn print_output(
|
||||
tree: &DisplayNode,
|
||||
is_colors: bool,
|
||||
terminal_width: usize,
|
||||
stdout: &mut RawTerminal<Stdout>
|
||||
stdout: &mut RawTerminal<Stdout>,
|
||||
) {
|
||||
let output_format = config.get_output_format(&options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user