private void EvalInputString(string inputString) { inputString = inputString.Trim(); if (string.IsNullOrEmpty(inputString)) { LogMessage(ConsoleMessage.Debug(string.Empty)); return; } _history.Add(inputString); LogMessage(ConsoleMessage.Debug(inputString)); var input = new List <string>(inputString.Split(new [] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries)); input = input.Select(low => low.ToLower()).ToList(); var cmd = input[0]; if (CommandController.Contains(cmd)) { CommandController[cmd].Execute(input.ToArray()) .ObserveOnMainThread() .Subscribe(r => LogMessage(ConsoleMessage.Info(r))); } else { LogMessage(ConsoleMessage.Info(string.Format("*** Unknown Command: {0} ***", cmd))); } }
private void OnEnable() { var scale = Screen.dpi / 160.0f; if (scale != 0.0f && scale >= 1.1f) { _scaled = true; _guiScale.Set(scale, scale, scale); } windowMethods = new GUI.WindowFunction[] { LogWindow, CopyLogWindow, WatchVarWindow }; _fps = new FPSCounter(); StartCoroutine(_fps.Update()); nameRect = messageLine; valueRect = messageLine; #if MOBILE this.useGUILayout = false; _windowRect = new Rect(5.0f, 5.0f, 300.0f, 450.0f); _fakeWindowRect = new Rect(0.0f, 0.0f, _windowRect.width, _windowRect.height); _fakeDragRect = new Rect(0.0f, 0.0f, _windowRect.width - 32, 24); #else _windowRect = new Rect(30.0f, 30.0f, 300.0f, 450.0f); #endif LogMessage(ConsoleMessage.Info(string.Format(" ActionStreetMap Engine, version {0}", Version))); LogMessage(ConsoleMessage.Info(" type 'help' for available commands.")); LogMessage(ConsoleMessage.Info("")); //RegisterTerminalCommands(); }
private void OnEnable() { //var scale = Screen.dpi/160.0f; //if (scale != 0.0f && scale >= 1.1f) //{ // _scaled = true; // _guiScale.Set(scale, scale, scale); //} windowMethods = new GUI.WindowFunction[] { LogWindow, CopyLogWindow, WatchVarWindow }; _fps = new FPSCounter(); StartCoroutine(_fps.Update()); nameRect = messageLine; valueRect = messageLine; #if MOBILE this.useGUILayout = false; _windowRect = WindowRect; _fakeWindowRect = new Rect(0.0f, 0.0f, _windowRect.width, _windowRect.height); _fakeDragRect = new Rect(0.0f, 0.0f, _windowRect.width - 32, 24); #else _windowRect = WindowRect; #endif LogMessage(ConsoleMessage.Info(string.Format(" UtyMap, version {0}", EnvironmentApi.Version))); LogMessage(ConsoleMessage.Info(" type 'help' for available commands.")); LogMessage(ConsoleMessage.Info(" double tap or press tilda to show/hide console.")); LogMessage(ConsoleMessage.Info("")); }
private void RegisterTerminalCommands() { _commandController.Register(new Command("close", "closes console", _ => { IsOpen = false; return("opened"); })); _commandController.Register(new Command("clear", "clears console", _ => { ClearLog(); return("clear"); })); _commandController.Register(new Command("filter", "filter console items", args => { const string enabledStr = "-e:"; const string disabledStr = "-d"; if (args.Length == 2) { var value = args[1].Trim(); if (value.StartsWith(enabledStr)) { var regexStr = value.Substring(enabledStr.Length); _regex = new Regex(regexStr, RegexOptions.IgnoreCase); return("filter enabled"); } if (value.StartsWith(disabledStr)) { _regex = null; return("filter disabled"); } } LogMessage(ConsoleMessage.Info("Wrong syntax: \n\tfilter -e:<regex> \n\tfilter -d")); return(""); })); _commandController.Register(new GeocodeCommand(_container.Resolve <IGeocoder>())); _commandController.Register(new GrepCommand(_messages)); _commandController.Register(new SysCommand()); _commandController.Register(new Command("help", "prints help", args => { var output = new StringBuilder(); output.AppendLine(":: Command List ::"); foreach (var name in _commandController.Commands.Keys) { var command = _commandController.Commands[name]; output.AppendFormat("{0}: {1}\n", name, command.Description); } output.AppendLine(" "); return(output.ToString()); })); }
private void RegisterTerminalCommands() { CommandController.Register(new Command("close", "closes console", _ => { IsOpen = false; return("opened"); })); CommandController.Register(new Command("clear", "clears console", _ => { ClearLog(); return("clear"); })); CommandController.Register(new Command("filter", "filter console items", args => { const string enabledStr = "-e:"; const string disabledStr = "-d"; if (args.Length == 2) { var value = args[1].Trim(); if (value.StartsWith(enabledStr)) { var regexStr = value.Substring(enabledStr.Length); _regex = new Regex(regexStr, RegexOptions.IgnoreCase); return("filter enabled"); } if (value.StartsWith(disabledStr)) { _regex = null; return("filter disabled"); } } LogMessage(ConsoleMessage.Info("Wrong syntax: \n\tfilter -e:<regex> \n\tfilter -d")); return(""); })); // NOTE grep is special command and cannot be registered as normal command CommandController.Register(new GrepCommand(_messages)); CommandController.Register(new SysCommand()); }
private ConsoleMessage ToLogMessage(RecordType type, string category, string text, Exception exception) { switch (type) { case RecordType.Error: return(ConsoleMessage.Error(String.Format("[{0}] {1}:{2}. Exception: {3}", type, category, text, exception))); case RecordType.Warn: return(ConsoleMessage.Warning(String.Format("[{0}] {1}:{2}", type, category, text))); case RecordType.Info: var lines = text.Trim('\n').Split('\n'); var output = new StringBuilder(); output.Append(String.Format("[{0}] {1}:", type, category)); for (var i = 0; i < lines.Length; i++) { output.AppendFormat("{0}{1}", lines[i], i != lines.Length - 1 ? "\n" : ""); } return(ConsoleMessage.Info(output.ToString())); default: return(ConsoleMessage.Debug(String.Format("[{0}] {1}: {2}", type, category, text))); } }