public static ReplaceTokens ( |
||
fileTagObject | ||
tagString | string | |
return | string |
/// <summary> /// Allows the user to generate a title block at the caret location, using the current file info /// </summary> public static void AddTitleBlockAtCaret() { CommonTagAction(fileInfo => { var output = new StringBuilder(); var eol = Npp.GetEolString; output.Append(FileTag.ReplaceTokens(fileInfo, Config.Instance.TagTitleBlock1)); output.Append(eol); // description var regex = new Regex(@"({&de\s*})"); var match = regex.Match(Config.Instance.TagTitleBlock2); if (match.Success && !String.IsNullOrEmpty(fileInfo.CorrectionDecription)) { var matchedStr = match.Groups[1].Value; foreach (var line in fileInfo.CorrectionDecription.BreakText(matchedStr.Length).Split('\n')) { output.Append(Config.Instance.TagTitleBlock2.Replace(matchedStr, String.Format("{0,-" + matchedStr.Length + @"}", line))); output.Append(eol); } } output.Append(FileTag.ReplaceTokens(fileInfo, Config.Instance.TagTitleBlock3)); output.Append(eol); Npp.SetTextByRange(Npp.CurrentPosition, Npp.CurrentPosition, output.ToString()); Npp.SetSel(Npp.CurrentPosition + output.Length); }); }
/// <summary> /// Allows the user to surround its selection with custom modification tags /// </summary> public static void SurroundSelectionWithTag() { CommonTagAction(fileInfo => { var output = new StringBuilder(); Npp.TargetFromSelection(); var indent = new String(' ', Npp.GetLine(Npp.LineFromPosition(Npp.TargetStart)).Indentation); var opener = FileTag.ReplaceTokens(fileInfo, Config.Instance.TagModifOpener); var eol = Npp.GetEolString; output.Append(opener); output.Append(eol); output.Append(indent); output.Append(Npp.SelectedText); output.Append(eol); output.Append(indent); output.Append(FileTag.ReplaceTokens(fileInfo, Config.Instance.TagModifCloser)); Npp.TargetFromSelection(); Npp.ReplaceTarget(output.ToString()); Npp.SetSel(Npp.TargetStart + opener.Length + eol.Length); }); }