summaryrefslogtreecommitdiffstats
path: root/src/commands/tab_switch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/tab_switch.rs')
-rw-r--r--src/commands/tab_switch.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/commands/tab_switch.rs b/src/commands/tab_switch.rs
index 7e782be..b0102b5 100644
--- a/src/commands/tab_switch.rs
+++ b/src/commands/tab_switch.rs
@@ -4,6 +4,7 @@ use crate::commands::{JoshutoCommand, JoshutoRunnable};
use crate::context::JoshutoContext;
use crate::preview;
use crate::ui;
+use crate::window::JoshutoView;
#[derive(Clone, Debug)]
pub struct TabSwitch {
@@ -18,7 +19,7 @@ impl TabSwitch {
"tab_switch"
}
- pub fn tab_switch(new_index: i32, context: &mut JoshutoContext) {
+ pub fn tab_switch(new_index: i32, context: &mut JoshutoContext, view: &JoshutoView) {
context.curr_tab_index = new_index as usize;
let path = &context.curr_tab_ref().curr_path;
match env::set_current_dir(path) {
@@ -27,17 +28,17 @@ impl TabSwitch {
let curr_tab = &mut context.tabs[context.curr_tab_index];
curr_tab.reload_contents(&context.config_t.sort_type);
curr_tab.refresh(
- &context.views,
+ view,
&context.config_t,
&context.username,
&context.hostname,
);
}
- ui::redraw_tab_view(&context.views.tab_win, &context);
+ ui::redraw_tab_view(&view.tab_win, &context);
let curr_tab = &mut context.tabs[context.curr_tab_index];
- preview::preview_file(curr_tab, &context.views, &context.config_t);
+ preview::preview_file(curr_tab, view, &context.config_t);
}
- Err(e) => ui::wprint_err(&context.views.left_win, e.to_string().as_str()),
+ Err(e) => ui::wprint_err(&view.left_win, e.to_string().as_str()),
}
}
}
@@ -51,7 +52,7 @@ impl std::fmt::Display for TabSwitch {
}
impl JoshutoRunnable for TabSwitch {
- fn execute(&self, context: &mut JoshutoContext) {
+ fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) {
let mut new_index = context.curr_tab_index as i32 + self.movement;
let tab_len = context.tabs.len() as i32;
while new_index < 0 {
@@ -60,7 +61,7 @@ impl JoshutoRunnable for TabSwitch {
while new_index >= tab_len {
new_index -= tab_len;
}
- Self::tab_switch(new_index, context);
+ Self::tab_switch(new_index, context, view);
ncurses::doupdate();
}
}