Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't paste long strings into text-accepting widgets #14

Closed
gcla opened this issue May 26, 2019 · 15 comments
Closed

Can't paste long strings into text-accepting widgets #14

gcla opened this issue May 26, 2019 · 15 comments

Comments

@gcla
Copy link
Owner

gcla commented May 26, 2019

e.g. run the editor example and paste a longish (> 10 characters) string using the mouse e.g. shift-right-click Paste in gnome terminal. Only the first few characters appear.

@gcla
Copy link
Owner Author

gcla commented May 27, 2019

This seems to be an issue in tcell - there are issues logged for tcell and for tview, a widget framework built on tcell:

gdamore/tcell#200

rivo/tview#92

I'll figure out what to do for gowid - maybe fork tcell temporarily and use this patch:

soyking/tcell@9addd5b

@gcla
Copy link
Owner Author

gcla commented May 29, 2019

I've made a couple of PRs to tcell to try to address this and other pasting problems. From previous comments the author has made, he's very busy and tcell isn't paying the bills, so I'm not sure if there'll be a quick reply. I'll give it a short time, then maybe maintain a minor fork of tcell until the issue is resolved one way or another.

@mdouchement
Copy link

In this fork https://github.com/zyedidia/tcell used by micro editor, there are a lots of commits for addressing pasting problems that can be useful.

@gcla
Copy link
Owner Author

gcla commented May 30, 2019

Thanks, this is interesting - it looks like the fork was made back in 2016! I wonder if the author tried to merge changes back upstream? Makes me wonder if this fork might be more fruitful than the original repo.

Would you be interested in trying out the paste fixes I submitted upstream? I can describe how to adjust your go project to use the changes. Are you using go modules?

@mdouchement
Copy link

Using replace github.com/gdamore/tcell => github.com/gcla/tcell fixpastelimit works like a charm for pasting long lines/multilines.

I also tried github.com/gcla/tcell bundleevents that has one more commit but it fails to compile:

go: finding github.com/gcla/tcell bundleevents
go: downloading github.com/gcla/tcell v1.1.2-0.20190529031537-c0fec8904a79
go: extracting github.com/gcla/tcell v1.1.2-0.20190529031537-c0fec8904a79
# github.com/gdamore/tcell
../../../.gopath/pkg/mod/github.com/gcla/tcell@v1.1.2-0.20190529031537-c0fec8904a79/tscreen.go:1231:20: undefined: NewEventBundle


I think the zyedidia/tcell fork has custom modifications for micro editor. Don't know if it would suit to your project but it worth to ask the maintainer.

@gcla
Copy link
Owner Author

gcla commented May 30, 2019

Sorry @mdouchement I forgot there are gowid-side changes to make use of the tcell bundleevents branch. Could you pull from gcla/gowid and point your app at the new gowid bundleevents branch too?

@mdouchement
Copy link

NP, it seems the compilation error remain:

go: finding github.com/gcla/tcell bundleevents
go: finding github.com/gcla/gowid bundleevents
go: finding golang.org/x/sys latest
go: finding github.com/alecthomas/units latest
go: finding github.com/alecthomas/template latest
go: finding golang.org/x/crypto latest
go: finding golang.org/x/tools latest
go: finding golang.org/x/net latest
go: finding golang.org/x/sync latest
go: downloading golang.org/x/sys v0.0.0-20190531132440-69e3a3a65b5b
go: extracting golang.org/x/sys v0.0.0-20190531132440-69e3a3a65b5b
# github.com/gdamore/tcell
../../../.gopath/pkg/mod/github.com/gcla/tcell@v1.1.2-0.20190529031537-c0fec8904a79/tscreen.go:1231:20: undefined: NewEventBundle

Based on the commits' sha1, my go.mod looks good:

require (
	github.com/BurntSushi/toml v0.3.1 // indirect
	github.com/bep/debounce v1.2.0
	github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
	github.com/gcla/gowid v1.0.1-0.20190530225931-1bb8b12f6450
	github.com/gdamore/tcell v1.1.2
	github.com/mdouchement/simple-argon2 v0.1.0
	github.com/mdouchement/standardfile v0.2.0
	github.com/pkg/errors v0.8.1
	github.com/sanity-io/litter v1.1.0
	github.com/sirupsen/logrus v1.4.2
	github.com/spf13/cobra v0.0.3
	github.com/stretchr/objx v0.2.0 // indirect
	golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5
	golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
	golang.org/x/sys v0.0.0-20190531132440-69e3a3a65b5b // indirect
	golang.org/x/tools v0.0.0-20190530215528-75312fb06703 // indirect
	gopkg.in/natefinch/lumberjack.v2 v2.0.0
)

replace github.com/gdamore/tcell => github.com/gcla/tcell v1.1.2-0.20190529031537-c0fec8904a79

@gcla
Copy link
Owner Author

gcla commented Jun 3, 2019

Sorry to waste your time, there was a file I forgot to check in :-( It worked for me because I had a replace statement pointing to the changes on my local disk. I've pushed it now to gcla/tcell@bundleevents, along with another change to replace imports of gdamore/tcell with gcla/tcell. Just on the bundleevents branch of course, for the purposes of this experiment.

@mdouchement
Copy link

The paste is faster than fixpastelimit but unhandled events no longer work in my project:

// app.MainLoop(gowid.UnhandledInputFunc(unhandled))

func unhandled(app gowid.IApp, ev interface{}) bool {
	evk, ok := ev.(*tcell.EventKey)
	if !ok {
		return false
	}

	handled := false

	switch evk.Key() {
	case tcell.KeyCtrlQ:
		handled = true
		app.Quit()
	}

	return handled
}

@gcla
Copy link
Owner Author

gcla commented Jun 4, 2019

Hi - trying to think what could be going wrong... Is unhandled() no longer called when you run your app? If it is called, could you print/log something like

logrus.Infof("Event is %v of type %T", ev, ev)

@mdouchement
Copy link

Here the result:

Event is &{{13778103487261885912 3563704780 0x1944840} 2 17 17} of type *tcell.EventKey

I've dig futher more and I found that the ok variable is false in this statement evk, ok := ev.(*tcell.EventKey).
I'm wondering if there is an issue between type assertions and the gomodule replace.

@gcla
Copy link
Owner Author

gcla commented Jun 6, 2019

Yes, sounds like it might be that - tcell will be sending you *EventBundle events now, but if gowid is on the right branch, its HandleTCellEvent function should unpack *EventBundle into individual events like *EventKey, *EventMouse, and process them like normal. If you're somehow linking to the non-bundleevents version of gowid, it would log an unexpected event type, and not pass it on to your application.

@gcla
Copy link
Owner Author

gcla commented Jun 6, 2019

I just re-read your previous comment, and realized I'm probably wrong! Could you check to make sure you don't have any references in your source code to gdamore/tcell and and if you do to replace those with gcla/tcell? That would also be consistent with your hunch about type assertions and "replace".

@mdouchement
Copy link

Ok, it works by importing github.com/gcla/tcell in the file where ev.(*tcell.EventKey) is used.

@gcla
Copy link
Owner Author

gcla commented Jun 10, 2019

The tcell author merged the PR for fixpastelimit: gdamore/tcell#280. I'm not yet sure what will happen to the bundlevents PR. I'll probably adjust the gcla/tcell fork so that it's up to date with respect to gdamore/tcell, then re-apply bundlevents on top. Just to let you know in case it causes problems for your application! I'll close this issue for now.

@gcla gcla closed this as completed Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants