More named keys: F5 ~ F10, ALT-/
This commit is contained in:
parent
70245ad98c
commit
c62fc5e75c
@ -80,9 +80,16 @@ const (
|
||||
F2
|
||||
F3
|
||||
F4
|
||||
F5
|
||||
F6
|
||||
F7
|
||||
F8
|
||||
F9
|
||||
F10
|
||||
|
||||
AltEnter
|
||||
AltSpace
|
||||
AltSlash
|
||||
AltBS
|
||||
AltA
|
||||
AltB
|
||||
@ -423,6 +430,8 @@ func escSequence(sz *int) Event {
|
||||
return Event{AltEnter, 0, nil}
|
||||
case 32:
|
||||
return Event{AltSpace, 0, nil}
|
||||
case 47:
|
||||
return Event{AltSlash, 0, nil}
|
||||
case 98:
|
||||
return Event{AltB, 0, nil}
|
||||
case 100:
|
||||
@ -468,6 +477,15 @@ func escSequence(sz *int) Event {
|
||||
*sz = 4
|
||||
switch _buf[2] {
|
||||
case 50:
|
||||
if len(_buf) == 5 && _buf[4] == 126 {
|
||||
*sz = 5
|
||||
switch _buf[3] {
|
||||
case 48:
|
||||
return Event{F9, 0, nil}
|
||||
case 49:
|
||||
return Event{F10, 0, nil}
|
||||
}
|
||||
}
|
||||
return Event{Invalid, 0, nil} // INS
|
||||
case 51:
|
||||
return Event{Del, 0, nil}
|
||||
@ -481,6 +499,21 @@ func escSequence(sz *int) Event {
|
||||
switch _buf[3] {
|
||||
case 126:
|
||||
return Event{Home, 0, nil}
|
||||
case 53, 55, 56, 57:
|
||||
if len(_buf) == 5 && _buf[4] == 126 {
|
||||
*sz = 5
|
||||
switch _buf[3] {
|
||||
case 53:
|
||||
return Event{F5, 0, nil}
|
||||
case 55:
|
||||
return Event{F6, 0, nil}
|
||||
case 56:
|
||||
return Event{F7, 0, nil}
|
||||
case 57:
|
||||
return Event{F8, 0, nil}
|
||||
}
|
||||
}
|
||||
return Event{Invalid, 0, nil}
|
||||
case 59:
|
||||
if len(_buf) != 6 {
|
||||
return Event{Invalid, 0, nil}
|
||||
|
@ -322,6 +322,8 @@ func parseKeyChords(str string, message string) map[int]string {
|
||||
chord = curses.AltEnter
|
||||
case "alt-space":
|
||||
chord = curses.AltSpace
|
||||
case "alt-/":
|
||||
chord = curses.AltSlash
|
||||
case "alt-bs", "alt-bspace":
|
||||
chord = curses.AltBS
|
||||
case "tab":
|
||||
@ -346,12 +348,14 @@ func parseKeyChords(str string, message string) map[int]string {
|
||||
chord = curses.SRight
|
||||
case "double-click":
|
||||
chord = curses.DoubleClick
|
||||
case "f10":
|
||||
chord = curses.F10
|
||||
default:
|
||||
if len(key) == 6 && strings.HasPrefix(lkey, "ctrl-") && isAlphabet(lkey[5]) {
|
||||
chord = curses.CtrlA + int(lkey[5]) - 'a'
|
||||
} else if len(key) == 5 && strings.HasPrefix(lkey, "alt-") && isAlphabet(lkey[4]) {
|
||||
chord = curses.AltA + int(lkey[4]) - 'a'
|
||||
} else if len(key) == 2 && strings.HasPrefix(lkey, "f") && key[1] >= '1' && key[1] <= '4' {
|
||||
} else if len(key) == 2 && strings.HasPrefix(lkey, "f") && key[1] >= '1' && key[1] <= '9' {
|
||||
chord = curses.F1 + int(key[1]) - '1'
|
||||
} else if utf8.RuneCountInString(key) == 1 {
|
||||
chord = curses.AltZ + int([]rune(key)[0])
|
||||
|
@ -430,6 +430,10 @@ class TestGoFZF < TestBase
|
||||
test.call 'f3', 'f3'
|
||||
test.call 'f2,f4', 'f2', 'f2'
|
||||
test.call 'f2,f4', 'f4', 'f4'
|
||||
test.call 'alt-/', [:Escape, :/]
|
||||
%w[f5 f6 f7 f8 f9 f10].each do |key|
|
||||
test.call 'f5,f6,f7,f8,f9,f10', key, key
|
||||
end
|
||||
test.call '@', '@'
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user