-
Notifications
You must be signed in to change notification settings - Fork 42
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
Contribute to prompt-toolkit? #6
Comments
Yes, absolutely The ScrollablePane from PT works by rendering all child elements to a virtual screen, then copying only the visible interest to the display. This is not good for performance, especially with a large number of child elements, because every child is redrawn on every refresh. My ScrollingContainer implementation accepts a list of functions which return child elements, so they can be created on the fly. Instances of child elements are only created for those elements which are currently in view, and only visible children are rendered. When a child is no longer visible, all references to it's instance are dropped, meaning it will be cleaned up by the GC. Children which are partially visible are drawn by rendering them on a virtual screen, then copying only the visible lines to the display. The effect of scrolling as achieved by maintaining a reference to the current (selected) child, and it's offset from the top of the available space. Scrolling up or down if done by adjusting this offset. When drawing to the screen, the selected child is drawn first, then the space above and below are then filled with neighbouring children until the available space is full. The child heights are cached to prevent having to render a large number of children just for their heights if the selected child is scrolled a long way off screen. There are a few things I'm planning to contribute upstream from euporie:
|
Thanks for the detailed explanation, this looks great! In nbterm I'm using |
I see you have implemented something similar to ScrollablePane in ScrollingContainer (maybe more efficient, or with more features?). Could you tell a bit more about it? Do you think you could contribute upstream in prompt-toolkit?
The text was updated successfully, but these errors were encountered: