TxtView
TxtView is a lightweight text viewer for the terminal, written in Rust and built on crossterm. Drop it into your own CLI tools whenever you need a line-based viewer with scrolling, wrapping, line numbers, and an optional interactive scrollbar.
Features
- View any text in an alternate screen terminal session
- Scroll line-by-line
↑/↓orj/k, by pagePgUp/PgDn, or with the mouse wheel - Jump to the start
Home/gor the endEnd/Gof the text - Automatic line wrapping to the viewport width, with continuation markers on wrapped rows
- Optional line numbers
- Optional help bar with keybinding hints
- Optional interactive vertical scrollbar
- Configurable viewport width and height, or just use the terminal size automatically
Library Usage
Add txtview to your Cargo.toml:
[]
= "0.1"
Quick start:
use ;
Styled Text
TxtView writes your content verbatim, so any ANSI-styled text renders as-is. Build your styled strings with crossterm (the same library TxtView uses internally, so adding it costs no extra build time):
[]
= "0.1"
= "0.29"
use Stylize;
use ;
You are not tied to crossterm for styling, any library that emits ANSI escapes, or even raw escape sequences written by hand, works just as well:
let text = "\x1b[1;32mrunning\x1b[0m";
Configuration
TxtView is configured through TxtViewConfig, either with ..TxtViewConfig::default() to fill the remaining fields, or with chained with_* setters:
let config = default
.with_show_line_numbers
.with_show_scrollbar;
It can toggle line numbers, the help bar, and the scrollbar, as well as fix the viewport width and height (it falls back to the terminal size when unset).
For the full list of options and defaults, see the TxtViewConfig rustdoc.
Keybindings
| Key | Action |
|---|---|
q / Esc / Ctrl+C |
Quit |
↑ / ↓, j / k |
Scroll one line |
PgUp / PgDn |
Scroll one page |
Home / g |
Jump to start |
End / G |
Jump to end |
| Mouse wheel | Scroll one line per tick |
Examples
# Show a generated sample document
# View an arbitrary file
# Show the style gallery
Building from Source
Tests
License
MIT License - see LICENSE for full details.
TxtView © 2026 Devstand.