feat: less pager mode with smooth Kitty image scrolling and Mermaid theming - #67
Open
kkovary wants to merge 6 commits into
Open
feat: less pager mode with smooth Kitty image scrolling and Mermaid theming#67kkovary wants to merge 6 commits into
kkovary wants to merge 6 commits into
Conversation
…id theme config Pager: - Add a 'less' pager mode that scrolls by line (j/k, arrows), half-page (d/u), page (space/b), g/G, and / ? n N search, instead of more's page jumps. - On Kitty-graphics terminals (Kitty, Ghostty), less mode scrolls images smoothly: scroll position is tracked in display rows and each redraw emits a vertically-cropped Kitty placement (EncodeKittyCrop) for the visible slice, so diagrams scroll partially off-screen instead of popping in/out. iTerm2/sixel keep the atomic fallback. Mermaid: - Add config 'mermaid.theme' (light/default, dark, forest, neutral, base); drives the Mermaid theme and page background for inline images and PDF. Unknown values warn and fall back to default. Includes unit tests for crop pixel math, row-scroll/segment math, search, and theme resolution.
Wrap each redraw in synchronized output (DEC mode 2026) so the terminal presents the clear-then-repaint as one atomic frame, coalesce already- buffered input (fast key-repeat / mouse wheel) into a single repaint, and skip repaints when the visible frame would not change.
…al background - Make 'less' the default pager mode so new installs get line-by-line scrolling (with smooth inline images on Kitty/Ghostty) out of the box. - Add an 'auto' Mermaid theme (now the default) that queries the terminal background via OSC 11 and renders dark diagrams on a dark background, light otherwise. Falls back to light when the background can't be detected (e.g. PDF export to a file). - Document pager.mode and mermaid.theme options in the README.
Watch the input file and refresh the pager in place when it changes, for an edit-in-one-pane / preview-in-another workflow. - internal/watch: mtime+size polling with debounce, coalescing rapid saves. - Event-driven less pagers (text and smooth-Kitty): a goroutine pumps terminal bytes into a channel and the loop selects over keystrokes + a reload signal, so the view refreshes without a keypress while preserving scroll position. Non-watch pager paths are unchanged. - --watch / --no-watch flags and a pager.watch config option, off by default. Gated to a file argument rendered to a TTY; otherwise renders once with a note. - Resolve the 'auto' text style once before raw mode so reloads keep the initial theme instead of re-querying the terminal mid-pager. - Docs and unit tests (watcher change-detection/debounce, applyContent scroll preservation, segment rebuild, chanReader).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
less-style pager, Mermaid theming, and a live-reload watch mode, and makes line-by-line scrolling + terminal-aware theming the defaults.Pager: new
lessmode (now the default)j/k, arrow keys, mouse wheel) instead ofmore's page jumps, plus half-page (d/u), page (space/b),g/Gtop/bottom, and/?nNsearch.Mermaid:
mermaid.themeconfig (defaultauto)--pdfexport:auto,light/default,dark,forest,neutral,base.autoqueries the terminal background via OSC 11 and renders dark diagrams on a dark background, light otherwise. Falls back to light when the background can't be determined (e.g. PDF export to a file).Watch mode (
--watch)--watch/--no-watchflags and apager.watchconfig option, off by default. Gated to a file argument rendered to a TTY; otherwise renders once with a note.Defaults & docs
pager.modeis nowless(wasmore); defaultmermaid.themeisauto.pager.mode,pager.watch, andmermaid.theme.Behavior change
The default pager changes from
moretoless. Users who prefer the old behavior can set{"pager": {"mode": "more"}}.vimmode is unchanged.Testing
go build ./...,go vet ./..., and the fullgo test ./...suite (including the Chrome-backed Mermaid tests) pass, plus-raceon the watch/pager packages.Notes
cat foo.md | glowm --watchdoes not watch.