mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
[gocui] Add PreviousX/PreviousY to ViewMouseBindingOpts
This is useful for detecting double-clicks.
This commit is contained in:
parent
153d0558b4
commit
5f149e2d07
1 changed files with 9 additions and 1 deletions
10
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
10
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
|
@ -92,6 +92,12 @@ type ViewMouseBinding struct {
|
|||
type ViewMouseBindingOpts struct {
|
||||
X int // i.e. origin x + cursor x
|
||||
Y int // i.e. origin y + cursor y
|
||||
|
||||
// the previous cursor right before the click; useful because by the time
|
||||
// the event is dispatched to handlers, gocui has already set the cursor to
|
||||
// the new position. This is useful for detecting double clicks.
|
||||
PreviousX int
|
||||
PreviousY int
|
||||
}
|
||||
|
||||
type GuiMutexes struct {
|
||||
|
@ -1375,6 +1381,8 @@ func (g *Gui) onKey(ev *GocuiEvent) error {
|
|||
newCx = lastCharForLine - v.ox
|
||||
}
|
||||
}
|
||||
previousX := v.cx + v.ox
|
||||
previousY := v.cy + v.oy
|
||||
if !IsMouseScrollKey(ev.Key) {
|
||||
v.SetCursor(newCx, newCy)
|
||||
if v.Editable {
|
||||
|
@ -1397,7 +1405,7 @@ func (g *Gui) onKey(ev *GocuiEvent) error {
|
|||
}
|
||||
|
||||
if IsMouseKey(ev.Key) {
|
||||
opts := ViewMouseBindingOpts{X: newX, Y: newY}
|
||||
opts := ViewMouseBindingOpts{X: newX, Y: newY, PreviousX: previousX, PreviousY: previousY}
|
||||
matched, err := g.execMouseKeybindings(v, ev, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue