1use crate::line_range::{HighlightedLineRanges, LineRanges};
2#[cfg(feature = "paging")]
3use crate::paging::PagingMode;
4use crate::style::StyleComponents;
5use crate::syntax_mapping::SyntaxMapping;
6use crate::wrapping::WrappingMode;
10 /// Show all lines which are included in the line ranges
13 #[cfg(feature = "git")]
14 /// Only show lines surrounding added/deleted/modified lines
19 pub fn diff_mode(&self) -> bool {
21 Self::Ranges(_) => false,
22 #[cfg(feature = "git")]
23 Self::DiffContext(_) => true,
28impl Default for VisibleLines {
29 fn default() -> Self {
30 VisibleLines::Ranges(LineRanges::default())
34#[derive(Debug, Clone, Default)]
35pub struct Config<'a> {
36 /// The explicitly configured language, if any
37 pub language: Option<&'a str>,
39 /// Whether or not to show/replace non-printable characters like space, tab and newline.
40 pub show_nonprintable: bool,
42 /// The character width of the terminal
43 pub term_width: usize,
45 /// The width of tab characters.
46 /// Currently, a value of 0 will cause tabs to be passed through without expanding them.
49 /// Whether or not to simply loop through all input (`cat` mode)
50 pub loop_through: bool,
52 /// Whether or not the output should be colorized
53 pub colored_output: bool,
55 /// Whether or not the output terminal supports true color
58 /// Style elements (grid, line numbers, ...)
59 pub style_components: StyleComponents,
61 /// If and how text should be wrapped
62 pub wrapping_mode: WrappingMode,
65 #[cfg(feature = "paging")]
66 pub paging_mode: PagingMode,
68 /// Specifies which lines should be printed
69 pub visible_lines: VisibleLines,
71 /// The syntax highlighting theme
74 /// File extension/name mappings
75 pub syntax_mapping: SyntaxMapping<'a>,
77 /// Command to start the pager
78 pub pager: Option<&'a str>,
80 /// Whether or not to use ANSI italics
81 pub use_italic_text: bool,
83 /// Ranges of lines which should be highlighted with a special background color
84 pub highlighted_lines: HighlightedLineRanges,
88fn default_config_should_include_all_lines() {
89 use crate::line_range::RangeCheckResult;
91 assert_eq!(LineRanges::default().check(17), RangeCheckResult::InRange);
95fn default_config_should_highlight_no_lines() {
96 use crate::line_range::RangeCheckResult;
99 Config::default().highlighted_lines.0.check(17),
100 RangeCheckResult::InRange
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list