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