summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrusty <rusty@spoqa.com>2021-06-08 19:20:45 +0900
committerrusty <rusty@spoqa.com>2021-06-08 19:20:45 +0900
commitfd3e2c35d80aa906aac0a4b36b4450e888b73647 (patch)
treedc9d490ce83147f382301aee986ace5662489f5a
parentfb1d16ef44600c3cef496cb9e9c6ad61381f6192 (diff)
Add pager option
-rw-r--r--src/cli.rs11
-rw-r--r--src/config.rs2
-rw-r--r--src/main.rs2
-rw-r--r--src/options/set.rs1
4 files changed, 13 insertions, 3 deletions
diff --git a/src/cli.rs b/src/cli.rs
index d9873d3c..72e91b5a 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -532,9 +532,14 @@ pub struct Opt {
#[structopt(long = "inspect-raw-lines", default_value = "true")]
pub inspect_raw_lines: String,
- /// Whether to use a pager when displaying output. Options are: auto, always, and never. The
- /// default pager is `less`: this can be altered by setting the environment variables
- /// DELTA_PAGER, BAT_PAGER, or PAGER (and that is their order of priority).
+ #[structopt(long)]
+ /// Which pager to use. The default pager is `less`. You can also change pager
+ /// by setting the environment variables DELTA_PAGER, BAT_PAGER, or PAGER
+ /// (and that is their order of priority). This option overrides all environment
+ /// variables above.
+ pub pager: Option<String>,
+
+ /// Whether to use a pager when displaying output. Options are: auto, always, and never.
#[structopt(long = "paging", default_value = "auto")]
pub paging_mode: String,
diff --git a/src/config.rs b/src/config.rs
index 0b8ab6d1..573a08ed 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -66,6 +66,7 @@ pub struct Config {
pub navigate_regexp: Option<String>,
pub null_style: Style,
pub null_syntect_style: SyntectStyle,
+ pub pager: Option<String>,
pub paging_mode: PagingMode,
pub plus_emph_style: Style,
pub plus_empty_line_marker_style: Style,
@@ -246,6 +247,7 @@ impl From<cli::Opt> for Config {
navigate_regexp,
null_style: Style::new(),
null_syntect_style: SyntectStyle::default(),
+ pager: opt.pager,
paging_mode: opt.computed.paging_mode,
plus_emph_style,
plus_empty_line_marker_style,
diff --git a/src/main.rs b/src/main.rs
index cbeb0bcf..6cd878f4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -246,6 +246,7 @@ fn show_config(config: &config::Config, writer: &mut dyn Write) -> std::io::Resu
max-line-length = {max_line_length}
navigate = {navigate}
navigate-regexp = {navigate_regexp}
+ pager = {pager}
paging = {paging_mode}
side-by-side = {side_by_side}
syntax-theme = {syntax_theme}
@@ -259,6 +260,7 @@ fn show_config(config: &config::Config, writer: &mut dyn Write) -> std::io::Resu
None => "".to_string(),
Some(s) => s.to_string(),
},
+ pager = config.pager.clone().unwrap_or_else(|| "none".to_string()),
paging_mode = match config.paging_mode {
PagingMode::Always => "always",
PagingMode::Never => "never",
diff --git a/src/options/set.rs b/src/options/set.rs
index a737fd4b..ef0a259c 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -165,6 +165,7 @@ pub fn set_options(
line_numbers_right_format,
line_numbers_right_style,
line_numbers_zero_style,
+ pager,
paging_mode,
// Hack: plus-style must come before plus-*emph-style because the latter default
// dynamically to the value of the former.