private void SetFloat(AnkhDiffToolArgs args) { IAnkhConfigurationService cs = GetService <IAnkhConfigurationService>(); if (cs != null) { args.ShowDiffAsDocument = !cs.Instance.FloatDiffEditors; } }
private bool Substitute(string reference, AnkhDiffToolArgs args, DiffToolMode toolMode, out string program, out string arguments) { if (string.IsNullOrEmpty(reference)) { throw new ArgumentNullException("reference"); } else if (args == null) { throw new ArgumentNullException("args"); } // Ok: We received a string with a program and arguments and windows // wants a program and arguments separated. Let's find the program before substituting reference = reference.TrimStart(); program = null; arguments = null; string app; if (!string.IsNullOrEmpty(app = AnkhDiffTool.GetToolNameFromTemplate(reference))) { // We have a predefined template. Just use it AnkhDiffTool tool = GetAppItem(app, toolMode); if (tool == null) { return(false); } else if (!tool.IsAvailable) { return(false); } program = SubstituteArguments(tool.Program, args, toolMode); arguments = SubstituteArguments(tool.Arguments, args, toolMode); return(!String.IsNullOrEmpty(program) && File.Exists(program)); } else if (!SvnTools.TrySplitCommandLine(reference, SubstituteEmpty, out program, out arguments)) { return(false); } program = SubstituteArguments(program, args, toolMode); arguments = SubstituteArguments(arguments, args, toolMode); return(true); }
public Replacer(AnkhDiff context, AnkhDiffToolArgs args, DiffToolMode toolMode) : base(context) { if (context == null) { throw new ArgumentNullException("context"); } else if (args == null) { throw new ArgumentNullException("args"); } _diff = context; _toolArgs = args; _diffArgs = args as AnkhDiffArgs; _mergeArgs = args as AnkhMergeArgs; _patchArgs = args as AnkhPatchArgs; _toolMode = toolMode; }
private string SubstituteArguments(string arguments, AnkhDiffToolArgs diffArgs, DiffToolMode toolMode) { if (diffArgs == null) { throw new ArgumentNullException("diffArgs"); } if (_re == null) { const string ifBody = "\\?(?<tick>['\"])(?<ifbody>([^'\"]|('')|(\"\"))*)\\k<tick>"; const string elseBody = "(:(?<tick2>['\"])(?<elsebody>([^'\"]|('')|(\"\"))*)\\k<tick2>)?"; const string isBody = "=(?<tick3>['\"])(?<isbody>([^'\"]|('')|(\"\"))*)\\k<tick3>"; _re = new Regex(@"(\%(?<pc>[a-zA-Z0-9_]+)(\%|\b))" + "|(\\$\\((?<vs>[a-zA-Z0-9_-]+)(\\((?<arg>[a-zA-Z0-9_-]*)\\))?\\))" + "|(\\$\\((?<if>[a-zA-Z0-9_-]+)" + ifBody + elseBody + "\\))" + "|(\\$\\((?<is>[a-zA-Z0-9_-]+)" + isBody + "\\))"); } return(_re.Replace(arguments, new Replacer(this, diffArgs, toolMode).Replace).TrimEnd()); }