@@ -7,6 +7,8 @@ use crate::error::*;
7use crate::less::retrieve_less_version;
7use crate::less::retrieve_less_version;
8#[cfg(feature = "paging")]
8#[cfg(feature = "paging")]
9use crate::paging::PagingMode;
9use crate::paging::PagingMode;
10+#[cfg(feature = "paging")]
11+use crate::wrapping::WrappingMode;
11#[derive(Debug)]
13#[derive(Debug)]
12pub enum OutputType {
14pub enum OutputType {
@@ -17,18 +19,23 @@ pub enum OutputType {
18impl OutputType {
20impl OutputType {
19 #[cfg(feature = "paging")]
21 #[cfg(feature = "paging")]
20− pub fn from_mode(mode: PagingMode, pager: Option<&str>) -> Result<Self> {
22+ pub fn from_mode(paging_mode: PagingMode, wrapping_mode: WrappingMode, pager: Option<&str>) -> Result<Self> {
21 use self::PagingMode::*;
23 use self::PagingMode::*;
24+ use self::WrappingMode::*;
22− Ok(match mode {
25+ Ok(match paging_mode {
23− Always => OutputType::try_pager(false, pager)?,
26+ Always => OutputType::try_pager(false, wrapping_mode == Character, pager)?,
24− QuitIfOneScreen => OutputType::try_pager(true, pager)?,
27+ QuitIfOneScreen => OutputType::try_pager(true, wrapping_mode == Character, pager)?,
25 _ => OutputType::stdout(),
28 _ => OutputType::stdout(),
29 /// Try to launch the pager. Fall back to stdout in case of errors.
32 /// Try to launch the pager. Fall back to stdout in case of errors.
30 #[cfg(feature = "paging")]
33 #[cfg(feature = "paging")]
35+ quit_if_one_screen: bool,
31− fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> {
37+ pager_from_config: Option<&str>
32 use std::env;
39 use std::env;
33 use std::ffi::OsString;
40 use std::ffi::OsString;
34 use std::path::PathBuf;
41 use std::path::PathBuf;
@@ -82,6 +89,10 @@ impl OutputType {
82 p.arg("--quit-if-one-screen");
89 p.arg("--quit-if-one-screen");
85 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
96 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
86 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
97 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.