summaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/tui_worker.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2020-12-13 12:42:53 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2020-12-13 12:42:53 -0500
commit2e5cdd07c2d8c18bad4099c82e36af64dc473a64 (patch)
treea9d7dee0f5a603cc96d6415a4549436a0f1818e0 /src/ui/widgets/tui_worker.rs
parent468e607c5d1cd5d554ae356fd3c8e78425840347 (diff)
code cleanup and fix path not showing when too long
Diffstat (limited to 'src/ui/widgets/tui_worker.rs')
-rw-r--r--src/ui/widgets/tui_worker.rs62
1 files changed, 27 insertions, 35 deletions
diff --git a/src/ui/widgets/tui_worker.rs b/src/ui/widgets/tui_worker.rs
index 8707e5d..68abee0 100644
--- a/src/ui/widgets/tui_worker.rs
+++ b/src/ui/widgets/tui_worker.rs
@@ -1,7 +1,6 @@
use tui::buffer::Buffer;
use tui::layout::Rect;
use tui::style::{Color, Modifier, Style};
-use tui::text::Span;
use tui::widgets::{Paragraph, Widget, Wrap};
use crate::context::JoshutoContext;
@@ -34,53 +33,46 @@ impl<'a> Widget for TuiWorker<'a> {
TuiTopBar::new(curr_tab.pwd()).render(rect, buf);
match self.context.worker_ref() {
- Some(io_obs) => match io_obs.progress.as_ref() {
- Some(progress) => {
- let msg = match progress.kind() {
- FileOp::Copy => format!(
- "Copying ({}/{}) {:?} -> {:?}",
- progress.index() + 1,
- progress.len(),
- io_obs.src_path(),
- io_obs.dest_path()
- ),
- FileOp::Cut => format!(
- "Moving ({}/{}) {:?} -> {:?}",
- progress.index() + 1,
- progress.len(),
- io_obs.src_path(),
- io_obs.dest_path()
- ),
+ Some(io_obs) => {
+ if let Some(progress) = io_obs.progress.as_ref() {
+ let op_str = match progress.kind() {
+ FileOp::Copy => "Copying",
+ FileOp::Cut => "Moving",
};
+ let msg = format!(
+ "{} ({}/{}) {:?} -> {:?}",
+ op_str,
+ progress.index() + 1,
+ progress.len(),
+ io_obs.src_path(),
+ io_obs.dest_path()
+ );
let style = Style::default();
buf.set_stringn(0, 2, msg, area.width as usize, style);
+
let style = Style::default()
.fg(Color::Yellow)
.add_modifier(Modifier::BOLD);
buf.set_stringn(0, 4, "Queue:", area.width as usize, style);
+
let style = Style::default();
for (i, worker) in self.context.worker_iter().enumerate() {
- let msg = match worker.kind() {
- FileOp::Copy => format!(
- "{:02} Copy {} items {:?} -> {:?}",
- i + 1,
- worker.paths.len(),
- worker.paths[0].parent().unwrap(),
- worker.dest
- ),
- FileOp::Cut => format!(
- "{:02} Moving {} items {:?} -> {:?}",
- i + 1,
- worker.paths.len(),
- worker.paths[0].parent().unwrap(),
- worker.dest
- ),
+ let op_str = match worker.kind() {
+ FileOp::Copy => "Copy",
+ FileOp::Cut => "Cut",
};
+ let msg = format!(
+ "{:02} {} {} items {:?} -> {:?}",
+ i + 1,
+ op_str,
+ worker.paths.len(),
+ worker.paths[0].parent().unwrap(),
+ worker.dest
+ );
buf.set_stringn(0, (4 + i + 2) as u16, msg, area.width as usize, style);
}
}
- _ => {}
- },
+ }
_ => {
let style = Style::default();
buf.set_stringn(0, 2, "No operations running", area.width as usize, style);