(keymap map[tui.Event][]*action, str string)
| 2012 | } |
| 2013 | |
| 2014 | func parseKeymap(keymap map[tui.Event][]*action, str string) error { |
| 2015 | var err error |
| 2016 | masked := maskActionContents(str) |
| 2017 | idx := 0 |
| 2018 | keys := []string{} |
| 2019 | for _, pairStr := range strings.Split(masked, ",") { |
| 2020 | origPairStr := str[idx : idx+len(pairStr)] |
| 2021 | idx += len(pairStr) + 1 |
| 2022 | |
| 2023 | pair := strings.SplitN(pairStr, ":", 2) |
| 2024 | if len(pair[0]) == 0 { |
| 2025 | return errors.New("key name required") |
| 2026 | } |
| 2027 | keys = append(keys, pair[0]) |
| 2028 | if len(pair) < 2 { |
| 2029 | continue |
| 2030 | } |
| 2031 | for _, keyName := range keys { |
| 2032 | var key tui.Event |
| 2033 | if len(keyName) == 1 && keyName[0] == escapedColon { |
| 2034 | key = tui.Key(':') |
| 2035 | } else if len(keyName) == 1 && keyName[0] == escapedComma { |
| 2036 | key = tui.Key(',') |
| 2037 | } else if len(keyName) == 1 && keyName[0] == escapedPlus { |
| 2038 | key = tui.Key('+') |
| 2039 | } else { |
| 2040 | keys, _, err := parseKeyChords(keyName, "key name required") |
| 2041 | if err != nil { |
| 2042 | return err |
| 2043 | } |
| 2044 | key = firstKey(keys) |
| 2045 | } |
| 2046 | putAllowed := key.Type == tui.Rune && unicode.IsGraphic(key.Char) |
| 2047 | keymap[key], err = parseActionList(pair[1], origPairStr[len(pair[0])+1:], keymap[key], putAllowed) |
| 2048 | if err != nil { |
| 2049 | return err |
| 2050 | } |
| 2051 | } |
| 2052 | keys = keys[:0] |
| 2053 | } |
| 2054 | if len(keys) > 0 { |
| 2055 | return errors.New("bind action not specified: " + strings.Join(keys, ", ")) |
| 2056 | } |
| 2057 | return nil |
| 2058 | } |
| 2059 | |
| 2060 | func isExecuteAction(str string) actionType { |
| 2061 | masked := maskActionContents(":" + str)[1:] |
searching dependent graphs…