bubbles
bubbles copied to clipboard
feat(viewport): add AppendContent and DeleteTopContent methods
I have a use case where I want to stream logs to a bubbletea-based TUI, which seems like a perfect use of the viewport.Model
! Particularly since logs can sometimes come at you quite fast, using the terminal built-in scrolling mechanisms seems prudent.
However the current viewport.Model
only supports fully replacing the current content and re-syncing on every change.
Here I've added two methods to viewport.Model
:
-
AppendContent
: adds to the end of the current content, and returns a tea.Cmd that "scrolls" the new content into view if necessary (i.e. ifPastBottom()
andHighPerformanceRendering
is true). -
DeleteTopContent
: deletesn
lines from the top of the current content, and scrolls appropriately if this leaves you "passed the top".
Open to feedback on everything here! I'll get around to making a few test apps myself to verify behavior before taking this out of draft.
Just wanted to chime in and say I have the same use case. Hope this gets approved
This looks useful for #294, but see also #133.