mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #913] Flickering screen in Windows powershell and cmd 🦆 #666
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#666
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @FJuedesOrcl on GitHub (Nov 6, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/913
Hi Friends,
i am writing some utilities for directory-servers, for example a browser. My development environment is a Linux box, but i have to cross-compile everything also for Windows. Never used it on Windows myself, but my colleagues are reporting that on Windows the screen is flickering. It looks like as if the entire screen is cleared and redrawn. It is a nuisance when the screen has a black background by default, but when using a white background it is beyond annoying.
When using the OoenSUSE bash window of the wsl everything looks fine - of course that's a Linux shell, now Windows…
Do i miss something or is that just the way how screen updates are performed in Windows?
I am neither an expert in Go nor with the TView package, so any help is welcome.
Thank you very much in advance for your help.
@FJuedesOrcl commented on GitHub (Nov 6, 2023):
Okay, i figured something out:
There are two go-routines, that will update a TextView primitive in an endless loop. I had coded:
Application.QueueUpdate**Draw**(func(){StatusLine.SetText(Buffer)})To update the content of the TextView element. I have changed this to
Application.QueueUpdate(func(){StatusLine.SetText(Buffer)})Now the flickering is gone, but the content of those TextView elements is only updated when i press a key on the keyboard.
How can i redraw just the content of a TextView element?
Yes there is a TextView.Draw() function, but what do i use as the Screen parameter?
@rivo commented on GitHub (Nov 7, 2023):
Regarding flickering on Windows, I'm trying to get some answers here: https://github.com/gdamore/tcell/issues/647. I hope to be able to remove the flickering. As a temporary workaround, you can remove this line:
github.com/rivo/tview@1b91b8131c/application.go (L604)Regarding writing to the
TextView, you could try to buffer your writes and flush them toTextViewat fixed intervals (or similar). It's a bit more complicated but it might be a good idea anyway to reduce the number of draw events.Don't call
TextView.Draw()directly. This is never needed. This function should actually be private (but it's not, due to backwards compatibility).@FJuedesOrcl commented on GitHub (Nov 7, 2023):
@rivo
Hi Rivo,
Thank you very much for your answer!
I will try to comment out the
screen.Clear()in the tcell package and test how that effects the screen-output on windows and (more important) *ux. It will just take some time to change the package-code and then run the build-script.i have not understood (yet) how the tcell package internally works, but aeons ago i had a somewhat similar issue on a Unix system with a cshell script that was periodically refreshing the display on a slow 9600 baud terminal.
My solution at that time was not to clear the screen, but instead move the cursor home, then refresh the screen line by line, character by character from the left to wherever the line ended and then send the delete to EOL escape code.
There were still some visible artifacts, but only in single lines and much less disturbing for the human eye.
I am not using any call to *Draw method, except in the function to update the status-line:
which is executed every 500ms. No call to *Draw() anywhere else in my code:
It must be something windows specific, so far i have tested Linux on I86, X64, Arm32, Arm64, Sparc and AIX and no flicker, it happens just in Windows cmd and power-shell, inside windows and in full-screen.
@FJuedesOrcl commented on GitHub (Nov 7, 2023):
OK, update with the
screen.Clear()in the tcell package commented out:No more flicker on windows, but i still feel a bit uneasy when not clearing the screen before a full redraw…
I will observe and give feedback...
@FJuedesOrcl commented on GitHub (Nov 17, 2023):
@rivo
Update on this issue:
Changes to the code of application.go
This will prevent screen-flickering in the windows terminals, cmd, MobaXTerm and MS-Terminal (cmd and powershell).
Few artifacts are visible if the window is resized, especially when the width is changed.
On *nix terminals no visible artifacts, tested with MobaXTerm, PuTTY, MS-Terminal and on Linux-consoles.
To be sure that the changes above will only affect Windows, the runtime package could be used to apply the changes only on windows.
@rivo commented on GitHub (Dec 6, 2023):
This issue was resolved in
tcelland I upgradedtviewto the latest version. So the flickering should be gone with the latest commit.