bubbles icon indicating copy to clipboard operation
bubbles copied to clipboard

feat(viewport): add AppendContent and DeleteTopContent methods

Open ThisGuyCodes opened this issue 9 months ago • 2 comments

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. if PastBottom() and HighPerformanceRendering is true).
  • DeleteTopContent: deletes n 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.

ThisGuyCodes avatar Nov 09 '23 22:11 ThisGuyCodes

Just wanted to chime in and say I have the same use case. Hope this gets approved

rendellc avatar Nov 11 '23 22:11 rendellc

This looks useful for #294, but see also #133.

QuLogic avatar Dec 13 '23 07:12 QuLogic