Minor refactoring

This commit is contained in:
Junegunn Choi 2015-05-22 00:02:14 +09:00
parent 8f99f8fcc6
commit 4e0e492427

View File

@ -295,17 +295,20 @@ func parseTheme(str string) *curses.ColorTheme {
func parseKeymap(keymap map[int]actionType, toggleSort bool, str string) (map[int]actionType, bool) { func parseKeymap(keymap map[int]actionType, toggleSort bool, str string) (map[int]actionType, bool) {
for _, pairStr := range strings.Split(str, ",") { for _, pairStr := range strings.Split(str, ",") {
fail := func() {
errorExit("invalid key binding: " + pairStr)
}
pair := strings.Split(pairStr, ":") pair := strings.Split(pairStr, ":")
if len(pair) != 2 { if len(pair) != 2 {
errorExit("invalid key binding: " + pairStr) fail()
} }
keys := parseKeyChords(pair[0], "key name required") keys := parseKeyChords(pair[0], "key name required")
if len(keys) != 1 { if len(keys) != 1 {
errorExit("invalid key binding: " + pairStr) fail()
} }
key := keys[0] key := keys[0]
act := strings.ToLower(pair[1]) act := strings.ToLower(pair[1])
switch strings.ToLower(pair[1]) { switch act {
case "beginning-of-line": case "beginning-of-line":
keymap[key] = actBeginningOfLine keymap[key] = actBeginningOfLine
case "abort": case "abort":