gizak / termui

Golang terminal dashboard
MIT License
13.06k stars 783 forks source link

Termui text can't be selected for copy-and-paste #255

Open mschilli opened 4 years ago

mschilli commented 4 years ago

What's the reason that text displayed in termui can't be selected with the mouse for copy-and-paste? The curses library supports it, tools like "top" allow the user to select text and copy it.

image

This seems to be related to https://github.com/gizak/termui/issues/67, which claims it only happens after a while, but I've found it happens right from the start, even with a simple hello world program on both Mac and Linux.

Would be great if you could add some hints on why this is, this would be a great thing to have for termui (and downstream projects like termdash), as almost all users expect this to work in a terminal UI.

AlbinoDrought commented 4 years ago

I'm experiencing this as well, but my usecase is more limited - I'm not using mouse support at all.

Mouse support is enabled here. If mouse support isn't required, it can be disabled like this:

import (
    tb "github.com/nsf/termbox-go"
)

// DisableMouseInput in termbox-go. This should be called after ui.Init()
func DisableMouseInput() {
    tb.SetInputMode(tb.InputEsc)
}

Selection and copy/paste works on my machine with mouse support disabled.

mschilli commented 4 years ago

Sounds crazy, but disabling mouse support works, it enables support for cut-and paste of the text displayed in the UI! Thanks for digging that up.