Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AppendContent and DeleteTopContent methods #431

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ThisGuyCodes
Copy link

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.

@rendellc
Copy link

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

@QuLogic
Copy link

QuLogic commented Dec 13, 2023

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

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.

None yet

3 participants