diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-06 08:08:15 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-06 08:08:15 +0530 |
commit | 7bef5974e86de825dcb0b3507df16a80b6986d88 (patch) | |
tree | 965fa139b9b56d0adba0a21cf180741c01ea3bea /src/interactive/widgets | |
parent | 982446ad0ef9a475274c9a0f05a32147fcafd061 (diff) |
refactor
Diffstat (limited to 'src/interactive/widgets')
-rw-r--r-- | src/interactive/widgets/entries.rs | 16 | ||||
-rw-r--r-- | src/interactive/widgets/footer.rs | 10 | ||||
-rw-r--r-- | src/interactive/widgets/help.rs | 10 | ||||
-rw-r--r-- | src/interactive/widgets/main.rs | 27 |
4 files changed, 30 insertions, 33 deletions
diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs index 0fe0bf0..8a740e3 100644 --- a/src/interactive/widgets/entries.rs +++ b/src/interactive/widgets/entries.rs @@ -8,9 +8,9 @@ use tui::{ style::{Color, Style}, widgets::{Block, Borders, Text}, }; -use tui_react::{fill_background_to_right, ReactList, ReactListProps}; +use tui_react::{fill_background_to_right, List, ListProps}; -pub struct ReactEntriesProps<'a> { +pub struct EntriesProps<'a> { pub tree: &'a Tree, pub root: TreeIndex, pub display: DisplayOptions, @@ -21,18 +21,18 @@ pub struct ReactEntriesProps<'a> { } #[derive(Default)] -pub struct ReactEntries { - pub list: ReactList, +pub struct Entries { + pub list: List, } -impl ReactEntries { +impl Entries { pub fn render<'a>( &mut self, - props: impl Borrow<ReactEntriesProps<'a>>, + props: impl Borrow<EntriesProps<'a>>, area: Rect, buf: &mut Buffer, ) { - let ReactEntriesProps { + let EntriesProps { tree, root, display, @@ -70,7 +70,7 @@ impl ReactEntries { .unwrap_or(0) }); - let props = ReactListProps { + let props = ListProps { block: Some(block), entry_in_view, }; diff --git a/src/interactive/widgets/footer.rs b/src/interactive/widgets/footer.rs index 048ae69..d598abd 100644 --- a/src/interactive/widgets/footer.rs +++ b/src/interactive/widgets/footer.rs @@ -10,20 +10,20 @@ use tui::{ }; use tui_react::ToplevelComponent; -pub struct ReactFooter; +pub struct Footer; -pub struct ReactFooterProps { +pub struct FooterProps { pub total_bytes: Option<u64>, pub entries_traversed: u64, pub format: ByteFormat, pub message: Option<String>, } -impl ToplevelComponent for ReactFooter { - type Props = ReactFooterProps; +impl ToplevelComponent for Footer { + type Props = FooterProps; fn render(&mut self, props: impl Borrow<Self::Props>, area: Rect, buf: &mut Buffer) { - let ReactFooterProps { + let FooterProps { total_bytes, entries_traversed, format, diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs index 66fc500..aad6f93 100644 --- a/src/interactive/widgets/help.rs +++ b/src/interactive/widgets/help.rs @@ -10,16 +10,16 @@ use tui::{ use tui_react::ToplevelComponent; #[derive(Default, Clone)] -pub struct ReactHelpPane { +pub struct HelpPane { pub scroll: u16, } -pub struct ReactHelpPaneProps { +pub struct HelpPaneProps { pub border_style: Style, } -impl ToplevelComponent for ReactHelpPane { - type Props = ReactHelpPaneProps; +impl ToplevelComponent for HelpPane { + type Props = HelpPaneProps; fn render(&mut self, props: impl Borrow<Self::Props>, area: Rect, buf: &mut Buffer) { let (texts, num_lines) = { @@ -98,7 +98,7 @@ impl ToplevelComponent for ReactHelpPane { (lines.into_inner(), num_lines.get()) }; - let ReactHelpPaneProps { border_style } = props.borrow(); + let HelpPaneProps { border_style } = props.borrow(); let mut block = Block::default() .title("Help") diff --git a/src/interactive/widgets/main.rs b/src/interactive/widgets/main.rs index ddb28bc..ee4e7ef 100644 --- a/src/interactive/widgets/main.rs +++ b/src/interactive/widgets/main.rs @@ -1,8 +1,5 @@ use crate::interactive::{ - widgets::{ - Header, ReactEntries, ReactEntriesProps, ReactFooter, ReactFooterProps, ReactHelpPane, - ReactHelpPaneProps, - }, + widgets::{Entries, EntriesProps, Footer, FooterProps, Header, HelpPane, HelpPaneProps}, AppState, DisplayOptions, FocussedPane, }; use dua::traverse::Traversal; @@ -16,26 +13,26 @@ use tui::{ }; use tui_react::ToplevelComponent; -pub struct ReactMainWindowProps<'a> { +pub struct MainWindowProps<'a> { pub traversal: &'a Traversal, pub display: DisplayOptions, pub state: &'a AppState, } #[derive(Default)] -pub struct ReactMainWindow { - pub help_pane: Option<ReactHelpPane>, - pub entries_pane: ReactEntries, +pub struct MainWindow { + pub help_pane: Option<HelpPane>, + pub entries_pane: Entries, } -impl ReactMainWindow { +impl MainWindow { pub fn render<'a>( &mut self, - props: impl Borrow<ReactMainWindowProps<'a>>, + props: impl Borrow<MainWindowProps<'a>>, area: Rect, buf: &mut Buffer, ) { - let ReactMainWindowProps { + let MainWindowProps { traversal: Traversal { tree, @@ -83,7 +80,7 @@ impl ReactMainWindow { }; Header.draw(header_area, buf); - let props = ReactEntriesProps { + let props = EntriesProps { tree: &tree, root: state.root, display: *display, @@ -99,14 +96,14 @@ impl ReactMainWindow { self.entries_pane.render(props, entries_area, buf); if let Some((help_area, pane)) = help_pane { - let props = ReactHelpPaneProps { + let props = HelpPaneProps { border_style: help_style, }; pane.render(props, help_area, buf); } - ReactFooter.render( - ReactFooterProps { + Footer.render( + FooterProps { total_bytes: *total_bytes, entries_traversed: *entries_traversed, format: display.byte_format, |