Redraw on resize
Closed this issue ยท 16 comments
Environment details (Put x
in the checkbox along with the information)
[x] Operating System: Red Hat Enterprise Linux Server release 6.9 (Santiago)
[ ] Desktop Environment:
[x ] Terminal Emulator: gnome-terminal
[x] Shell: zsh
[ ] Custom desktop opener (if applicable):
[x] Issue exists on nnn
master
Exact steps to reproduce the issue
- Resize the window or tmux pane so there is only one visible row (I've reproduced this in tmux and gnome-terminal)
- Resize the window or tmux pane back to it's original size.
This causes some weird graphical bugs. For example, the top bar gets overwritten:
I end up with a lot of missing files. Here's what happens when I move the cursor around:
And here's what happens when I try to access every context, then it gets restored at the top:
Please confirm if the patch fixes this problem.
Confirmed it's fixed. Thanks! ๐
Awesome! I tried some optimization to reduce redundant screen clear... but it looks we have to do a complete erase.
@toddyamakawa do you nee this issue with the following patch?
diff --git a/src/nnn.c b/src/nnn.c
index dcdafcc..4c488c5 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4938,14 +4938,16 @@ static void redraw(char *path)
DPRINTF_S(__FUNCTION__);
- /* Clear screen */
- erase();
+ /* Clear first line */
+ move(0, 0);
+ clrtoeol();
/* Enforce scroll/cursor invariants */
move_cursor(cur, 1);
/* Fail redraw if < than 10 columns, context info prints 10 chars */
if (ncols < MIN_DISPLAY_COLS) {
+ clrtobot();
printmsg(messages[MSG_FEW_COLUMNS]);
return;
}
@@ -4998,7 +5000,8 @@ static void redraw(char *path)
attroff(A_UNDERLINE);
/* Go to first entry */
- move(2, 0);
+ move(1, 0);
+ addch('\n');
ncols = adjust_cols(ncols);
@@ -5015,6 +5018,9 @@ static void redraw(char *path)
cfg.dircolor = 0;
}
+ /* Clear from last entry to end */
+ clrtobot();
+
statusbar(path);
}
@toddyamakawa do you nee this issue with the following patch?
The fix still works with this patch ๐
I think we'll have this patch then. I want to reduce the amount of erase we do. The way ncurses prints on the screen is - it overwrites the earlier. And if you add a \n
at the end (which we do for each entry), it clears till the end of the line and goes to the next. So when we have a screenful of files we don't really need to erase the full screen and we can save almost one full screen erasure in the best case. And it comes at minimal cost.
That's good to know. Thanks for the explanation.
Please test master. I have modified a bit from the patch. Even more optimized!
Alright, confirmed that I see 75724f9e3b6463d44081a5c48b68a0b28a69ef4a
and the fix still works. Great work!
@leovilok can you test the commit with your issue of resizing the screen and confirm?
I tested master, I don't have the partial redraw bug on extra small window sizes, but it's still buggy : now on smallish window sizes an extra newline is sometimes inserted at the top, shifting every lines in the file list, and they don't redraw well. I'll try to capture that if you want.
I think I'll just get back to complete erase.