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 (in the line-number column)
- 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 renders ANSI-styled text correctly: SGR color and style codes, plus OSC8 hyperlinks, pass through untouched, and when a styled line wraps the active style is preserved and re-emitted as a compact prefix on the wrapped rows. Control bytes and any other escape sequence are shown as visible caret notation (^G, ^[[2A) rather than executed. 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 SGR styling codes, or even raw sequences written by hand, works just as well (other escape sequences are neutralized to visible text, so only styling and OSC8 links register):
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 |
| Scrollbar track / thumb | Click to jump to a position, drag to scroll |
Examples
# Show a generated sample document
# View an arbitrary file
# Show the style gallery
# Show control bytes and non-SGR escapes as visible caret notation
# Show column-aware wrapping with CJK, emoji, and full-width punctuation
# Show how grapheme clusters (skintone modifiers, ZWJ families, flags) never split across a wrap
Building from Source
Tests
License
MIT License - see LICENSE for full details.
TxtView © 2026 Devstand.