public static IList <string> ListAliasesConfig() { return(Collection.Map(CRegistery.ListAliases(), delegate(CAliasCommand alias) { return ToString(alias); })); }
bool Execute(string prefix = null) { IList <CAliasCommand> cmds = CRegistery.ListAliases(prefix); if (cmds.Count > 0) { if (shortList) { string[] names = Collection.Map(cmds, delegate(CAliasCommand cmd) { return(cmd.Name); }); Print(names); } else { foreach (CAliasCommand cmd in cmds) { PrintIndent("{0} {1}", cmd.Name, cmd.Alias); } } } return(true); }
private bool TryExecuteSingleCommand(string commandLine, bool manualMode = false) { IList <string> tokensList = CommandTokenizer.Tokenize(commandLine); if (tokensList.Count > 0) { string commandName = tokensList[0]; CCommand command = CRegistery.FindCommand(commandName); if (command != null) { command.Delegate = m_delegate; command.IsManualMode = manualMode; command.CommandString = commandLine; bool succeed = command.ExecuteTokens(tokensList, commandLine); command.Clear(); return(succeed); } if (manualMode) { m_delegate.LogTerminal(StringUtils.C(commandName + ": command not found", ColorCode.ErrorUnknownCommand)); } } return(false); }
public static void ListAliasesConfig(IList <string> lines) { IList <CAliasCommand> aliases = CRegistery.ListAliases(); for (int i = 0; i < aliases.Count; ++i) { lines.Add(ToString(aliases[i])); } }
void Execute(string name, string commands) { CRegistery.AddAlias(name, StringUtils.UnArg(commands)); PostNotification( CCommandNotifications.CAliasesChanged, CCommandNotifications.KeyName, name, CCommandNotifications.KeyManualMode, this.IsManualMode ); }
void Execute(string name) { if (CRegistery.RemoveAlias(name)) { PostNotification( CCommandNotifications.CAliasesChanged, CCommandNotifications.KeyName, name, CCommandNotifications.KeyManualMode, this.IsManualMode ); } }
private string[] ListCommandNames(string prefix, CommandListOptions options) { IList <CCommand> commands = CRegistery.ListCommands(delegate(CCommand cmd) { return(!(cmd is CVarCommand) && CRegistery.ShouldListCommand(cmd, prefix, options)); }); return(Collection.Map(commands, delegate(CCommand cmd) { return C(cmd.Name, cmd.ColorCode); })); }
internal static IList <string> AutoCompleteArgs(string token) { IList <CAliasCommand> aliases = CRegistery.ListAliases(); if (aliases != null && aliases.Count > 0) { return(Collection.Map(aliases, delegate(CAliasCommand alias) { return alias.Name; })); } return(null); }
internal static IList <string> AutoCompleteArgs(string prefix) { IList <CVar> vars = CRegistery.ListVars(prefix, CCommand.DefaultListOptions); if (vars.Count == 0) { return(null); } return(Collection.Map(vars, delegate(CVar cvar) { return StringUtils.C(cvar.Name, ColorCode.TableVar); })); }
void Execute(string prefix = null) { IList <CCommand> cmds = CRegistery.ListCommands(prefix); foreach (CCommand cmd in cmds) { CVarCommand cvarCmd = cmd as CVarCommand; if (cvarCmd != null) { cvarCmd.ParentCommand = this; cvarCmd.SetDefault(); cvarCmd.ParentCommand = null; } } }
bool Execute(string command) { CCommand cmd = CRegistery.FindCommand(command); if (cmd == null) { PrintError("{0}: command not found \"{1}\"", this.Name, command); return(false); } cmd.Delegate = this.Delegate; cmd.PrintUsage(true); cmd.Delegate = null; return(true); }
protected override IList <string> AutoCompleteArgs(string commandLine, string prefix) { IList <CVar> vars = CRegistery.ListVars(delegate(CVarCommand cmd) { return(cmd.IsBool && CRegistery.ShouldListCommand(cmd, prefix, CCommand.DefaultListOptions)); }); if (vars.Count == 0) { return(null); } return(Collection.Map(vars, delegate(CVar cvar) { return StringUtils.C(cvar.Name, ColorCode.TableVar); })); }
bool Execute(string name) { CVarCommand cmd = CRegistery.FindCvarCommand(name); if (cmd == null) { PrintError("Can't find cvar: '{0}'", name); return(false); } cmd.ParentCommand = this; cmd.SetDefault(); cmd.ParentCommand = null; return(true); }
bool Execute(string prefix = null) { CommandListOptions options = CCommand.DefaultListOptions; if (includeSystem) { options |= CommandListOptions.System; } // TODO: refactoring IList <CVar> vars = CRegistery.ListVars(prefix, options); if (vars.Count > 0) { if (shortList) { string[] names = Collection.Map(vars, delegate(CVar cvar) { return(StringUtils.C(cvar.Name, ColorCode.TableVar)); }); Print(names); } else { StringBuilder result = new StringBuilder(); for (int i = 0; i < vars.Count; ++i) { CVar cvar = vars[i]; result.AppendFormat(" {0} {1}", StringUtils.C(cvar.Name, ColorCode.TableVar), StringUtils.Arg(cvar.Value)); // TODO: better color highlight if (!cvar.IsDefault) { result.AppendFormat(" {0} {1}", StringUtils.C("default", ColorCode.TableVar), cvar.DefaultValue); } if (i < vars.Count - 1) { result.Append('\n'); } } Print(result.ToString()); } } return(true); }
void Execute(string prefix = null) { IList <CAliasCommand> aliases = CRegistery.ListAliases(prefix); if (aliases.Count > 0) { foreach (CAliasCommand alias in aliases) { CRegistery.RemoveAlias(alias.Name); } PostNotification( CCommandNotifications.CAliasesChanged, CCommandNotifications.KeyManualMode, this.IsManualMode ); } }
private CVar ResolveCvar(string identifier) { CVar cvar = CRegistery.FindCvar(identifier); if (cvar == null) { PrintError("Can't find boolean variable: '{0}'", identifier); return(null); } if (!cvar.IsBool) { PrintError("Boolean variable expected: '{0}'", identifier); return(null); } return(cvar); }
protected override IList <string> AutoCompleteArgs(string commandLine, string token) { IList <CCommand> commands = CRegistery.ListCommands(delegate(CCommand command) { return(!(command is CVarCommand) && !(command is CDelegateCommand) && !(command is CAliasCommand) && CRegistery.ShouldListCommand(command, token, CCommand.DefaultListOptions)); }); if (commands.Count == 0) { return(null); } return(Collection.Map(commands, delegate(CCommand cmd) { return StringUtils.C(cmd.Name, cmd.ColorCode); })); }
bool Execute(string cvarName) { CVarCommand cmd = CRegistery.FindCvarCommand(cvarName); if (cmd == null) { PrintError("Can't find cvar '" + cvarName + "'"); return(false); } if (!cmd.IsInt) { PrintError("Can't toggle non-int value"); return(false); } cmd.ParentCommand = this; cmd.SetValue(cmd.BoolValue ? 0 : 1); cmd.ParentCommand = null; return(true); }
private static IList <string> ListCvars() { IList <CVar> cvars = CRegistery.ListVars(delegate(CVarCommand cmd) { return(!cmd.IsDefault && !cmd.HasFlag(CFlags.NoArchive)); }); IList <string> entries = new List <string>(cvars.Count); foreach (CVar cvar in cvars) { if (cvar.Value != null) { entries.Add(string.Format("{0} {1}", cvar.Name, StringUtils.Arg(cvar.Value))); } else { entries.Add("null " + cvar.Name); } } return(entries); }
public CCommand FindCommand(string name) { return(CRegistery.FindCommand(name)); }
public CVar FindCvar(string name) { return(CRegistery.FindCvar(name)); }
////////////////////////////////////////////////////////////////////////////// #region Inheritance protected virtual void ResolveCommands() { CRegistery.ResolveElements(); }
bool Execute(string stroke, string command = null) // TODO: refactor me! { string name = stroke.ToLower(); if (!string.IsNullOrEmpty(command)) { CShortCut shortCut; if (!CShortCut.TryParse(stroke, out shortCut)) { PrintError("Invalid shortcut: {0}", name); return(false); } string keyUpCommand = null; char keyDownOp = command[0]; if (keyDownOp == '+' || keyDownOp == '-') { if (command.Length == 1) { PrintError("Identifier expected!"); return(false); } string identifier = command.Substring(1); // register operation command CCommand keyDownCmd = CRegistery.FindCommand(command); if (keyDownCmd == null) { keyDownCmd = new COperationCommand(keyDownOp, identifier); CRegistery.Register(keyDownCmd); keyDownCmd.SetFlag(CCommandFlags.System, true); } // register opposite operation command char keyUpOp = OppositeOperation(keyDownOp); keyUpCommand = keyUpOp + identifier; CCommand keyUpCmd = CRegistery.FindCommand(keyUpCommand); if (keyUpCmd == null) { keyUpCmd = new COperationCommand(keyUpOp, identifier); CRegistery.Register(keyUpCmd); keyUpCmd.SetFlag(CCommandFlags.System, true); } } CBindings.Bind(shortCut, StringUtils.UnArg(command), keyUpCommand != null ? StringUtils.UnArg(keyUpCommand) : null); PostNotification( CCommandNotifications.CBindingsChanged, CCommandNotifications.KeyManualMode, this.IsManualMode ); return(true); } IList <CBinding> bindings = CBindings.List(name); if (bindings.Count > 0) { foreach (CBinding b in bindings) { PrintIndent(ToString(b)); } } else { PrintIndent("No bindings"); } return(true); }
protected override IList <string> AutoCompleteArgs(string commandLine, string token) { return(CRegistery.ListVarNames(token, CCommand.DefaultListOptions)); }