mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #1080] TUIs are corrupted when any code in the program prints a newline #786
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#786
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 @xxxserxxx on GitHub (Mar 30, 2025).
Original GitHub issue: https://github.com/rivo/tview/issues/1080
This is related to #1064.
tview display can be corrupted by code printing a newline to either
os.Stderroros.Stdout. Ideally, the tview display would not be affected by code printing output. In particular, this happens if any code, in any dependency, prints a newline; this includes CGO linked libraries, as well as indirect dependencies. It may be impossible to prevent a dependency anywhere in the dependency tree from printing output.As a work-around for when a dependency is printing to
os.Stderr, a program can hijackos.Stderrandos.Stdoutand redirect them.This last point illustrates the importance of handling this in tview.
Paste the code and run it, then scroll the table (list). You'll see the issue. Press 'q' to exit the program. Test the work-around by piping stderr to a file when running, or uncomment the lines 18-20. Note that this work-around is not portable; a portable work-around would need to create a file and redirect Stdin/Stdout to that.
@xxxserxxx commented on GitHub (Mar 30, 2025):
The work-around of redirecting stdin/stdout within the code apparently does not work when the message is generated in CGO-linked libraries; I assume this is because libraries are initialized and grab the file handles before
main()is called. I also tried redirecting the output in aninit()function; it also does not work. Piping the output on the command line does work, but this makes the solution something the every user must do.@xxxserxxx commented on GitHub (Apr 9, 2025):
This has been resolved; my test application no longer reproduces the issue.