diff options
author | DLFW <daniel@llin.info> | 2022-10-20 17:17:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-20 11:17:02 -0400 |
commit | 7d89ec31a0028957bbbcb47cabc67d47523820dc (patch) | |
tree | ac9d1d3c770531d00caab2a6ccea612ce78ff01e /src/commands | |
parent | e59ed84f5ac3ba864b6c0d2bcdb6a014d2d46e73 (diff) |
Add linemode feature and first simple linemodes (#206)
This adds the basic ability to change the representation of files in the
TUI detailed dir list by letting the user choose a certain "linemode".
As of now, there are only three simple linemodes, all showing the
filename on the left side and a preceding symlink indicator in the
beginning of the right label as usual.
The "size" linemode shows the right label as it has been up to now.
The "mtime" linemode shows the mtime of the file or directory.
The "sizemtime" linemodes combines both meta-data.
The user can change the linemode like so:
```
:linemode [size|mtime|sizemtime]
```
Default keybindings have been added:
``ms`` for *size*, ``mm`` for *mtime*, and ``mM`` for *sizemtime*.
The selected linemode is specific for each tab.
A new tab always starts with the *size* linemode.
Possible enhancements:
* Move the code for factoring a label out of the
``tui_dirlist_detailed`` module to some UI-independent module
* Add a configuration option for the default linemode for new tabs
* Add further simple linemodes
* Generic support for linemodes with only one “full line label”
* Add support for custom linemodes where a label is constructed by an
external script
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/linemode.rs | 13 | ||||
-rw-r--r-- | src/commands/mod.rs | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/commands/linemode.rs b/src/commands/linemode.rs new file mode 100644 index 0000000..82668f6 --- /dev/null +++ b/src/commands/linemode.rs @@ -0,0 +1,13 @@ +use super::reload; +use crate::config::option::LineMode; +use crate::context::AppContext; +use crate::error::JoshutoResult; +use crate::history::DirectoryHistory; + +pub fn set_linemode(context: &mut AppContext, linemode: LineMode) -> JoshutoResult { + let curr_tab = context.tab_context_mut().curr_tab_mut(); + curr_tab.option_mut().linemode = linemode; + curr_tab.history_mut().depreciate_all_entries(); + reload::soft_reload_curr_tab(context)?; + Ok(()) +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index c4f7531..cf7ef53 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -8,6 +8,7 @@ pub mod file_ops; pub mod filter; pub mod flat; pub mod line_nums; +pub mod linemode; pub mod new_directory; pub mod numbered_command; pub mod open_file; |