@@ -10,6 +10,15 @@ use crate::paging::PagingMode;
1010#[cfg(feature = "paging")]
1111use crate::wrapping::WrappingMode;
1212
13+
14+#[cfg(feature = "paging")]
15+#[derive(Debug)]
16+enum SingleScreenAction {
17+ Quit,
18+ Nothing,
19+}
20+
21+
1322#[derive(Debug)]
1423pub enum OutputType {
1524 #[cfg(feature = "paging")]
@@ -21,10 +30,9 @@ impl OutputType {
2130 #[cfg(feature = "paging")]
2231 pub fn from_mode(paging_mode: PagingMode, wrapping_mode: WrappingMode, pager: Option<&str>) -> Result<Self> {
2332 use self::PagingMode::*;
24− use self::WrappingMode::*;
2533 Ok(match paging_mode {
26− Always => OutputType::try_pager(false, wrapping_mode == Character, pager)?,
27− QuitIfOneScreen => OutputType::try_pager(true, wrapping_mode == Character, pager)?,
34+ Always => OutputType::try_pager(SingleScreenAction::Nothing, wrapping_mode, pager)?,
35+ QuitIfOneScreen => OutputType::try_pager(SingleScreenAction::Quit, wrapping_mode, pager)?,
2836 _ => OutputType::stdout(),
2937 })
3038 }
@@ -32,8 +40,8 @@ impl OutputType {
3240 /// Try to launch the pager. Fall back to stdout in case of errors.
3341 #[cfg(feature = "paging")]
3442 fn try_pager(
35− quit_if_one_screen: bool,
36− line_wrap: bool,
43+ single_screen_action: SingleScreenAction,
44+ wrapping_mode: WrappingMode,
3745 pager_from_config: Option<&str>
3846 ) -> Result<Self> {
3947 use std::env;
@@ -85,12 +93,12 @@ impl OutputType {
8593 let mut p = Command::new(&pager_path);
8694 if args.is_empty() || replace_arguments_to_less {
8795 p.arg("--RAW-CONTROL-CHARS");
88− if quit_if_one_screen {
96+ if let SingleScreenAction::Quit = single_screen_action {
8997 p.arg("--quit-if-one-screen");
9098 }
9199
92− if !line_wrap {
93− p.arg("-S");
100+ if let WrappingMode::NoWrapping = wrapping_mode {
101+ p.arg("--chop-long-lines");
94102 }
95103
96104 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older