Skip to content

feat: fire OnScrollback hook for lines scrolled off the main screen#6

Open
leogr wants to merge 1 commit into
vito:mainfrom
leogr:feat/fire-onscrollback-hook
Open

feat: fire OnScrollback hook for lines scrolled off the main screen#6
leogr wants to merge 1 commit into
vito:mainfrom
leogr:feat/fire-onscrollback-hook

Conversation

@leogr

@leogr leogr commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

OnScrollback is already public and documented ("called every time a line is about to be pushed out of the visible screen region"), but the implementation in scrollUpN is a no-op - the call was commented out, so setting the hook does nothing today.

This PR wires it up: when the main screen scrolls a line off the top, the hook fires with that line (content + per-cell format).

A few details:

  • It only fires for history-producing scrolls - the main screen (not the alt screen, which has no scrollback) with a full-screen scroll region. Partial-region scrolls don't accumulate history.
  • Each line is deep-copied before the scroll (since scrollUp recycles the row slices), and the hook fires afterward, from the stable post-scroll state.
  • The per-cell Format is rebuilt from the canvas regions, so the hook gets the same Line shape that Render produces.

I also tightened the doc to match this contract - including that the hook runs synchronously during input and shouldn't re-enter the terminal.

@vito

vito commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Woops, just needs a rebase now that #5 is merged. (Thanks!)

@leogr leogr force-pushed the feat/fire-onscrollback-hook branch from 76e37cf to e1db390 Compare June 26, 2026 14:52
@leogr

leogr commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Woops, just needs a rebase now that #5 is merged. (Thanks!)

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants