1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![cfg_attr(
4 not(any(feature = "dynamic_output", feature = "static_output")),
5 allow(unused_imports),
6 allow(dead_code)
7)]
8#![deny(clippy::all)]
9#![warn(clippy::pedantic)]
10#![warn(clippy::nursery)]
11#![cfg_attr(doctest, doc = include_str!("../README.md"))]
12
13mod color;
18#[cfg(feature = "dynamic_output")]
19mod dynamic_pager;
20pub mod error;
21pub mod hooks;
22pub mod input;
23#[cfg(feature = "search")]
24mod layout;
25#[cfg(feature = "search")]
26mod line_navigation;
27#[cfg(feature = "search")]
28pub use layout::LayoutRenderer;
29mod highlight_styles;
30#[path = "core/mod.rs"]
31mod minus_core;
32mod pager;
33mod prompt;
34pub mod screen;
35#[cfg(feature = "search")]
36#[cfg_attr(docsrs, doc(cfg(feature = "search")))]
37pub mod search;
38mod selection;
39pub use highlight_styles::{HighlightColors, HighlightStyles};
40#[cfg(feature = "search")]
41mod toc;
42#[cfg(feature = "search")]
43pub use toc::TocEntry;
44pub mod state;
45#[cfg(feature = "static_output")]
46mod static_pager;
47
48#[cfg(feature = "dynamic_output")]
49pub use dynamic_pager::{dynamic_paging, dynamic_paging_in_place};
50#[cfg(feature = "static_output")]
51pub use static_pager::page_all;
52
53pub use minus_core::RunMode;
54#[cfg(feature = "search")]
55pub use search::SearchMode;
56
57pub use color::{ColorDepth, ansi256_to_rgb};
58pub use error::MinusError;
59#[cfg(feature = "search")]
60pub use line_navigation::{LineNavigation, SourceViewRenderer};
61pub use pager::Pager;
62pub use prompt::{
63 PromptAttribute, PromptColor, PromptContext, PromptError, PromptLine, PromptRenderer,
64 PromptSpan, PromptStyle,
65};
66pub use state::PagerState;
67
68pub type ExitCallbacks = Vec<Box<dyn FnMut() + Send + Sync + 'static>>;
70
71type Result<T = (), E = MinusError> = std::result::Result<T, E>;
72
73#[derive(PartialEq, Clone, Debug, Eq)]
75pub enum ExitStrategy {
76 ProcessQuit,
78 PagerQuit,
80}
81
82#[derive(Debug, PartialEq, Eq, Copy, Clone)]
84pub enum LineNumbers {
85 AlwaysOn,
87 Enabled,
89 Disabled,
91 AlwaysOff,
93}
94
95impl LineNumbers {
96 const EXTRA_PADDING: usize = 5;
97
98 #[cfg(test)]
99 const fn is_invertible(self) -> bool {
100 matches!(self, Self::Enabled | Self::Disabled)
101 }
102
103 const fn is_on(self) -> bool {
104 matches!(self, Self::Enabled | Self::AlwaysOn)
105 }
106}
107
108impl std::ops::Not for LineNumbers {
109 type Output = Self;
110
111 fn not(self) -> Self::Output {
112 use LineNumbers::{Disabled, Enabled};
113
114 match self {
115 Enabled => Disabled,
116 Disabled => Enabled,
117 ln => ln,
118 }
119 }
120}
121
122#[cfg(test)]
123mod tests;