mirror of https://github.com/gdamore/tcell.git
Make focus reporting an opt-in feature, like mouse reporting
This commit is contained in:
parent
622b6c2aa7
commit
f028121cb8
|
@ -129,6 +129,7 @@ func main() {
|
||||||
s.SetStyle(defStyle)
|
s.SetStyle(defStyle)
|
||||||
s.EnableMouse()
|
s.EnableMouse()
|
||||||
s.EnablePaste()
|
s.EnablePaste()
|
||||||
|
s.EnableFocus()
|
||||||
s.Clear()
|
s.Clear()
|
||||||
|
|
||||||
posfmt := "Mouse: %d, %d "
|
posfmt := "Mouse: %d, %d "
|
||||||
|
|
|
@ -139,6 +139,12 @@ type Screen interface {
|
||||||
// DisablePaste disables bracketed paste mode.
|
// DisablePaste disables bracketed paste mode.
|
||||||
DisablePaste()
|
DisablePaste()
|
||||||
|
|
||||||
|
// EnableFocus enables reporting of focus events, if your terminal supports it.
|
||||||
|
EnableFocus()
|
||||||
|
|
||||||
|
// DisableFocus disables reporting of focus events.
|
||||||
|
DisableFocus()
|
||||||
|
|
||||||
// HasMouse returns true if the terminal (apparently) supports a
|
// HasMouse returns true if the terminal (apparently) supports a
|
||||||
// mouse. Note that the return value of true doesn't guarantee that
|
// mouse. Note that the return value of true doesn't guarantee that
|
||||||
// a mouse/pointing device is present; a false return definitely
|
// a mouse/pointing device is present; a false return definitely
|
||||||
|
|
|
@ -325,6 +325,12 @@ func (s *simscreen) DisablePaste() {
|
||||||
s.paste = false
|
s.paste = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *simscreen) EnableFocus() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *simscreen) DisableFocus() {
|
||||||
|
}
|
||||||
|
|
||||||
func (s *simscreen) Size() (int, int) {
|
func (s *simscreen) Size() (int, int) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
w, h := s.back.Size()
|
w, h := s.back.Size()
|
||||||
|
|
19
tscreen.go
19
tscreen.go
|
@ -163,6 +163,7 @@ type tScreen struct {
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
mouseFlags MouseFlags
|
mouseFlags MouseFlags
|
||||||
pasteEnabled bool
|
pasteEnabled bool
|
||||||
|
focusEnabled bool
|
||||||
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
@ -1056,6 +1057,20 @@ func (t *tScreen) enablePasting(on bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *tScreen) EnableFocus() {
|
||||||
|
t.Lock()
|
||||||
|
t.focusEnabled = true
|
||||||
|
t.enableFocusReporting()
|
||||||
|
t.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *tScreen) DisableFocus() {
|
||||||
|
t.Lock()
|
||||||
|
t.focusEnabled = false
|
||||||
|
t.disableFocusReporting()
|
||||||
|
t.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (t *tScreen) enableFocusReporting() {
|
func (t *tScreen) enableFocusReporting() {
|
||||||
if t.enableFocus != "" {
|
if t.enableFocus != "" {
|
||||||
t.TPuts(t.enableFocus)
|
t.TPuts(t.enableFocus)
|
||||||
|
@ -1866,7 +1881,9 @@ func (t *tScreen) engage() error {
|
||||||
t.stopQ = stopQ
|
t.stopQ = stopQ
|
||||||
t.enableMouse(t.mouseFlags)
|
t.enableMouse(t.mouseFlags)
|
||||||
t.enablePasting(t.pasteEnabled)
|
t.enablePasting(t.pasteEnabled)
|
||||||
t.enableFocusReporting()
|
if t.focusEnabled {
|
||||||
|
t.enableFocusReporting()
|
||||||
|
}
|
||||||
|
|
||||||
ti := t.ti
|
ti := t.ti
|
||||||
t.TPuts(ti.EnterCA)
|
t.TPuts(ti.EnterCA)
|
||||||
|
|
Loading…
Reference in New Issue