void Command_Position_Goto(GotoType gotoType, bool selecting, GotoDialog.Result result)
		{
			var offsets = GetVariableExpressionResults<int>(result.Expression);
			if (!offsets.Any())
				return;

			var sels = Selections.ToList();

			if ((sels.Count == 0) && (gotoType == GotoType.Line))
				sels.Add(BeginRange);
			if (sels.Count == 1)
				sels = sels.Resize(offsets.Count, sels[0]).ToList();
			if (offsets.Count == 1)
				offsets = offsets.Expand(sels.Count, offsets[0]).ToList();
			if (offsets.Count != sels.Count)
				throw new Exception("Expression count doesn't match selection count");

			if (gotoType != GotoType.Position)
				offsets = offsets.Select(ofs => ofs - 1).ToList();

			switch (gotoType)
			{
				case GotoType.Line:
					Selections.Replace(sels.AsParallel().AsOrdered().Select((range, ctr) => MoveCursor(range, Data.GetNonDiffLine(offsets[ctr]), 0, selecting, false, false)).ToList());
					break;
				case GotoType.Column:
					Selections.Replace(sels.AsParallel().AsOrdered().Select((range, ctr) => MoveCursor(range, 0, offsets[ctr], selecting, true, false)).ToList());
					break;
				case GotoType.Position:
					Selections.Replace(sels.AsParallel().AsOrdered().Select((range, ctr) => MoveCursor(range, offsets[ctr], selecting)).ToList());
					break;
			}
		}
Esempio n. 2
0
		public static Result Run(Window parent, GotoType gotoType, int startValue, NEVariables variables)
		{
			var dialog = new GotoDialog(gotoType, startValue, variables) { Owner = parent };
			return dialog.ShowDialog() ? dialog.result : null;
		}