Skip to content

Commit ccf5021

Browse files
committed
move preserve_selection to diplay config
Signed-off-by: Luterán Lajos <luteranlajos@protonmail.ch>
2 parents 1dfb019 + 59b6ae5 commit ccf5021

38 files changed

+880
-804
lines changed

Cargo.lock

Lines changed: 278 additions & 226 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/joshuto.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use_trash = true
66
watch_files = true
77
xdg_open = false
88
xdg_open_fork = false
9-
case_sensitive_ext = false
9+
case_insensitive_ext = false
1010

1111
custom_commands = []
1212

@@ -21,7 +21,7 @@ column_ratio = [1, 4, 4]
2121
scroll_offset = 6
2222
show_borders = true
2323
show_hidden = false
24-
show_icons = true
24+
show_icons = false
2525
# none, absolute, relative
2626
line_number_style = "none"
2727

docs/configuration/joshuto.toml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ xdg_open_fork = false
1818

1919
# If true, all file extensions checks will be case sensitive.
2020
# Applies to `[extension]` in `mimetype.toml` and `[ext]` in `theme.toml` and `icons.toml`
21-
case_sensitive_ext = false
21+
case_insensitive_ext = false
2222

2323
# Use system trash can instead of permanently removing files
2424
use_trash = true

src/commands/bulk_rename.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::process;
66

77
use rand::Rng;
88

9+
use crate::context::remove_external_preview;
910
use crate::context::AppContext;
1011
use crate::error::{AppError, AppErrorKind, AppResult};
1112
use crate::ui::AppBackend;
@@ -125,10 +126,10 @@ pub fn _bulk_rename(context: &mut AppContext) -> AppResult {
125126
}
126127

127128
pub fn bulk_rename(context: &mut AppContext, backend: &mut AppBackend) -> AppResult {
128-
context.remove_external_preview();
129+
remove_external_preview(context);
129130
backend.terminal_drop();
130131
let res = _bulk_rename(context);
131-
backend.terminal_restore(context.config_ref().mouse_support)?;
132+
backend.terminal_restore()?;
132133
reload::soft_reload_curr_tab(context)?;
133134
res
134135
}

src/commands/change_directory.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path;
33
use crate::commands::reload;
44
use crate::context::AppContext;
55
use crate::error::AppResult;
6-
use crate::history::DirectoryHistory;
6+
use crate::history::{generate_entries_to_root, DirectoryHistory};
77
use crate::util::cwd;
88

99
// ChangeDirectory command
@@ -28,25 +28,18 @@ pub fn change_directory(context: &mut AppContext, mut path: &path::Path) -> AppR
2828
};
2929

3030
cd(new_cwd.as_path(), context)?;
31-
let config = context.config_ref().clone();
32-
let options = context.config_ref().display_options_ref().clone();
33-
let ui_context = context.ui_context_ref().clone();
34-
let tab_options = context
35-
.tab_context_ref()
36-
.curr_tab_ref()
37-
.option_ref()
38-
.clone();
31+
let dirlists = generate_entries_to_root(
32+
new_cwd.as_path(),
33+
context.tab_context_ref().curr_tab_ref().history_ref(),
34+
context.ui_context_ref(),
35+
context.config_ref().display_options_ref(),
36+
context.tab_context_ref().curr_tab_ref().option_ref(),
37+
)?;
3938
context
4039
.tab_context_mut()
4140
.curr_tab_mut()
4241
.history_mut()
43-
.populate_to_root(
44-
new_cwd.as_path(),
45-
&config,
46-
&ui_context,
47-
&options,
48-
&tab_options,
49-
)?;
42+
.insert_entries(dirlists);
5043
Ok(())
5144
}
5245

