mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-29 00:51:35 +02:00
[gocui] Add PreviousX/PreviousY to ViewMouseBindingOpts
This is useful for detecting double-clicks.
This commit is contained in:
10
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
10
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
@ -95,6 +95,12 @@ type ViewMouseBinding struct {
|
|||||||
type ViewMouseBindingOpts struct {
|
type ViewMouseBindingOpts struct {
|
||||||
X int // i.e. origin x + cursor x
|
X int // i.e. origin x + cursor x
|
||||||
Y int // i.e. origin y + cursor y
|
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 {
|
type GuiMutexes struct {
|
||||||
@ -1378,6 +1384,8 @@ func (g *Gui) onKey(ev *GocuiEvent) error {
|
|||||||
newCx = lastCharForLine - v.ox
|
newCx = lastCharForLine - v.ox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
previousX := v.cx + v.ox
|
||||||
|
previousY := v.cy + v.oy
|
||||||
if !IsMouseScrollKey(ev.Key) {
|
if !IsMouseScrollKey(ev.Key) {
|
||||||
v.SetCursor(newCx, newCy)
|
v.SetCursor(newCx, newCy)
|
||||||
if v.Editable {
|
if v.Editable {
|
||||||
@ -1400,7 +1408,7 @@ func (g *Gui) onKey(ev *GocuiEvent) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if IsMouseKey(ev.Key) {
|
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)
|
matched, err := g.execMouseKeybindings(v, ev, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user