mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-03 13:42:11 -07:00
Add bindable double-click event (#374)
This commit is contained in:
@@ -50,6 +50,7 @@ const (
|
|||||||
|
|
||||||
Invalid
|
Invalid
|
||||||
Mouse
|
Mouse
|
||||||
|
DoubleClick
|
||||||
|
|
||||||
BTab
|
BTab
|
||||||
BSpace
|
BSpace
|
||||||
|
@@ -343,6 +343,8 @@ func parseKeyChords(str string, message string) map[int]string {
|
|||||||
chord = curses.SLeft
|
chord = curses.SLeft
|
||||||
case "shift-right":
|
case "shift-right":
|
||||||
chord = curses.SRight
|
chord = curses.SRight
|
||||||
|
case "double-click":
|
||||||
|
chord = curses.DoubleClick
|
||||||
default:
|
default:
|
||||||
if len(key) == 6 && strings.HasPrefix(lkey, "ctrl-") && isAlphabet(lkey[5]) {
|
if len(key) == 6 && strings.HasPrefix(lkey, "ctrl-") && isAlphabet(lkey[5]) {
|
||||||
chord = curses.CtrlA + int(lkey[5]) - 'a'
|
chord = curses.CtrlA + int(lkey[5]) - 'a'
|
||||||
|
@@ -180,6 +180,7 @@ func defaultKeymap() map[int]actionType {
|
|||||||
|
|
||||||
keymap[C.Rune] = actRune
|
keymap[C.Rune] = actRune
|
||||||
keymap[C.Mouse] = actMouse
|
keymap[C.Mouse] = actMouse
|
||||||
|
keymap[C.DoubleClick] = actAccept
|
||||||
return keymap
|
return keymap
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,6 +859,8 @@ func (t *Terminal) Loop() {
|
|||||||
action = act
|
action = act
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var doAction func(actionType) bool
|
||||||
|
doAction = func(action actionType) bool {
|
||||||
switch action {
|
switch action {
|
||||||
case actIgnore:
|
case actIgnore:
|
||||||
case actExecute:
|
case actExecute:
|
||||||
@@ -867,12 +870,12 @@ func (t *Terminal) Loop() {
|
|||||||
}
|
}
|
||||||
case actInvalid:
|
case actInvalid:
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
continue
|
return false
|
||||||
case actToggleSort:
|
case actToggleSort:
|
||||||
t.sort = !t.sort
|
t.sort = !t.sort
|
||||||
t.eventBox.Set(EvtSearchNew, t.sort)
|
t.eventBox.Set(EvtSearchNew, t.sort)
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
continue
|
return false
|
||||||
case actBeginningOfLine:
|
case actBeginningOfLine:
|
||||||
t.cx = 0
|
t.cx = 0
|
||||||
case actBackwardChar:
|
case actBackwardChar:
|
||||||
@@ -1040,7 +1043,7 @@ func (t *Terminal) Loop() {
|
|||||||
// Double-click
|
// Double-click
|
||||||
if my >= min {
|
if my >= min {
|
||||||
if t.vset(t.offset+my-min) && t.cy < t.merger.Length() {
|
if t.vset(t.offset+my-min) && t.cy < t.merger.Length() {
|
||||||
req(reqClose)
|
return doAction(t.keymap[C.DoubleClick])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if me.Down {
|
} else if me.Down {
|
||||||
@@ -1057,6 +1060,11 @@ func (t *Terminal) Loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if !doAction(action) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
changed := string(previousInput) != string(t.input)
|
changed := string(previousInput) != string(t.input)
|
||||||
t.mutex.Unlock() // Must be unlocked before touching reqBox
|
t.mutex.Unlock() // Must be unlocked before touching reqBox
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user