diff options
author | Kamiyaa <jeff.no.zhao@gmail.com> | 2020-06-06 15:00:15 -0400 |
---|---|---|
committer | Kamiyaa <jeff.no.zhao@gmail.com> | 2020-06-06 15:00:15 -0400 |
commit | 4f3842b56f1729dcd8e81c77f98253ed9dfb23b3 (patch) | |
tree | a9cb1b5c300fcbdbcdfad34f0076919e30f03c88 /src/ui | |
parent | a462ebe2140323a6085ce5a064727288fa4dff3c (diff) |
shell command now parses correctly
- rework file operations
- simpler model for listening on io_worker progress
- cargo fmt/clippy
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 42 | ||||
-rw-r--r-- | src/ui/widgets/tui_footer.rs | 9 | ||||
-rw-r--r-- | src/ui/widgets/tui_menu.rs | 5 | ||||
-rw-r--r-- | src/ui/widgets/tui_textfield.rs | 2 | ||||
-rw-r--r-- | src/ui/widgets/tui_view.rs | 4 |
5 files changed, 22 insertions, 40 deletions
diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index d4c7db1..8f75317 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -68,33 +68,25 @@ impl<'a> Widget for TuiDirList<'a> { buf.set_stringn(x, y + i as u16, name, area_width - 1, style); buf.set_string(x + area_width as u16 - 1, y + i as u16, "…", style); } + } else if name_width < area_width { + buf.set_stringn(x, y + i as u16, name, area_width, style); } else { - if name_width < area_width { - buf.set_stringn(x, y + i as u16, name, area_width, style); - } else { - match name.rfind('.') { - None => { - buf.set_stringn(x, y + i as u16, name, area_width, style); - } - Some(p_ind) => { - let ext_width = name[p_ind..].width(); - let file_name_width = area_width - ext_width - 1; + match name.rfind('.') { + None => { + buf.set_stringn(x, y + i as u16, name, area_width, style); + } + Some(p_ind) => { + let ext_width = name[p_ind..].width(); + let file_name_width = area_width - ext_width - 1; - buf.set_stringn( - x, - y + i as u16, - &name[..p_ind], - file_name_width, - style, - ); - buf.set_string(x + file_name_width as u16, y + i as u16, "…", style); - buf.set_string( - x + file_name_width as u16 + 1, - y + i as u16, - &name[p_ind..], - style, - ); - } + buf.set_stringn(x, y + i as u16, &name[..p_ind], file_name_width, style); + buf.set_string(x + file_name_width as u16, y + i as u16, "…", style); + buf.set_string( + x + file_name_width as u16 + 1, + y + i as u16, + &name[p_ind..], + style, + ); } } } diff --git a/src/ui/widgets/tui_footer.rs b/src/ui/widgets/tui_footer.rs index 6cb8a70..e8297ed 100644 --- a/src/ui/widgets/tui_footer.rs +++ b/src/ui/widgets/tui_footer.rs @@ -49,12 +49,9 @@ impl<'a> Widget for TuiFooter<'a> { Text::raw(mimetype), ]; - match &self.entry.metadata.file_type { - FileType::Symlink(s) => { - text.push(Text::styled(" -> ", mode_style)); - text.push(Text::styled(s, mode_style)); - } - _ => {} + if let FileType::Symlink(s) = &self.entry.metadata.file_type { + text.push(Text::styled(" -> ", mode_style)); + text.push(Text::styled(s, mode_style)); } Paragraph::new(text.iter()).wrap(true).render(area, buf); diff --git a/src/ui/widgets/tui_menu.rs b/src/ui/widgets/tui_menu.rs index cc9a700..36de8ac 100644 --- a/src/ui/widgets/tui_menu.rs +++ b/src/ui/widgets/tui_menu.rs @@ -4,7 +4,7 @@ use termion::event::Key; use tui::buffer::Buffer; use tui::layout::Rect; use tui::style::Style; -use tui::widgets::{Block, Borders, Widget}; +use tui::widgets::Widget; use unicode_width::UnicodeWidthStr; use super::TuiView; @@ -119,10 +119,7 @@ const LONG_SPACE: &str = " impl<'a> Widget for TuiMenu<'a> { fn render(self, area: Rect, buf: &mut Buffer) { let text_iter = self.options.iter(); - let block = Block::default().borders(Borders::TOP).render(area, buf); - let style = Style::default(); - let area_x = area.x + 1; let area_y = area.y + 1; diff --git a/src/ui/widgets/tui_textfield.rs b/src/ui/widgets/tui_textfield.rs index 7d454fc..a57da5d 100644 --- a/src/ui/widgets/tui_textfield.rs +++ b/src/ui/widgets/tui_textfield.rs @@ -116,7 +116,7 @@ impl<'a> TuiTextField<'a> { let prefix = &line_buffer.as_str()[..cursor_xpos]; - let curr = line_buffer.as_str()[cursor_xpos..].chars().nth(0); + let curr = line_buffer.as_str()[cursor_xpos..].chars().next(); let (suffix, curr) = match curr { Some(c) => { let curr_len = c.len_utf8(); diff --git a/src/ui/widgets/tui_view.rs b/src/ui/widgets/tui_view.rs index 481bcc6..54bfe58 100644 --- a/src/ui/widgets/tui_view.rs +++ b/src/ui/widgets/tui_view.rs @@ -109,10 +109,6 @@ impl<'a> Widget for TuiView<'a> { let text = [Text::styled(&self.context.message_queue[0], message_style)]; Paragraph::new(text.iter()).wrap(true).render(rect, buf); - } else if let Some(msg) = self.context.worker_msg.as_ref() { - let text = [Text::styled(msg, message_style)]; - - Paragraph::new(text.iter()).wrap(true).render(rect, buf); } else if let Some(entry) = curr_list.get_curr_ref() { TuiFooter::new(entry).render(rect, buf); } |