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

Support for resize #51

Closed
ChristianKienle opened this issue Jul 31, 2018 · 3 comments
Closed

Support for resize #51

ChristianKienle opened this issue Jul 31, 2018 · 3 comments

Comments

@ChristianKienle
Copy link

This is more of a question than an issue:

I am using terminal canvas for a small cli app. I want to support the user resizing the terminal. I am catching the resize event from the underlying stream to get the new width/height. However I haven’t found an API that allows me to resize the canvas. Atm I am recreating the whole canvas (with new(...)) using the new size. However this is causing a lot of flickering.

Is there anything I am overlooking?

I think it should be possible to support resizing the window in an efficient manner... can you confirm that there is no API? Then I could work on this feature if you don’t want to do it yourself.

Btw: thank you so much for this cool project.

@ghaiklor
Copy link
Owner

@ChristianKienle wow, sorry for such a long reply :)
I just got time to get through all the notifications.

Regard your question, no. There is no such a way to change canvas size without creating a new one.

@ChristianKienle
Copy link
Author

Regard your question, no. There is no such a way to change canvas size without creating a new one.

Thanks for the response :)

It is a while back when I last worked on the project using terminal-canvas. I believe I ended up by disabling (showing the current size w/h instead) UI updates while the resizing occurs. This was good enough for a CLI UI. I wonder how ncurses is doing it though. :D

@ghaiklor
Copy link
Owner

If you ask me, I'd try to implement it via vectors in terminal-canvas, not just arrays.

The problem here, why it can't be easily done here is that, I'm pre-allocating required space for frame buffer by calling Array.new(witdth * height). It is done for performance optimizations.

So, if you want to change width or height, you will be forced to allocate new array and re-assign it to variable, which is obviously will be slow. Especially, if you do it in each resize event.

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

No branches or pull requests

2 participants