summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-01-24 12:00:41 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-01-24 12:00:41 +0900
commit91b9591b10911263265cb36248db6f95d4fabde3 (patch)
treece4dc94f7790d62d76a54c75d73e37c094759084
parentaa7361337d3f78ae1e32283ba395446025323abb (diff)
Reenable mouse mode when coming back from an external program
Close #3141
-rw-r--r--src/tui/light.go37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/tui/light.go b/src/tui/light.go
index 3ff4ded7..5a011db5 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -174,11 +174,7 @@ func (r *LightRenderer) Init() {
}
}
- if r.mouse {
- r.csi("?1000h")
- r.csi("?1002h")
- r.csi("?1006h")
- }
+ r.enableMouse()
r.csi(fmt.Sprintf("%dA", r.MaxY()-1))
r.csi("G")
r.csi("K")
@@ -621,6 +617,23 @@ func (r *LightRenderer) Pause(clear bool) {
}
}
+func (r *LightRenderer) enableMouse() {
+ if r.mouse {
+ r.csi("?1000h")
+ r.csi("?1002h")
+ r.csi("?1006h")
+ }
+}
+
+func (r *LightRenderer) disableMouse() {
+ if r.mouse {
+ r.csi("?1000l")
+ r.csi("?1002l")
+ r.csi("?1006l")
+ r.mouse = false
+ }
+}
+
func (r *LightRenderer) Resume(clear bool, sigcont bool) {
r.setupTerminal()
if clear {
@@ -629,15 +642,13 @@ func (r *LightRenderer) Resume(clear bool, sigcont bool) {
} else {
r.rmcup()
}
+ r.enableMouse()
r.flush()
- } else if sigcont && !r.fullscreen && r.mouse {
+ } else if sigcont && !r.fullscreen {
// NOTE: SIGCONT (Coming back from CTRL-Z):
// It's highly likely that the offset we obtained at the beginning is
// no longer correct, so we simply disable mouse input.
- r.csi("?1000l")
- r.csi("?1002l")
- r.csi("?1006l")
- r.mouse = false
+ r.disableMouse()
}
}
@@ -678,11 +689,7 @@ func (r *LightRenderer) Close() {
} else if !r.fullscreen {
r.csi("u")
}
- if r.mouse {
- r.csi("?1000l")
- r.csi("?1002l")
- r.csi("?1006l")
- }
+ r.disableMouse()
r.flush()
r.closePlatform()
r.restoreTerminal()