public static Dictionary <string, MacrosExecutor.Action> GetSpecials() { if (specials == null) { specials = new Dictionary <string, MacrosExecutor.Action>(); specials["space"] = new MacrosExecutor.Action(' '); specials["escape"] = new MacrosExecutor.Action(Keys.Escape); specials["cr"] = new MacrosExecutor.Action(Keys.Enter); specials["bs"] = new MacrosExecutor.Action(Keys.Back); specials["del"] = new MacrosExecutor.Action(Keys.Delete); specials["tab"] = new MacrosExecutor.Action(Keys.Tab); specials["f1"] = new MacrosExecutor.Action(Keys.F1); specials["f2"] = new MacrosExecutor.Action(Keys.F2); specials["f3"] = new MacrosExecutor.Action(Keys.F3); specials["f4"] = new MacrosExecutor.Action(Keys.F4); specials["f5"] = new MacrosExecutor.Action(Keys.F5); specials["f6"] = new MacrosExecutor.Action(Keys.F6); specials["f7"] = new MacrosExecutor.Action(Keys.F7); specials["f8"] = new MacrosExecutor.Action(Keys.F8); specials["f9"] = new MacrosExecutor.Action(Keys.F9); specials["f11"] = new MacrosExecutor.Action(Keys.F11); specials["f12"] = new MacrosExecutor.Action(Keys.F12); specials["leader"] = new MacrosExecutor.Action('\\'); specials["lt"] = new MacrosExecutor.Action('<'); specials["gt"] = new MacrosExecutor.Action('>'); specials["bra"] = new MacrosExecutor.Action('['); specials["ket"] = new MacrosExecutor.Action(']'); } return(specials); }
private string StringOf(MacrosExecutor.Action action) { string text = ""; if (action.code != '\0') { text += action.code; } if (action.keys != Keys.None) { text += "(" + action.keys + ")"; } return(text); }
private static MacrosExecutor.Action GetSpecial(string specialText, StringBuilder errors) { string lowerText = specialText.ToLowerInvariant(); MacrosExecutor.Action action; if (GetSpecials().TryGetValue(lowerText, out action)) { return(action); } if ((lowerText.StartsWith("c-s-") || lowerText.StartsWith("s-c-")) && specialText.Length >= 5) { action = new MacrosExecutor.Action(); action.keys = Keys.Control | Keys.Shift; if (specialText.Length == 5) { char c = specialText[4]; Keys charKey = GetKey(c); if (charKey != Keys.None) { action.keys |= charKey; } else { if (GetSpecials().TryGetValue(lowerText.Substring(4), out action)) { action.keys |= Keys.Control | Keys.Shift; return(action); } errors.Append("Unsupported control: " + c); } return(action); } if (GetSpecials().TryGetValue(lowerText.Substring(4), out action)) { action.keys |= Keys.Control | Keys.Shift; return(action); } } if ((lowerText.StartsWith("c-") || lowerText.StartsWith("s-")) && specialText.Length >= 3) { action = new MacrosExecutor.Action(); action.keys = lowerText[0] == 'c' ? Keys.Control : Keys.Shift; if (specialText.Length == 3) { char c = specialText[2]; Keys charKey = GetKey(c); if (charKey != Keys.None) { action.keys |= charKey; } else { errors.Append("Unsupported control: " + c); } return(action); } if (GetSpecials().TryGetValue(lowerText.Substring(2), out action)) { action.keys |= lowerText[0] == 'c' ? Keys.Control : Keys.Shift; return(action); } } errors.Append("Unexpected: [" + specialText + "]"); return(new MacrosExecutor.Action()); }