Skip to content

Commit

Permalink
use highest capable mouse flag (with care if 1003 is ignored in some …
Browse files Browse the repository at this point in the history
…terminals)
  • Loading branch information
tmatz committed Feb 15, 2022
1 parent 39161d6 commit e47b2bd
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tscreen.go
Expand Up @@ -923,7 +923,7 @@ func (t *tScreen) EnableMouse(flags ...MouseFlags) {
flagsPresent = true
}
if !flagsPresent {
f = MouseMotionEvents | MouseDragEvents | MouseButtonEvents
f = MouseMotionEvents
}

t.Lock()
Expand All @@ -939,17 +939,14 @@ func (t *tScreen) enableMouse(f MouseFlags) {
if len(t.mouse) != 0 {
// start by disabling all tracking.
t.TPuts("\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l")
if f&MouseButtonEvents != 0 {
t.TPuts("\x1b[?1000h")
}
if f&MouseDragEvents != 0 {
t.TPuts("\x1b[?1002h")
}
if f&MouseMotionEvents != 0 {
t.TPuts("\x1b[?1003h")
}
if f != 0 {
t.TPuts("\x1b[?1006h")
// Some terminals (putty, hterm, etc.) may ignore 1003,
// in which case use 1002 instead.
t.TPuts("\x1b[?1002h\x1b[?1003h\x1b[?1006h")
} else if f&MouseDragEvents != 0 {
t.TPuts("\x1b[?1002h\x1b[?1006h")
} else if f&MouseButtonEvents != 0 {
t.TPuts("\x1b[?1000h\x1b[?1006h")
}
}

Expand Down

0 comments on commit e47b2bd

Please sign in to comment.