Skip to content

bookokrat

Batch 8 (readers / browsers / hierarchical-navigation TUIs).

bookokrat is a Rust terminal book reader for EPUB, PDF, and DJVU. Its layout is a split panel: a left panel carrying the library + table-of-contents tree, and a right panel rendering the book content. It ships a zen mode (distraction-free, full-screen reader with the side panel hidden), adjustable margins, inline annotations/comments with persistent storage and Markdown export, reading statistics, and vim keybindings. PDF/DJVU pages render as images via the Kitty SHM graphics protocol on supporting terminals (Kitty, Ghostty; degraded on iTerm2/WezTerm/Warp/Konsole); EPUB renders as reflowable text. Storage is XDG-compliant (bookmarks, comments, settings per library).

  • Split library/TOC + reader is the reader-mode layout. The left-panel (navigation) / right-panel (content) split is the reference for KN-86’s reading surfaces — a cart presenting a multi-chapter document, a lore archive, a mission briefing dossier. The navigation pane lists structure; the reader pane shows the focused section. This is the same multi-pane composition w3m frames and newsboat implements, framed specifically for long-form reading.
  • TOC tree navigation = drill-into for documents. The TOC tree lets the operator move hierarchically through a document’s structure (part → chapter → section) and jump the reader pane to any node. This is the hackernews-TUI collapsible-tree widget applied to document structure — same primitive, reading context. For KN-86, any structured content a cart ships (a manual, a campaign codex, a phase-chain dossier) gets a navigable TOC tree, and CAR/BACK drill in and out of it.
  • Zen / focus mode is a strong, portable concept. A keystroke collapses all chrome and gives the full grid to the content. KN-86 owns Rows 0 and 24 (status/action bars per Canonical Hardware Specification) and carts own Rows 1–23 — but a zen toggle that lets a reader-mode cart temporarily reclaim a maximal reading area (subject to the runtime keeping Row 0/24 authority) is a clean, ergonomic affordance for long reads on the small grid. Worth flagging as a reader-mode design option.
  • Annotations with Markdown export. Persistent inline annotations that export to a portable text format is a model for KN-86 operator notes — a deckline that lets the operator mark up lore or mission intel, persisted to the device microSD (Universal Deck State / per-cart save per Canonical Hardware Specification) and exportable as plain text. The Markdown-export-as-portability idea fits KN-86’s plain-text-everything ethos.
  • Reading statistics. Tracked reading progress/stats is a light gameplay/telemetry hook — a KN-86 cart could surface “fragments decoded,” “intel reviewed,” etc. in the same spirit.
  • Format-aware rendering split (reflowable text vs. image pages). bookokrat reflows EPUB as text but rasterizes PDF/DJVU as images — picking the rendering path per content type. KN-86 makes the same choice: reflowable glyph text for prose (the common case), framebuffer/half-block imagery only where the content is inherently pictorial.

Ratatui is fully themeable and runs in monochrome; bookokrat’s text-reading core needs no color. Adaptations for amber-on-black:

  • TOC tree via indentation + box-drawing + collapse glyphs. Same as hackernews-TUI: nesting from indent + │ ├ └ connectors, collapse state from /, current node from inversion. No color.
  • Split-panel divider via box-drawing. The library/reader split is a vertical rule (or a full box border), not a color boundary.
  • Reading-position / progress via a glyph gauge. A progress indicator renders as a text bar ([████▌···] 58%) or a margin tick column, not a colored fill — block glyphs give the fill, percentage gives the readout.
  • Annotation markers as marginal glyphs. An annotated line carries a leading /§/* margin mark; the focused annotation inverts. State is glyph + inversion.
  • Zen mode is inherently single-color. Hiding chrome to maximize reading area has no color dimension — it ports directly. The PDF/DJVU Kitty-SHM image path is the one part that doesn’t apply on-device (KN-86 isn’t a Kitty terminal); KN-86’s pictorial path is its own BITMAP framebuffer plus the half-block/braille glyph-encoding from browsh / mapscii.
  • Ratatui joins the TUI-library shortlist alongside Cursive (see hackernews-TUI) and OpenTUI — a mature, widely-used Rust immediate-mode TUI framework. As with the others, it’s a pattern reference, not a dependency (KN-86 runtime is C/SDL3); study its split-pane + tree-widget + theming model.
  • Cross-link hackernews-TUI — the collapsible-tree widget shared between comment threads (there) and TOC trees (here).
  • Cross-link newsboat and w3m — the other reader/pager entries; bookokrat is the long-form-reading specialist with the zen-mode and annotation dimensions the others lack.