lesster

A less-like interactive text pager library for Nim

v0.2.0 Nim ≥ 2.0 License MIT nimwave + illwave
Browse the API Reference →

Full symbol index, module docs, and type definitions

What is lesster?

lesster is a Nim library that gives any terminal application a full-screen, keyboard-driven text viewer — the kind you already know from less or man — in just two lines of code.

It is built on top of nimwave and illwave, giving you smooth rendering, Unicode support, multiple colour themes, regex search, and optional Markdown highlighting, without any dependency on external system pagers.

Use it to display help text, log output, generated reports, or any long string your program produces — instead of dumping everything to stdout and losing the user in a wall of text.

Screenshot

lesster in action

Quick start

Add the package to your project:

nimble install lesster

Display an in-memory sequence of lines:

import lesster

let lines = readFile("report.txt").splitLines()
viewText(lines, title = "My Report", themeName = "default")

Or open a file directly (pass "-" for stdin):

import lesster

viewFile("output.log", title = "Build Log", themeName = "dark")

# pipe-friendly: cat report.txt | ./myapp -
viewFile("-", title = "stdin", themeName = "terminal")

Custom theme at runtime:

import lesster
from illwave as iw import nil

var myTheme = ThemesTable["dark"]
myTheme.titleBg = iw.bgBlue
myTheme.titleFg = iw.fgWhite
# See API reference for all Theme fields

Keyboard navigation

All bindings are active in the default normal mode. Press q at any time to exit.

/
Scroll one line Up or down
PgUp / PgDn
Scroll one page Up or down
Space
Page down Scroll one page forward
g
Jump to top First line of the document
G
Jump to bottom Last line of the document
/
Search Enter regex search mode
n
Next match Jump to next search result
N
Previous match Jump to previous search result
m
Toggle Markdown Enable / disable MD rendering
s
Toggle word-wrap Soft-wrap long lines
Tab
Cycle themes Rotate through colour schemes
q
Quit Return to the calling program

Built-in themes

Pass a theme name to viewText / viewFile, or let users cycle through them interactively with Tab. You can also construct a Theme object from scratch for full control.

"default"
"dark"
"light"
"matrix"
"mono"
"terminal"

Ready to dig deeper?

The full API reference documents every exported symbol.

API Reference → lesster module