1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! A minimal, crossterm-based terminal text viewer for Rust.
//!
//! Wrap any text with [`TxtView::new`], optionally tune it with
//! [`TxtViewConfig`], then call [`TxtView::run`]. The viewer takes over the
//! terminal with an alternate screen, switches to raw mode, and restores the
//! previous screen and settings when the user quits.
//!
//! [`TxtView::run`] blocks for the whole session and requires an interactive
//! terminal, so a small program is all it takes:
//!
//! ```no_run
//! # use txtview::TxtView;
//! # fn main() -> std::io::Result<()> {
//! let mut viewer = TxtView::new("hello world");
//! viewer.run()
//! # }
//! ```
//!
//! # Styled text
//!
//! ANSI colors and styling pass through unchanged: SGR codes and OSC8
//! hyperlinks are preserved, and the active style is re-emitted compactly
//! when a styled line wraps. Control bytes and other escape sequences are
//! shown as visible caret notation. Build styled lines with crossterm's
//! `style` module and feed them straight into [`TxtView::new`].
//!
//! # Configuration
//!
//! [`TxtViewConfig`] controls the display: line numbers, the help bar, the
//! interactive scrollbar, and a fixed viewport size. Configure it with a struct
//! literal plus `..TxtViewConfig::default()`, or chain the `with_*` setters.
//! See its documentation for examples.
pub use TxtView;
pub use TxtViewConfig;