public string ReplaceValue(string value) { if (value.StartsWith("Regex#")) { Regex regex = null; try { regex = new Regex(value.Substring("Regex#".Length), RegexOptions.RightToLeft); } catch { } if (regex != null) { Place place = lines.PlaceOf(position); Line line = lines[place.iLine]; Match match = regex.Match(line.Text, 0, place.iChar); if (match.Success && match.Groups.Count > 0 && match.Groups[1].Captures.Count > 0) { return(match.Groups[1].Captures[0].Value); } } return(""); } string error; Commander.ReplaceVars(frame.Nest.MainForm, frame.Snippets_GetFile, frame.settings, ref value, out error); return(value); }
public SelectionAssertion Anchor(int iChar, int iLine) { Assert.AreEqual(new Place(iChar, iLine), provider.PlaceOf(selection.anchor), (description != null ? description + ":" : "") + "Anchor"); return(this); }
public void PlaceOf_Simple() { Init(); lines.SetText("line0\nline1 text\r\nline3"); CollectionAssert.AreEqual(new string[] { "line0\n", "line1 text\r\n", "line3" }, lines.Debug_GetLinesText()); // line0N // line1 textRN // line3 Assert.AreEqual(new Place(0, 0), lines.PlaceOf(0)); Assert.AreEqual(new Place(1, 0), lines.PlaceOf(1)); Assert.AreEqual(new Place(2, 0), lines.PlaceOf(2)); Assert.AreEqual(new Place(3, 0), lines.PlaceOf(3)); Assert.AreEqual(new Place(4, 0), lines.PlaceOf(4)); Assert.AreEqual(new Place(5, 0), lines.PlaceOf(5)); Assert.AreEqual(new Place(0, 1), lines.PlaceOf(6)); Assert.AreEqual(new Place(1, 1), lines.PlaceOf(7)); Assert.AreEqual(new Place(2, 1), lines.PlaceOf(8)); Assert.AreEqual(new Place(3, 1), lines.PlaceOf(9)); Assert.AreEqual(new Place(4, 1), lines.PlaceOf(10)); Assert.AreEqual(new Place(9, 1), lines.PlaceOf(15)); Assert.AreEqual(new Place(10, 1), lines.PlaceOf(16)); Assert.AreEqual(new Place(11, 1), lines.PlaceOf(17)); Assert.AreEqual(new Place(0, 2), lines.PlaceOf(18)); Assert.AreEqual(new Place(1, 2), lines.PlaceOf(19)); Assert.AreEqual(new Place(2, 2), lines.PlaceOf(20)); Assert.AreEqual(new Place(3, 2), lines.PlaceOf(21)); Assert.AreEqual(new Place(4, 2), lines.PlaceOf(22)); Assert.AreEqual(new Place(5, 2), lines.PlaceOf(23)); }