summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorCatherine Noll <noll.catherine@gmail.com>2021-03-21 11:45:54 -0500
committerCatherine Noll <noll.catherine@gmail.com>2021-03-21 11:45:54 -0500
commit3572ec451f78270fc5aa8348e6ac716a32ab366c (patch)
tree79aa714c552508e83ddeaadf17ca4c52ef3ac413 /src/config.rs
parent43f971512594d931b97a61313612601ea5af6d0c (diff)
Navigate from theme to theme with n/N when --show-themes
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/config.rs b/src/config.rs
index 23b7b97d..eaa295ea 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -13,6 +13,7 @@ use crate::cli;
use crate::color;
use crate::delta::State;
use crate::env;
+use crate::features::navigate;
use crate::features::side_by_side;
use crate::git_config::GitConfigEntry;
use crate::style::{self, Style};
@@ -58,6 +59,7 @@ pub struct Config {
pub minus_non_emph_style: Style,
pub minus_style: Style,
pub navigate: bool,
+ pub navigate_regexp: Option<String>,
pub null_style: Style,
pub null_syntect_style: SyntectStyle,
pub paging_mode: PagingMode,
@@ -154,6 +156,24 @@ impl From<cli::Opt> for Config {
_ => *style::GIT_DEFAULT_PLUS_STYLE,
};
+ let file_added_label = opt.file_added_label;
+ let file_copied_label = opt.file_copied_label;
+ let file_modified_label = opt.file_modified_label;
+ let file_removed_label = opt.file_removed_label;
+ let file_renamed_label = opt.file_renamed_label;
+
+ let navigate_regexp = if opt.navigate || opt.show_themes {
+ Some(navigate::make_navigate_regexp(
+ opt.show_themes,
+ &file_modified_label,
+ &file_added_label,
+ &file_removed_label,
+ &file_renamed_label,
+ ))
+ } else {
+ None
+ };
+
Self {
available_terminal_width: opt.computed.available_terminal_width,
background_color_extends_to_terminal_width: opt
@@ -163,11 +183,11 @@ impl From<cli::Opt> for Config {
color_only: opt.color_only,
decorations_width: opt.computed.decorations_width,
error_exit_code: 2, // Use 2 for error because diff uses 0 and 1 for non-error.
- file_added_label: opt.file_added_label,
- file_copied_label: opt.file_copied_label,
- file_modified_label: opt.file_modified_label,
- file_removed_label: opt.file_removed_label,
- file_renamed_label: opt.file_renamed_label,
+ file_added_label,
+ file_copied_label,
+ file_modified_label,
+ file_removed_label,
+ file_renamed_label,
file_style,
git_config_entries: opt.git_config_entries,
hunk_header_file_style,
@@ -203,6 +223,7 @@ impl From<cli::Opt> for Config {
minus_non_emph_style,
minus_style,
navigate: opt.navigate,
+ navigate_regexp,
null_style: Style::new(),
null_syntect_style: SyntectStyle::default(),
paging_mode: opt.computed.paging_mode,