rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang
MIT License
11.17k stars 574 forks source link

Scrambled text not found in old commit. #853

Closed jorgeluismireles closed 1 year ago

jorgeluismireles commented 1 year ago

I found old code works correctly but newest doesn't, for the same example and machine I got:

For github.com/rivo/tview v0.0.0-20200915114512-42866ecf6ca6: tview_old

For github.com/rivo/tview v0.0.0-20230525073430-4a1f85bb2219: tview_new

For exactly the same example:

    app := tview.NewApplication()
    form := tview.NewForm().
        AddDropDown("Title", []string{"Mr.", "Ms.", "Mrs.", "Dr.", "Prof."}, 0, nil).
        AddInputField("First name", "", 20, nil, nil).
        AddInputField("Last name", "", 20, nil, nil).
        AddCheckbox("Age 18+", false, nil).
        AddPasswordField("Password", "", 10, '*', nil).
        AddButton("Save", nil).
        AddButton("Quit", func() {
            app.Stop()
        })
    form.SetBorder(true).SetTitle("Enter some data").SetTitleAlign(tview.AlignLeft)
    if err := app.SetRoot(form, true).EnableMouse(true).Run(); err != nil {
        panic(err)
    }
$ uname -a
Linux XXXXXX 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:00 UTC 2021 i686 i686 i686 GNU/Linux

I searched the FAQ, tried several console's configs changes but the issue persists. Thanks for your advice!

jorgeluismireles commented 1 year ago

The problem is present even for base example of recent tcell:

github.com/gdamore/tcell/v2 v2.6.0

But my systems (ARM32, x86) works OK with old tview mentioned which uses 'old' tcell:

github.com/gdamore/tcell v1.3.0 // indirect

How to proceed?

More details about the differences from tcell requires: Old versions that work for my case:

require (
    github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
    github.com/mattn/go-runewidth v0.0.9 // indirect
    github.com/rivo/uniseg v0.1.0 // indirect
)

New versions don't:

require (
    github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
    github.com/mattn/go-runewidth v0.0.14 // indirect
    github.com/rivo/uniseg v0.4.3 // indirect
)
rivo commented 1 year ago

I would suggest that you take this issue over to tcell. tview is based on tcell. If tcell has this problem, tview will have it, too, and it needs to be solved there. In that case, there's nothing I can do here.

jorgeluismireles commented 1 year ago

Thanks. The problem started when tcell changed from v1.4.0 to v2

The last version "working" is the v2.5.1, the first "failing" is v2.5.2. I'll post the issue there.

gdamore commented 1 year ago

I'm guessing some terminal is missing support for some capabilities that I'm using... I need more detail about the specific terminal so I can investigate.

jorgeluismireles commented 1 year ago

Workaround

For legacy linux 32 bits systems arm, x86 set environment variable TERM=linux before to prevent latest versions scramble the display. Default terminals of type xterm cause escape/mouse artifacts.

gdamore commented 1 year ago

If this is on a linux terminal then any form of "xterm" is wrong because it does not support the normal xterm escapes.

rivo commented 1 year ago

@jorgeluismireles Have you been able to solve this? I will probably close this issue soon as it doesn't appear to be related to tview.

gdamore commented 1 year ago

I'm quite certain that the problem here is neither a bug in tcell nor tview. It was user error declaring a terminal to be xterm that isn't, which caused us to emit various escape sequences that the terminal did not know how to handle.

I recommend just closing this as not a bug.

And for posterity: The linux console is not xterm. It is "linux", and I believe that is the correct setting for $TERM when using the linux console.

jorgeluismireles commented 1 year ago

Yes, I solved the problem setting in old linux terminals: TERM=linux. Thanks!