public GetStartingWith ( string settingName ) : OpenIDE.Core.Config.ConfigurationSetting[] | ||
settingName | string | |
return | OpenIDE.Core.Config.ConfigurationSetting[] |
private void readInterpreters(ConfigReader config) { var prefix = "interpreter."; foreach (var interpreter in config.GetStartingWith(prefix)) { if (interpreter.Key.Length <= prefix.Length) continue; var extension = interpreter.Key .Substring( prefix.Length, interpreter.Key.Length - prefix.Length); if (extension.Length == 0) continue; extension = "." + extension; var path = interpreter.Value; if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX) { path.Replace("/", "\\"); } if (!File.Exists(path)) { var modifiedPath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location), path); if (File.Exists(path)) path = modifiedPath; } if (!_interpreters.ContainsKey(extension)) { Logger.Write("Adding interpreter: " + path + " for " + extension); _interpreters.Add(extension, path); } } }
public void Execute(string[] arguments) { Logger.Write ("Getting editor instance"); var instance = _editorFactory.GetInstance(_rootPath); // TODO remove that unbeleavable nasty setfocus solution. Only init if launching editor var isSetfocus = arguments.Length > 0 && arguments[0] == "setfocus"; if (instance == null && arguments.Length >= 0 && !isSetfocus) { var args = new List<string>(); Logger.Write("Reading configuration from " + _rootPath); var configReader = new ConfigReader(_rootPath); if (arguments.Length == 0) { var name = configReader.Get("default.editor"); if (name == null) { Console.WriteLine("To launch without specifying editor you must specify the default.editor config option"); return; } args.Add(name); } else { args.AddRange(arguments); } var editorName = args[0]; args.AddRange( configReader .GetStartingWith("editor." + editorName) .Select(x => "--" + x.Key + "=" + x.Value)); if (!_environment.HasEditorEngine(_rootPath)) { if (!_environment.StartEditorEngine(args, _rootPath)) { Console.WriteLine("Could not launch editor " + args[0]); return; } } if (!_environment.HasEditorEngine(_rootPath)) { Console.WriteLine("Could not launch editor " + args[0]); return; } if (!_environment.IsRunning(_rootPath)) _environment.Start(_rootPath); } else if (arguments.Length >= 1 && arguments[0] == "get-dirty-files") { if (instance == null) return; string file = null; if (arguments.Length > 1) file = arguments[1]; Console.WriteLine(instance.GetDirtyFiles(file)); } else { if (instance == null) return; instance.Run(arguments); } }
public void Execute(string[] arguments) { Logger.Write ("Getting editor instance"); var instance = _editorFactory.GetInstance(_rootPath); // TODO remove that unbeleavable nasty setfocus solution. Only init if launching editor var isSetfocus = arguments.Length > 0 && arguments[0] == "setfocus"; if (instance == null && arguments.Length >= 0 && !isSetfocus) { var args = new List<string>(); Logger.Write("Reading configuration from " + _rootPath); var configReader = new ConfigReader(_rootPath); if (arguments.Length == 0) { var name = configReader.Get("default.editor"); if (name == null) { Console.WriteLine("To launch without specifying editor you must specify the default.editor config option"); return; } args.Add(name); } else { args.AddRange(arguments); } var editorName = args[0]; args.AddRange( configReader .GetStartingWith("editor." + editorName) .Select(x => "--" + x.Key + "=" + x.Value)); // A bit of a hack but if we find a configuration called executable for the editor // if the path is rooted (avvoids checking for files in PATH) display a warning // if it does not exist. var executableSetting = configReader.Get("editor." + editorName + ".executable"); if (executableSetting != null) { if (Path.IsPathRooted(executableSetting)) { if (!File.Exists(executableSetting)) _dispatch("warning|The configured path for the " + editorName + " editor does not exist: " + executableSetting); } } if (!_environment.HasEditorEngine(_rootPath)) { if (!_environment.StartEditorEngine(args, _rootPath)) { Logger.Write("Could not launch editor " + args[0]); return; } } if (!_environment.HasEditorEngine(_rootPath)) { Logger.Write("Could not launch editor " + args[0]); return; } if (!_environment.IsRunning(_rootPath)) { _environment.Start(_rootPath); } } else if (arguments.Length >= 1 && arguments[0] == "get-dirty-files") { if (instance == null) return; string file = null; if (arguments.Length > 1) file = arguments[1]; Console.WriteLine(instance.GetDirtyFiles(file)); } else if (arguments.Length == 1 && arguments[0] == "get-caret") { Console.WriteLine(instance.GetCaret()); } else if (arguments.Length == 3 && arguments[0] == "user-select") { instance.UserSelect(arguments[1], arguments[2]); } else if (arguments.Length >= 2 && arguments[0] == "user-input") { var defaultvalue = ""; if (arguments.Length > 2) defaultvalue = arguments[2]; instance.UserInput(arguments[1], defaultvalue); } else if (arguments.Length == 1 && arguments[0] == "get-windows") { Console.WriteLine(instance.GetWindows()); } else { if (instance == null) return; instance.Run(arguments); } }