Move PagingMode to separate module

This commit is contained in:
sharkdp 2020-04-22 22:54:33 +02:00 committed by David Peter
parent 17f3a3b95d
commit 8961f7aef8
7 changed files with 24 additions and 22 deletions

View file

@ -15,10 +15,11 @@ use console::Term;
use bat::{ use bat::{
assets::HighlightingAssets, assets::HighlightingAssets,
config::{Config, PagingMode}, config::Config,
error::*, error::*,
input::Input, input::Input,
line_range::{HighlightedLineRanges, LineRange, LineRanges}, line_range::{HighlightedLineRanges, LineRange, LineRanges},
paging::PagingMode,
style::{StyleComponent, StyleComponents}, style::{StyleComponent, StyleComponents},
MappingTarget, SyntaxMapping, WrappingMode, MappingTarget, SyntaxMapping, WrappingMode,
}; };

View file

@ -1,23 +1,10 @@
use crate::line_range::{HighlightedLineRanges, LineRanges}; use crate::line_range::{HighlightedLineRanges, LineRanges};
#[cfg(feature = "paging")]
use crate::paging::PagingMode;
use crate::style::StyleComponents; use crate::style::StyleComponents;
use crate::syntax_mapping::SyntaxMapping; use crate::syntax_mapping::SyntaxMapping;
use crate::wrapping::WrappingMode; 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)] #[derive(Debug, Clone, Default)]
pub struct Config<'a> { pub struct Config<'a> {
/// The explicitly configured language, if any /// The explicitly configured language, if any

View file

@ -2,12 +2,12 @@ use std::io::{self, Write};
use crate::assets::HighlightingAssets; use crate::assets::HighlightingAssets;
use crate::config::Config; use crate::config::Config;
#[cfg(feature = "paging")]
use crate::config::PagingMode;
use crate::error::*; use crate::error::*;
use crate::input::{Input, InputReader, OpenedInput}; use crate::input::{Input, InputReader, OpenedInput};
use crate::line_range::{LineRanges, RangeCheckResult}; use crate::line_range::{LineRanges, RangeCheckResult};
use crate::output::OutputType; use crate::output::OutputType;
#[cfg(feature = "paging")]
use crate::paging::PagingMode;
use crate::printer::{InteractivePrinter, Printer, SimplePrinter}; use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
pub struct Controller<'a> { pub struct Controller<'a> {

View file

@ -29,6 +29,8 @@ pub mod input;
mod less; mod less;
pub mod line_range; pub mod line_range;
mod output; mod output;
#[cfg(feature = "paging")]
pub mod paging;
mod preprocessor; mod preprocessor;
mod pretty_printer; mod pretty_printer;
pub(crate) mod printer; pub(crate) mod printer;
@ -42,4 +44,4 @@ pub use syntax_mapping::{MappingTarget, SyntaxMapping};
pub use wrapping::WrappingMode; pub use wrapping::WrappingMode;
#[cfg(feature = "paging")] #[cfg(feature = "paging")]
pub use config::PagingMode; pub use paging::PagingMode;

View file

@ -2,11 +2,11 @@ use std::io::{self, Write};
#[cfg(feature = "paging")] #[cfg(feature = "paging")]
use std::process::Child; use std::process::Child;
#[cfg(feature = "paging")]
use crate::config::PagingMode;
use crate::error::*; use crate::error::*;
#[cfg(feature = "paging")] #[cfg(feature = "paging")]
use crate::less::retrieve_less_version; use crate::less::retrieve_less_version;
#[cfg(feature = "paging")]
use crate::paging::PagingMode;
#[derive(Debug)] #[derive(Debug)]
pub enum OutputType { pub enum OutputType {

12
src/paging.rs Normal file
View file

@ -0,0 +1,12 @@
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PagingMode {
Always,
QuitIfOneScreen,
Never,
}
impl Default for PagingMode {
fn default() -> Self {
PagingMode::Never
}
}

View file

@ -16,7 +16,7 @@ use crate::{
}; };
#[cfg(feature = "paging")] #[cfg(feature = "paging")]
use crate::config::PagingMode; use crate::paging::PagingMode;
#[derive(Default)] #[derive(Default)]
struct ActiveStyleComponents { struct ActiveStyleComponents {