mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
Point tcell at stefanhaller's fork
This is temporary as long as https://github.com/gdamore/tcell/pull/599 is not merged. Once that PR is merged, we can revert this.
This commit is contained in:
79
vendor/github.com/gdamore/tcell/v2/tscreen.go
generated
vendored
79
vendor/github.com/gdamore/tcell/v2/tscreen.go
generated
vendored
@ -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
|
||||
@ -161,6 +163,7 @@ type tScreen struct {
|
||||
wg sync.WaitGroup
|
||||
mouseFlags MouseFlags
|
||||
pasteEnabled bool
|
||||
focusEnabled bool
|
||||
|
||||
sync.Mutex
|
||||
}
|
||||
@ -366,6 +369,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() {
|
||||
@ -1043,6 +1057,32 @@ 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() {
|
||||
if t.enableFocus != "" {
|
||||
t.TPuts(t.enableFocus)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tScreen) disableFocusReporting() {
|
||||
if t.disableFocus != "" {
|
||||
t.TPuts(t.disableFocus)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tScreen) Size() (int, int) {
|
||||
t.Lock()
|
||||
w, h := t.w, t.h
|
||||
@ -1380,6 +1420,35 @@ func (t *tScreen) parseSgrMouse(buf *bytes.Buffer, evs *[]Event) (bool, bool) {
|
||||
return true, false
|
||||
}
|
||||
|
||||
func (t *tScreen) parseFocus(buf *bytes.Buffer, evs *[]Event) (bool, bool) {
|
||||
state := 0
|
||||
b := buf.Bytes()
|
||||
for i := range b {
|
||||
switch state {
|
||||
case 0:
|
||||
if b[i] != '\x1b' {
|
||||
return false, false
|
||||
}
|
||||
state = 1
|
||||
case 1:
|
||||
if b[i] != '[' {
|
||||
return false, false
|
||||
}
|
||||
state = 2
|
||||
case 2:
|
||||
if b[i] != 'I' && b[i] != 'O' {
|
||||
return false, false
|
||||
}
|
||||
*evs = append(*evs, NewEventFocus(b[i] == 'I'))
|
||||
_, _ = buf.ReadByte()
|
||||
_, _ = buf.ReadByte()
|
||||
_, _ = buf.ReadByte()
|
||||
return true, true
|
||||
}
|
||||
}
|
||||
return true, false
|
||||
}
|
||||
|
||||
// parseXtermMouse is like parseSgrMouse, but it parses a legacy
|
||||
// X11 mouse record.
|
||||
func (t *tScreen) parseXtermMouse(buf *bytes.Buffer, evs *[]Event) (bool, bool) {
|
||||
@ -1556,6 +1625,12 @@ func (t *tScreen) collectEventsFromInput(buf *bytes.Buffer, expire bool) []Event
|
||||
partials++
|
||||
}
|
||||
|
||||
if part, comp := t.parseFocus(buf, &res); comp {
|
||||
continue
|
||||
} else if part {
|
||||
partials++
|
||||
}
|
||||
|
||||
// Only parse mouse records if this term claims to have
|
||||
// mouse support
|
||||
|
||||
@ -1804,6 +1879,9 @@ func (t *tScreen) engage() error {
|
||||
t.stopQ = stopQ
|
||||
t.enableMouse(t.mouseFlags)
|
||||
t.enablePasting(t.pasteEnabled)
|
||||
if t.focusEnabled {
|
||||
t.enableFocusReporting()
|
||||
}
|
||||
|
||||
ti := t.ti
|
||||
t.TPuts(ti.EnterCA)
|
||||
@ -1853,6 +1931,7 @@ func (t *tScreen) disengage() {
|
||||
t.TPuts(ti.ExitKeypad)
|
||||
t.enableMouse(0)
|
||||
t.enablePasting(false)
|
||||
t.disableFocusReporting()
|
||||
|
||||
_ = t.tty.Stop()
|
||||
}
|
||||
|
Reference in New Issue
Block a user