Repository navigation
ui.py: Reuse existing windows on resize - #217
Conversation
0dba526 to
ddff466
Compare
| # Test for new curses | ||
| if "get_wch" not in dir(self.header_win): | ||
| # Notify only once | ||
| if not self.warned_old_curses: |
There was a problem hiding this comment.
I did not check if self.warned_old_curses has other implications outside of ui.py or can be removed completely after this change. A quick grep -R inside the repo seems to suggest it can be removed completely. If that is indeed the case I'll remove it from __init__ as well.
Edit:
Force pushed a new version which removed it.
There was a problem hiding this comment.
That's ok. It's not used anywhere else like you said.
1277726 to
6be9e1c
Compare
|
With this applied I sometimes get log outputs from the editor win like this: It doesn't seem to affect anything but still strange. Will need to investigate. |
| # Not sure why editor implements this on its own | ||
| # and if it's a good thing or not. | ||
| self.app.get_editor().move_win((offset_top, 0)) | ||
| self.app.get_editor().resize((y - offset_top - offset_bottom, x)) |
There was a problem hiding this comment.
I seem to be getting some errors when resizing the terminal. It works fine and everything looks like it should, but curses complains a little bit:
2018-01-21 17:33:15,393 - suplemon.viewer - WARNING - Moving window failed!
Traceback (most recent call last):
File "/home/wavi/code/python/suplemon-contrib/consolatis-suplemon/suplemon/viewer.py", line 284, in move_win
self.window.mvwin(yx[0], yx[1])
_curses.error: mvwin() returned ERR
This seems to go away if the two lines above are swapped, so that resize is run first and move_win after that. I'm guessing it might be complaining because the window is too big and would be placed on top of the legend or status bar after the move. I'm not sure though.
I think it'd be fine to just swap the lines and go forward with this 👍
|
Oops, forgot to submit my comment earlier. See above. The mvwin was wrapped with that try/except a long time ago because I noticed that it might fail randomly sometimes. It's no big deal but the above seems to help. |
|
Switched those two around and indeed: no more errors showing up. |
|
Yeah, that's all :) Thanks! |
6025664 to
ec3be7b
Compare
|
squashed the commits :) |
|
Merged :) |
Reuse existing curses windows on resize instead of recreating them
Edit:
To clarify the reasoning for this change: I added this because my local WIP branch for statusbar components creates an instance of StatusBar() for each bar (currently only top and bottom) which gets a curses window via constructor so the window should always be available.
Things to do:
investigate editor move errorsquashrebase