public void SetSymbolShortcut(KalkShortcut shortcut) { if (shortcut == null) { throw new ArgumentNullException(nameof(shortcut)); } RemoveShortcut(shortcut.Name); Add(shortcut.Name, shortcut); foreach (KalkShortcutKeySequence shortcutKey in shortcut.Keys) { var map = ShortcutKeyMap; KalkConsoleKey consoleKey = default; for (int i = 0; i < shortcutKey.Keys.Count; i++) { if (i > 0) { if (!map.TryGetShortcut(consoleKey, out var newMap) || !(newMap is KalkShortcutKeyMap)) { newMap = new KalkShortcutKeyMap(); map[consoleKey] = newMap; } map = (KalkShortcutKeyMap)newMap; } consoleKey = shortcutKey.Keys[i]; } map[consoleKey] = shortcutKey.Expression; } }
public bool TryGetValue(string key, out KalkShortcut value) { value = null; if (TryGetValue(null, new SourceSpan(), key, out var valueObj)) { value = (KalkShortcut)valueObj; return(true); } return(false); }