rivo / tview

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

InputField paste-buffer is very short #133

Closed Lallassu closed 6 years ago

Lallassu commented 6 years ago

When pasting text into a InputField it only takes the first 11 chars of the copy-buffer.

Tested in OSX.

joegrasse commented 6 years ago

This is because of this issue.

rivo commented 6 years ago

Was going to say the same. I'm closing this issue then.

alvarolm commented 6 years ago

in case anyone needs it, i leave a poor man fix, assuming the cursor is always at the end of the input text:

import (
    ....

    "github.com/atotto/clipboard"
    "github.com/gdamore/tcell"
    "github.com/rivo/tview"
)

myinputfield.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
    switch event.Key() {
    case tcell.KeyCtrlV:
        // janky fix
        cb, err := clipboard.ReadAll()
        if err != nil {
            km.logger.Error().Msg("Couldn't get clipboard: " + err.Error())
            break
        }
        km.components.command.SetText(km.components.command.GetText() + cb)
    ....
    }
}
l0k18 commented 5 years ago

This bug is such a smelly one in the middle of a rose garden. The fix makes your app dependent on xsel being installed, on linux. I am forking tcell and tview because I need this working before halley's comet returns.

https://github.com/rivo/tcell/commits/master the tcell tview uses now has been untouched in over a year, and this is literally one character change to fix, and said tcell library has no issues either.

It's a very very nice library and I'm forking it but who doesn't need to paste 16+ character long strings on a regular basis these days?

rivo commented 5 years ago

@l0k1verloren The repo you quoted is not the one tview depends on:

https://github.com/rivo/tview/blob/cf9d1151736203cd42b67c554536559e2af885e1/application.go#L6

@gdamore still maintains tcell. It's probably better to direct any (constructive) feedback to the relevant issue for this: gdamore/tcell#200.