txtview 0.1.0

A lightweight terminal text viewer with scrolling, wrapping, line numbers, and an optional interactive scrollbar
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented3 out of 3 items with examples
  • Size
  • Source code size: 45.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 396.6 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • iamdevstand
txtview-0.1.0 has been yanked.

TxtView

crates.io docs.rs

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 ↑/↓ or j/k, by page PgUp/PgDn, or with the mouse wheel
  • Jump to the start Home/g or the end End/G of 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:

[dependencies]
txtview = "0.1"

Quick start:

use txtview::{TxtView, TxtViewConfig};

fn main() {
    let text = "hello world";

    let config = TxtViewConfig {
        show_line_numbers: true,
        ..TxtViewConfig::default()
    };

    let mut viewer = TxtView::new(&text).with_config(config);
    viewer.run().unwrap();
}

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):

[dependencies]
txtview = "0.1"
crossterm = "0.29"
use crossterm::style::Stylize;
use txtview::{TxtView, TxtViewConfig};

fn main() {
    let text = format!(
        "Status: {}\n  · {}\n  · {}",
        "running".green().bold(),
        "in a sandbox".yellow().italic(),
        "high disk usage".red()
    );

    let mut viewer = TxtView::new(&text).with_config(TxtViewConfig::default());
    viewer.run().unwrap();
}

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 = TxtViewConfig::default()
    .with_show_line_numbers(true)
    .with_show_scrollbar(false);

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
cargo run --example sample_text

# View an arbitrary file
cargo run --example view_file -- path/to/file.txt

# Show the style gallery
cargo run --example styled

Building from Source

git clone https://github.com/iamdevstand/txtview
cd txtview
cargo build --release

Tests

cargo test

License

MIT License - see LICENSE for full details.


TxtView © 2026 Devstand.