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
enhanced mouse tracking mode (1006) is set improperly when exiting tcell #512
Conversation
So the problem is that VIM and tcell are fighting over mouse control... I don't think it's good not to disable mouse tracking by default, because vim aside, most people will not like the result -- you'll move the mouse and it will inject a bunch of garbage into your shell window. What need to do is figure out if we can query the mouse state when starting up, and restore it to what it was. Unconditionally not clearing the mouse flags is unacceptable. (To be honest, I think the problem here is VIM's fault -- when returning from a subshell, it should reenable the mouse behavior it wants, rather than making assumptions that the child process didn't mess with it. This is done for other settings like terminfo flags, and the mouse handling needs to be treated in the precise same way.) |
I found the specification of control sequnces of terminal app in chromebook. https://chromium.googlesource.com/apps/libapps/+/master/hterm/doc/ControlSequences.md |
@gdamore I checked the specifications and implementation of hterm's control sequence. As a result, I found two things. First, it turns out that hterm completely ignores her 1003 settings. Therefore, not only motion events but also button and drag events are no longer generated. I suspect that the fix of #477 is a hack to deal with this behavior. Second, SGR (1006) must be reset at the finalization of tcell. If the SGR setting remains, older applications that do not use SGR (such as I also found that the current implementation of tcell is incomplete. You can give func (t *tScreen) enableMouse(f MouseFlags) {
// Rather than using terminfo to find mouse escape sequences, we rely on the fact that
// pretty much *every* terminal that supports mouse tracking follows the
// XTerm standards (the modern ones).
if len(t.mouse) != 0 {
// start by disabling all tracking.
t.TPuts("\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l")
if f&MouseMotionEvents != 0 {
t.TPuts("\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h")
} else if f&MouseDragEvents != 0 {
t.TPuts("\x1b[?1000h\x1b[?1002h\x1b[?1006h")
} else if f&MouseButtonEvents != 0 {
t.TPuts("\x1b[?1000h\x1b[?1006h")
}
}
} |
@gdamore |
I'm going to take a close look at this. My fear is that there is some impedance mismatch here in the intended behavior and the actual... and what happens in the terminals. It is not surprising to me that some of these flags are ignored by terminals... the design actually depends upon it -- they should enable what they can, and ignore the rest. The other thing is that my commentary earlier may also have been misunderstanding the context where this occurs. |
e47b2bd
to
39161d6
Compare
@gdamore thank you very much! |
Fixed to properly reset enhanced mouse tracking mode (1006) when calling
enableMouse(0)
.related #477
Behavior before modification:
If I quit the
tcell
application with the mouse enabled and then startvim
, the cursor doesn't move when I click the mouse.The symptom was confirmed by
_demos/mouse.go
in the linux environment on Chromebook and Windows.