src/commands/custom_search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn custom_search(
5757
.stdout(Stdio::piped())
5858
.spawn()?
5959
.wait_with_output()?;
60-
backend.terminal_restore(context.config_ref().mouse_support)?;
60+
backend.terminal_restore()?;
6161
cmd_result
6262
} else {
6363
cmd.output()?

src/commands/delete_files.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ use termion::event::Key;
55

66
use crate::context::AppContext;
77
use crate::error::{AppError, AppErrorKind, AppResult};
8-
use crate::history::DirectoryHistory;
98
use crate::io::{FileOperation, FileOperationOptions, IoWorkerThread};
109
use crate::ui::widgets::TuiPrompt;
1110
use crate::ui::AppBackend;
1211

12+
use super::tab_ops;
13+
1314
fn prompt(context: &mut AppContext, backend: &mut AppBackend, paths_len: usize) -> bool {
1415
let ch = {
1516
let prompt_str = format!("Delete {} files? (Y/n)", paths_len);
@@ -93,14 +94,7 @@ pub fn delete_selected_files(
9394
delete_files(context, paths, background, permanently)?;
9495
}
9596

96-
let curr_tab = context.tab_context_ref().curr_tab_ref();
97-
let config = context.config_ref().clone();
98-
let options = context.config_ref().display_options_ref().clone();
99-
let curr_path = curr_tab.cwd().to_path_buf();
100-
for (_, tab) in context.tab_context_mut().iter_mut() {
101-
let tab_options = tab.option_ref().clone();
102-
tab.history_mut()
103-
.reload(&curr_path, &config, &options, &tab_options)?;
104-
}
97+
let curr_path = context.tab_context_ref().curr_tab_ref().cwd().to_path_buf();
98+
tab_ops::reload_all_tabs(context, curr_path.as_path())?;
10599
Ok(())
106100
}

src/commands/fzf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn fzf_multi(
5151
}
5252

5353
fn fzf_impl(
54-
context: &mut AppContext,
54+
_context: &mut AppContext,
5555
backend: &mut AppBackend,
5656
items: Vec<String>,
5757
args: Vec<String>,
@@ -68,7 +68,7 @@ fn fzf_impl(
6868
let mut fzf = match cmd.spawn() {
6969
Ok(child) => child,
7070
Err(e) => {
71-
backend.terminal_restore(context.config_ref().mouse_support)?;
71+
backend.terminal_restore()?;
7272
return Err(AppError::from(e));
7373
}
7474
};
@@ -82,7 +82,7 @@ fn fzf_impl(
8282
}
8383

8484
let fzf_output = fzf.wait_with_output();
85-
backend.terminal_restore(context.config_ref().mouse_support)?;
85+
backend.terminal_restore()?;
8686

8787
if let Ok(output) = fzf_output {
8888
if output.status.success() {

src/commands/new_directory.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ use std::path;
33
use crate::commands::cursor_move;
44
use crate::context::AppContext;
55
use crate::error::AppResult;
6-
use crate::history::DirectoryHistory;
6+
7+
use super::tab_ops;
78

89
pub fn new_directory(context: &mut AppContext, p: &path::Path) -> AppResult {
910
std::fs::create_dir_all(p)?;
10-
let config = context.config_ref().clone();
11-
let options = context.config_ref().display_options_ref().clone();
11+
1212
let curr_path = context.tab_context_ref().curr_tab_ref().cwd().to_path_buf();
13-
for (_, tab) in context.tab_context_mut().iter_mut() {
14-
let tab_options = tab.option_ref().clone();
15-
tab.history_mut()
16-
.reload(&curr_path, &config, &options, &tab_options)?;
17-
}
13+
tab_ops::reload_all_tabs(context, curr_path.as_path())?;
1814

1915
if context.config_ref().focus_on_create {
2016
cursor_move::to_path(context, p)?;

src/commands/open_file.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ fn _get_options<'a>(path: &path::Path, config: &AppConfig) -> Vec<&'a ProgramEnt
2323
.extension()
2424
.and_then(|ext| ext.to_str())
2525
.and_then(|ext| {
26-
if config.case_sensitive_ext {
27-
MIMETYPE_T.app_list_for_ext(ext)
28-
} else {
26+
if config.case_insensitive_ext {
2927
MIMETYPE_T.app_list_for_ext(&ext.to_lowercase())
28+
} else {
29+
MIMETYPE_T.app_list_for_ext(ext)
3030
}
3131
})
3232
{
@@ -67,7 +67,7 @@ where
6767
} else {
6868
backend.terminal_drop();
6969
let res = execute_and_wait(option, files);
70-
backend.terminal_restore(context.config_ref().mouse_support)?;
70+
backend.terminal_restore()?;
7171
res?;
7272
}
7373
Ok(())
@@ -86,7 +86,7 @@ fn _open_with_xdg(
8686
backend.terminal_drop();
8787
let handle = open::that_in_background(path);
8888
let result = handle.join();
89-
backend.terminal_restore(context.config_ref().mouse_support)?;
89+
backend.terminal_restore()?;
9090
if let Ok(result) = result {
9191
result?;
9292
}
@@ -143,7 +143,7 @@ where
143143
let mut option = ProgramEntry::new(String::from(cmd));
144144
option.args(args_iter);
145145
let res = execute_and_wait(&option, files);
146-
backend.terminal_restore(context.config_ref().mouse_support)?;
146+
backend.terminal_restore()?;
147147
res?
148148
}
149149
}

0 commit comments

Comments
 (0)