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

Improve scroll persistence #104

Merged
merged 5 commits into from
Jan 8, 2020
Merged

Conversation

dhleong
Copy link
Owner

@dhleong dhleong commented Jan 8, 2020

We have pretty solid scroll persistence when strictly appending, but I noticed it still gets wonky sometimes, and it turns out that's because we don't persist scroll position when deleting lines, etc. This PR refactors the way changes to the Buffer are passed onto the Renderer, by essentially having the Window subscribe to changes to the buffer. JLineBuffer now does nothing on its own (we keep it around just in case we need some renderer-specific bits in there) and instead JudoBuffer notifies any attached IJudoWindow instances that it's going to change something, and then that it has changed something, providing storage for the windows to save some state that they want handed back to them after the change.

This allows JLineWindow to trigger rendering when any change in any JudoBuffer subclass occurs, and also to update its scroll position as necessary.

This allows all buffer operations to be able to attempt to preserve
scroll position without having to go through the Window object.
Window.append should probably be deprecated, except perhaps as a
convenience extension
This drastically simplifies the JLineBuffer implementation; we may even
be able to just replace it with a factory function
@dhleong dhleong merged commit 3307e59 into master Jan 8, 2020
@dhleong dhleong deleted the dhleong/improved-scroll-persistence branch January 8, 2020 21:43
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.

1 participant