mirror of https://github.com/gdamore/tcell.git
Enable focus reporting only for terminals that support it
We assume that any terminal that supports mouse reporting will also support focus reporting; but we also add an entry to Terminfo to let specific terminals override it if needed.
This commit is contained in:
parent
85dc29bf8a
commit
622b6c2aa7
|
@ -230,6 +230,8 @@ type Terminfo struct {
|
|||
EnterUrl string
|
||||
ExitUrl string
|
||||
SetWindowSize string
|
||||
EnableFocusReporting string
|
||||
DisableFocusReporting string
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
21
tscreen.go
21
tscreen.go
|
@ -153,6 +153,8 @@ type tScreen struct {
|
|||
enterUrl string
|
||||
exitUrl string
|
||||
setWinSize string
|
||||
enableFocus string
|
||||
disableFocus string
|
||||
cursorStyles map[CursorStyle]string
|
||||
cursorStyle CursorStyle
|
||||
saved *term.State
|
||||
|
@ -366,6 +368,17 @@ func (t *tScreen) prepareExtendedOSC() {
|
|||
} else if t.ti.Mouse != "" {
|
||||
t.setWinSize = "\x1b[8;%p1%p2%d;%dt"
|
||||
}
|
||||
|
||||
if t.ti.EnableFocusReporting != "" {
|
||||
t.enableFocus = t.ti.EnableFocusReporting
|
||||
} else if t.ti.Mouse != "" {
|
||||
t.enableFocus = "\x1b[?1004h"
|
||||
}
|
||||
if t.ti.DisableFocusReporting != "" {
|
||||
t.disableFocus = t.ti.DisableFocusReporting
|
||||
} else if t.ti.Mouse != "" {
|
||||
t.disableFocus = "\x1b[?1004l"
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tScreen) prepareCursorStyles() {
|
||||
|
@ -1044,11 +1057,15 @@ func (t *tScreen) enablePasting(on bool) {
|
|||
}
|
||||
|
||||
func (t *tScreen) enableFocusReporting() {
|
||||
t.TPuts("\x1b[?1004h")
|
||||
if t.enableFocus != "" {
|
||||
t.TPuts(t.enableFocus)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tScreen) disableFocusReporting() {
|
||||
t.TPuts("\x1b[?1004l")
|
||||
if t.disableFocus != "" {
|
||||
t.TPuts(t.disableFocus)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tScreen) Size() (int, int) {
|
||||
|
|
Loading…
Reference in New Issue