mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Auto-refresh on window activation (#2854)
This commit is contained in:
commit
c8520fbe78
14 changed files with 184 additions and 28 deletions
6
go.mod
6
go.mod
|
@ -17,7 +17,7 @@ require (
|
|||
github.com/integrii/flaggy v1.4.0
|
||||
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68
|
||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d
|
||||
github.com/jesseduffield/gocui v0.3.1-0.20230723014157-03e858e46144
|
||||
github.com/jesseduffield/gocui v0.3.1-0.20230802092815-ae0a5c181634
|
||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
||||
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
|
||||
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
|
||||
|
@ -25,7 +25,7 @@ require (
|
|||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
|
||||
github.com/kyokomi/emoji/v2 v2.2.8
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0
|
||||
github.com/mattn/go-runewidth v0.0.14
|
||||
github.com/mattn/go-runewidth v0.0.15
|
||||
github.com/mgutz/str v1.2.0
|
||||
github.com/pmezard/go-difflib v1.0.0
|
||||
github.com/sahilm/fuzzy v0.1.0
|
||||
|
@ -73,3 +73,5 @@ require (
|
|||
golang.org/x/text v0.11.0 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
)
|
||||
|
||||
replace github.com/gdamore/tcell/v2 v2.6.0 => github.com/stefanhaller/tcell/v2 v2.6.1
|
||||
|
|
16
go.sum
16
go.sum
|
@ -86,9 +86,6 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
|
|||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
||||
github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg=
|
||||
github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y=
|
||||
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
|
||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
|
||||
|
@ -183,8 +180,8 @@ github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8T
|
|||
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
|
||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE=
|
||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
|
||||
github.com/jesseduffield/gocui v0.3.1-0.20230723014157-03e858e46144 h1:gwy5JzP6+PhcPFG1obkUSLGcTkUY88sLKlCPOFjwtak=
|
||||
github.com/jesseduffield/gocui v0.3.1-0.20230723014157-03e858e46144/go.mod h1:dJ/BEUt3OWtaRg/PmuJWendRqREhre9JQ1SLvqrVJ8s=
|
||||
github.com/jesseduffield/gocui v0.3.1-0.20230802092815-ae0a5c181634 h1:tL9DS59Po4kw1fR+wFn0zUYQhrgxMskTatLcYQl7MMU=
|
||||
github.com/jesseduffield/gocui v0.3.1-0.20230802092815-ae0a5c181634/go.mod h1:pArPLsN1+S6jDrBDukTkpnH89rdhw44wzKdXFICGH3Q=
|
||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0=
|
||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo=
|
||||
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY=
|
||||
|
@ -216,7 +213,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
|
|||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/kyokomi/emoji/v2 v2.2.8 h1:jcofPxjHWEkJtkIbcLHvZhxKgCPl6C7MyjTrD4KDqUE=
|
||||
github.com/kyokomi/emoji/v2 v2.2.8/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
|
@ -228,9 +224,9 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
|
|||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mgutz/str v1.2.0 h1:4IzWSdIz9qPQWLfKZ0rJcV0jcUDpxvP4JVZ4GXQyvSw=
|
||||
github.com/mgutz/str v1.2.0/go.mod h1:w1v0ofgLaJdoD0HpQ3fycxKD1WtxpjSo151pK/31q6w=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
|
@ -252,7 +248,6 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77
|
|||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
|
@ -274,6 +269,8 @@ github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM=
|
|||
github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
|
||||
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad h1:fiWzISvDn0Csy5H0iwgAuJGQTUpVfEMJJd4nRFXogbc=
|
||||
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
|
||||
github.com/stefanhaller/tcell/v2 v2.6.1 h1:Qo4k5SOUc09q9xyA8juH4jFJy+neM9aQwJHgVO2/zBM=
|
||||
github.com/stefanhaller/tcell/v2 v2.6.1/go.mod h1:PuJ7T6QKbsU7iVOHlhRoV3D/ipIAJsyiV4dbwcVaYj8=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
|
||||
|
@ -458,7 +455,6 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c=
|
||||
|
|
|
@ -288,6 +288,15 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context
|
|||
return err
|
||||
}
|
||||
|
||||
gui.g.SetFocusHandler(func(Focused bool) error {
|
||||
if Focused {
|
||||
gui.c.Log.Info("Receiving focus - refreshing")
|
||||
return gui.helpers.Refresh.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
// if a context key has been given, push that instead, and set its index to 0
|
||||
if contextKey != context.NO_CONTEXT {
|
||||
contextToPush = gui.c.ContextForKey(contextKey)
|
||||
|
|
1
vendor/github.com/gdamore/tcell/v2/README.md
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/README.md
generated
vendored
|
@ -65,6 +65,7 @@ A brief, and still somewhat rough, [tutorial](TUTORIAL.md) is available.
|
|||
- [todo](https://github.com/kyprifog/todo) - simple todo app
|
||||
- [gosnakego](https://github.com/liweiyi88/gosnakego) - a snake game
|
||||
- [gbb](https://github.com/sdemingo/gbb) - A classical bulletin board app for tildes or public unix servers
|
||||
- [lil](https://github.com/andrievsky/lil) - A simple and flexible interface for any service by implementing only list and get operations
|
||||
|
||||
## Pure Go Terminfo Database
|
||||
|
||||
|
|
4
vendor/github.com/gdamore/tcell/v2/console_win.go
generated
vendored
4
vendor/github.com/gdamore/tcell/v2/console_win.go
generated
vendored
|
@ -282,6 +282,10 @@ func (s *cScreen) EnablePaste() {}
|
|||
|
||||
func (s *cScreen) DisablePaste() {}
|
||||
|
||||
func (s *cScreen) EnableFocus() {}
|
||||
|
||||
func (s *cScreen) DisableFocus() {}
|
||||
|
||||
func (s *cScreen) Fini() {
|
||||
s.disengage()
|
||||
}
|
||||
|
|
28
vendor/github.com/gdamore/tcell/v2/focus.go
generated
vendored
Normal file
28
vendor/github.com/gdamore/tcell/v2/focus.go
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2023 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
// You may obtain a copy of the license at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tcell
|
||||
|
||||
// EventFocus is a focus event. It is sent when the terminal window (or tab)
|
||||
// gets or loses focus.
|
||||
type EventFocus struct {
|
||||
*EventTime
|
||||
|
||||
// True if the window received focus, false if it lost focus
|
||||
Focused bool
|
||||
}
|
||||
|
||||
func NewEventFocus(focused bool) *EventFocus {
|
||||
return &EventFocus{Focused: focused}
|
||||
}
|
6
vendor/github.com/gdamore/tcell/v2/screen.go
generated
vendored
6
vendor/github.com/gdamore/tcell/v2/screen.go
generated
vendored
|
@ -139,6 +139,12 @@ type Screen interface {
|
|||
// DisablePaste disables bracketed paste mode.
|
||||
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
|
||||
// mouse. Note that the return value of true doesn't guarantee that
|
||||
// a mouse/pointing device is present; a false return definitely
|
||||
|
|
6
vendor/github.com/gdamore/tcell/v2/simulation.go
generated
vendored
6
vendor/github.com/gdamore/tcell/v2/simulation.go
generated
vendored
|
@ -325,6 +325,12 @@ func (s *simscreen) DisablePaste() {
|
|||
s.paste = false
|
||||
}
|
||||
|
||||
func (s *simscreen) EnableFocus() {
|
||||
}
|
||||
|
||||
func (s *simscreen) DisableFocus() {
|
||||
}
|
||||
|
||||
func (s *simscreen) Size() (int, int) {
|
||||
s.Lock()
|
||||
w, h := s.back.Size()
|
||||
|
|
2
vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go
generated
vendored
2
vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go
generated
vendored
|
@ -230,6 +230,8 @@ type Terminfo struct {
|
|||
EnterUrl string
|
||||
ExitUrl string
|
||||
SetWindowSize string
|
||||
EnableFocusReporting string
|
||||
DisableFocusReporting string
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
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()
|
||||
}
|
||||
|
|
4
vendor/github.com/jesseduffield/gocui/edit.go
generated
vendored
4
vendor/github.com/jesseduffield/gocui/edit.go
generated
vendored
|
@ -63,9 +63,7 @@ func SimpleEditor(v *View, key Key, ch rune, mod Modifier) bool {
|
|||
v.TextArea.BackSpaceWord()
|
||||
case key == KeyCtrlY:
|
||||
v.TextArea.Yank()
|
||||
|
||||
// TODO: see if we need all three of these conditions: maybe the final one is sufficient
|
||||
case ch != 0 && mod == 0 && unicode.IsPrint(ch):
|
||||
case unicode.IsPrint(ch):
|
||||
v.TextArea.TypeRune(ch)
|
||||
default:
|
||||
return false
|
||||
|
|
17
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
17
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
|
@ -128,6 +128,7 @@ type Gui struct {
|
|||
currentView *View
|
||||
managers []Manager
|
||||
keybindings []*keybinding
|
||||
focusHandler func(bool) error
|
||||
maxX, maxY int
|
||||
outputMode OutputMode
|
||||
stop chan struct{}
|
||||
|
@ -603,6 +604,10 @@ func (g *Gui) WhitelistKeybinding(k Key) error {
|
|||
return ErrNotBlacklisted
|
||||
}
|
||||
|
||||
func (g *Gui) SetFocusHandler(handler func(bool) error) {
|
||||
g.focusHandler = handler
|
||||
}
|
||||
|
||||
// getKey takes an empty interface with a key and returns the corresponding
|
||||
// typed Key or rune.
|
||||
func getKey(key interface{}) (Key, rune, error) {
|
||||
|
@ -728,6 +733,8 @@ func (g *Gui) MainLoop() error {
|
|||
Screen.EnableMouse()
|
||||
}
|
||||
|
||||
Screen.EnableFocus()
|
||||
|
||||
for {
|
||||
err := g.processEvent()
|
||||
if err != nil {
|
||||
|
@ -794,6 +801,8 @@ func (g *Gui) handleEvent(ev *GocuiEvent) error {
|
|||
case eventResize:
|
||||
g.onResize()
|
||||
return nil
|
||||
case eventFocus:
|
||||
return g.onFocus(ev)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
@ -1418,6 +1427,14 @@ func (g *Gui) execKeybinding(v *View, kb *keybinding) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func (g *Gui) onFocus(ev *GocuiEvent) error {
|
||||
if g.focusHandler != nil {
|
||||
return g.focusHandler(ev.Focused)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Gui) StartTicking(ctx context.Context) {
|
||||
go func() {
|
||||
g.Mutexes.tickingMutex.Lock()
|
||||
|
|
28
vendor/github.com/jesseduffield/gocui/tcell_driver.go
generated
vendored
28
vendor/github.com/jesseduffield/gocui/tcell_driver.go
generated
vendored
|
@ -154,18 +154,20 @@ type gocuiEventType uint8
|
|||
// The 'Mod', 'Key' and 'Ch' fields are valid if 'Type' is 'eventKey'.
|
||||
// The 'MouseX' and 'MouseY' fields are valid if 'Type' is 'eventMouse'.
|
||||
// The 'Width' and 'Height' fields are valid if 'Type' is 'eventResize'.
|
||||
// The 'Focused' field is valid if 'Type' is 'eventFocus'.
|
||||
// The 'Err' field is valid if 'Type' is 'eventError'.
|
||||
type GocuiEvent struct {
|
||||
Type gocuiEventType
|
||||
Mod Modifier
|
||||
Key Key
|
||||
Ch rune
|
||||
Width int
|
||||
Height int
|
||||
Err error
|
||||
MouseX int
|
||||
MouseY int
|
||||
N int
|
||||
Type gocuiEventType
|
||||
Mod Modifier
|
||||
Key Key
|
||||
Ch rune
|
||||
Width int
|
||||
Height int
|
||||
Err error
|
||||
MouseX int
|
||||
MouseY int
|
||||
Focused bool
|
||||
N int
|
||||
}
|
||||
|
||||
// Event types.
|
||||
|
@ -174,6 +176,7 @@ const (
|
|||
eventKey
|
||||
eventResize
|
||||
eventMouse
|
||||
eventFocus
|
||||
eventInterrupt
|
||||
eventError
|
||||
eventRaw
|
||||
|
@ -368,6 +371,11 @@ func (g *Gui) pollEvent() GocuiEvent {
|
|||
Ch: 0,
|
||||
Mod: mouseMod,
|
||||
}
|
||||
case *tcell.EventFocus:
|
||||
return GocuiEvent{
|
||||
Type: eventFocus,
|
||||
Focused: tev.Focused,
|
||||
}
|
||||
default:
|
||||
return GocuiEvent{Type: eventNone}
|
||||
}
|
||||
|
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
|
@ -36,7 +36,7 @@ github.com/fsnotify/fsnotify
|
|||
# github.com/gdamore/encoding v1.0.0
|
||||
## explicit; go 1.9
|
||||
github.com/gdamore/encoding
|
||||
# github.com/gdamore/tcell/v2 v2.6.0
|
||||
# github.com/gdamore/tcell/v2 v2.6.0 => github.com/stefanhaller/tcell/v2 v2.6.1
|
||||
## explicit; go 1.12
|
||||
github.com/gdamore/tcell/v2
|
||||
github.com/gdamore/tcell/v2/terminfo
|
||||
|
@ -168,7 +168,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
|
|||
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
|
||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
|
||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
|
||||
# github.com/jesseduffield/gocui v0.3.1-0.20230723014157-03e858e46144
|
||||
# github.com/jesseduffield/gocui v0.3.1-0.20230802092815-ae0a5c181634
|
||||
## explicit; go 1.12
|
||||
github.com/jesseduffield/gocui
|
||||
# github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
||||
|
@ -210,7 +210,7 @@ github.com/mattn/go-colorable
|
|||
# github.com/mattn/go-isatty v0.0.14
|
||||
## explicit; go 1.12
|
||||
github.com/mattn/go-isatty
|
||||
# github.com/mattn/go-runewidth v0.0.14
|
||||
# github.com/mattn/go-runewidth v0.0.15
|
||||
## explicit; go 1.9
|
||||
github.com/mattn/go-runewidth
|
||||
# github.com/mgutz/str v1.2.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue