diff options
author | sharkdp <davidpeter@web.de> | 2020-04-22 22:54:33 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-04-22 23:55:28 +0200 |
commit | 8961f7aef8a24e35007b6e6d4eed5bdaa30763a9 (patch) | |
tree | 870e83ba40e3028a899d724a86d60d1077b45da5 | |
parent | 17f3a3b95da60b27fcd341b0a47a76aaa2784bc5 (diff) |
Move PagingMode to separate module
-rw-r--r-- | src/bin/bat/app.rs | 3 | ||||
-rw-r--r-- | src/config.rs | 17 | ||||
-rw-r--r-- | src/controller.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 4 | ||||
-rw-r--r-- | src/output.rs | 4 | ||||
-rw-r--r-- | src/paging.rs | 12 | ||||
-rw-r--r-- | src/pretty_printer.rs | 2 |
7 files changed, 24 insertions, 22 deletions
diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index f16e8fb6..abdefbd6 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -15,10 +15,11 @@ use console::Term; use bat::{ assets::HighlightingAssets, - config::{Config, PagingMode}, + config::Config, error::*, input::Input, line_range::{HighlightedLineRanges, LineRange, LineRanges}, + paging::PagingMode, style::{StyleComponent, StyleComponents}, MappingTarget, SyntaxMapping, WrappingMode, }; diff --git a/src/config.rs b/src/config.rs index f276176b..d5df9910 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,23 +1,10 @@ use crate::line_range::{HighlightedLineRanges, LineRanges}; +#[cfg(feature = "paging")] +use crate::paging::PagingMode; use crate::style::StyleComponents; use crate::syntax_mapping::SyntaxMapping; use crate::wrapping::WrappingMode; -#[derive(Debug, Clone, Copy, PartialEq)] -#[cfg(feature = "paging")] -pub enum PagingMode { - Always, - QuitIfOneScreen, - Never, -} - -#[cfg(feature = "paging")] -impl Default for PagingMode { - fn default() -> Self { - PagingMode::Never - } -} - #[derive(Debug, Clone, Default)] pub struct Config<'a> { /// The explicitly configured language, if any diff --git a/src/controller.rs b/src/controller.rs index c0d22e50..09c6ec2a 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -2,12 +2,12 @@ use std::io::{self, Write}; use crate::assets::HighlightingAssets; use crate::config::Config; -#[cfg(feature = "paging")] -use crate::config::PagingMode; use crate::error::*; use crate::input::{Input, InputReader, OpenedInput}; use crate::line_range::{LineRanges, RangeCheckResult}; use crate::output::OutputType; +#[cfg(feature = "paging")] +use crate::paging::PagingMode; use crate::printer::{InteractivePrinter, Printer, SimplePrinter}; pub struct Controller<'a> { @@ -29,6 +29,8 @@ pub mod input; mod less; pub mod line_range; mod output; +#[cfg(feature = "paging")] +pub mod paging; mod preprocessor; mod pretty_printer; pub(crate) mod printer; @@ -42,4 +44,4 @@ pub use syntax_mapping::{MappingTarget, SyntaxMapping}; pub use wrapping::WrappingMode; #[cfg(feature = "paging")] -pub use config::PagingMode; +pub use paging::PagingMode; diff --git a/src/output.rs b/src/output.rs index 8c1b111f..12f7a165 100644 --- a/src/output.rs +++ b/src/output.rs @@ -2,11 +2,11 @@ use std::io::{self, Write}; #[cfg(feature = "paging")] use std::process::Child; -#[cfg(feature = "paging")] -use crate::config::PagingMode; use crate::error::*; #[cfg(feature = "paging")] use crate::less::retrieve_less_version; +#[cfg(feature = "paging")] +use crate::paging::PagingMode; #[derive(Debug)] pub enum OutputType { diff --git a/src/paging.rs b/src/paging.rs new file mode 100644 index 00000000..77a183c2 --- /dev/null +++ b/src/paging.rs @@ -0,0 +1,12 @@ +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum PagingMode { + Always, + QuitIfOneScreen, + Never, +} + +impl Default for PagingMode { + fn default() -> Self { + PagingMode::Never + } +} diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index e9d566b7..0c78ea90 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -16,7 +16,7 @@ use crate::{ }; #[cfg(feature = "paging")] -use crate::config::PagingMode; +use crate::paging::PagingMode; #[derive(Default)] struct ActiveStyleComponents { |