当前位置: 首页>>代码示例>>C#>>正文


C# ITextUndoHistoryRegistry.RegisterHistory方法代码示例

本文整理汇总了C#中ITextUndoHistoryRegistry.RegisterHistory方法的典型用法代码示例。如果您正苦于以下问题:C# ITextUndoHistoryRegistry.RegisterHistory方法的具体用法?C# ITextUndoHistoryRegistry.RegisterHistory怎么用?C# ITextUndoHistoryRegistry.RegisterHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextUndoHistoryRegistry的用法示例。


在下文中一共展示了ITextUndoHistoryRegistry.RegisterHistory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TextBufferUndoManager

		public TextBufferUndoManager(ITextBuffer textBuffer, ITextUndoHistoryRegistry textUndoHistoryRegistry) {
			if (textBuffer == null)
				throw new ArgumentNullException(nameof(textBuffer));
			if (textUndoHistoryRegistry == null)
				throw new ArgumentNullException(nameof(textUndoHistoryRegistry));
			changes = new List<ChangeInfo>();
			TextBuffer = textBuffer;
			this.textUndoHistoryRegistry = textUndoHistoryRegistry;
			textBufferUndoHistory = textUndoHistoryRegistry.RegisterHistory(TextBuffer);
			TextBuffer.Changed += TextBuffer_Changed;
			TextBuffer.PostChanged += TextBuffer_PostChanged;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:12,代码来源:TextBufferUndoManager.cs

示例2: Execute

		public void Execute(ITextView textView, ITextUndoHistoryRegistry textUndoHistoryRegistry)
		{
			var isReversed = textView.Selection.IsReversed;
			var newSelection = new List<Tuple<int, int>>();

			var undoHistory = textUndoHistoryRegistry.RegisterHistory(textView);
			using (var transaction = undoHistory.CreateTransaction("Comment Selection"))
			{
				foreach (var span in textView.Selection.SelectedSpans)
				{
					var startLine = span.Start.GetContainingLine().LineNumber;
					var endLine = span.End.GetContainingLine().LineNumber;

					if (startLine > endLine)
					{
						var tmp = startLine;
						startLine = endLine;
						endLine = tmp;
					}

					var edit = span.Snapshot.TextBuffer.CreateEdit();
					for (int lineNumber = startLine; lineNumber <= endLine; ++lineNumber)
					{
						var line = span.Snapshot.GetLineFromLineNumber(lineNumber);
						Modify(edit, line);
					}

					edit.Apply();

					newSelection.Add(Tuple.Create(startLine, endLine));
				}

				transaction.Complete();
			}

			textView.Selection.Select(new NormalizedSnapshotSpanCollection(
				newSelection.Select(l => new SnapshotSpan(
					textView.TextSnapshot.GetLineFromLineNumber(l.Item1).Start,
					textView.TextSnapshot.GetLineFromLineNumber(l.Item2).End)
				)
			)[0], isReversed);
		}
开发者ID:modulexcite,项目名称:YamlDotNet.Editor,代码行数:42,代码来源:SelectionModifierCommandHandler.cs

示例3: Execute

		public void Execute(ITextView textView, ITextUndoHistoryRegistry textUndoHistoryRegistry)
		{
			var undoHistory = textUndoHistoryRegistry.RegisterHistory(textView);
			using (var transaction = undoHistory.CreateTransaction("Format Document"))
			{
				var text = textView.TextBuffer.CurrentSnapshot.GetText();

				var formatted = new StringWriter();
				var parser = new Parser(new Scanner(new StringReader(text), skipComments: false));
				var emitter = new Emitter(formatted);

				while (parser.MoveNext())
				{
					emitter.Emit(parser.Current);
				}

				var edit = textView.TextBuffer.CreateEdit();
				edit.Replace(0, text.Length, formatted.ToString());
				edit.Apply();

				transaction.Complete();
			}
		}
开发者ID:modulexcite,项目名称:YamlDotNet.Editor,代码行数:23,代码来源:FormatDocumentCommandHandler.cs


注:本文中的ITextUndoHistoryRegistry.RegisterHistory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。