Hasty Briefsbeta

Bilingual

I made a terminal pager

3 hours ago
  • #Go-programming
  • #TUI-development
  • #terminal-pager
  • Created reusable viewport component in Go for text navigation in terminal applications (TUIs) like kl for Kubernetes logs and wander for Nomad.
  • Terminal pagers allow interactive navigation of multi-page text; used viewport to build lore, a terminal pager used daily.
  • Terminals have grid-like nature with monospace fonts; styling uses ANSI escape codes for colors and formatting.
  • Developers view high volumes of text in terminals: logs, diffs, man pages, READMEs, query results, and AI tool outputs.
  • Programs use PAGER environment variable for paging; less is common, but alternatives include bat, most, and delta.
  • TUIs are terminal applications using alt screen and components like viewports, selection lists, and input fields.
  • Viewport component handles Unicode, text wrapping, horizontal panning, search, selection, and ANSI styling.
  • Unicode handling considers code points, graphemes, terminal width, and uses Item interface for efficient text management.
  • Search features include exact match, regex, case-insensitive with shortcuts, match navigation, and context toggling.
  • Item selection is enabled in viewport for interactive selection, returning selected object to callers.
  • lore is a terminal pager built with Bubble Tea TUI, leveraging viewport for intuitive text navigation and daily use.