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


C# TextArea.GetDeletableSegments方法代码示例

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


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

示例1: ReplaceSelectionWithText

		/// <inheritdoc/>
		public override void ReplaceSelectionWithText(TextArea textArea, string newText)
		{
			if (textArea == null)
				throw new ArgumentNullException("textArea");
			if (newText == null)
				throw new ArgumentNullException("newText");
			using (textArea.Document.RunUpdate()) {
				if (IsEmpty) {
					if (newText.Length > 0) {
						if (textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset)) {
							textArea.Document.Insert(textArea.Caret.Offset, newText);
						}
					}
				} else {
					ISegment[] segmentsToDelete = textArea.GetDeletableSegments(this);
					for (int i = segmentsToDelete.Length - 1; i >= 0; i--) {
						if (i == segmentsToDelete.Length - 1) {
							textArea.Caret.Offset = segmentsToDelete[i].EndOffset;
							textArea.Document.Replace(segmentsToDelete[i], newText);
						} else {
							textArea.Document.Remove(segmentsToDelete[i]);
						}
					}
					if (segmentsToDelete.Length != 0) {
						textArea.Selection = Selection.Empty;
					}
				}
			}
		}
开发者ID:pusp,项目名称:o2platform,代码行数:30,代码来源:SimpleSelection.cs

示例2: ReplaceSingleLineText

 private void ReplaceSingleLineText(TextArea textArea, SelectionSegment lineSegment, string newText, out int insertionLength)
 {
     if (lineSegment.Length == 0)
     {
         if (newText.Length > 0 && textArea.ReadOnlySectionProvider.CanInsert(lineSegment.StartOffset))
         {
             newText = AddSpacesIfRequired(newText, new TextViewPosition(document.GetLocation(lineSegment.StartOffset), lineSegment.StartVisualColumn), new TextViewPosition(document.GetLocation(lineSegment.EndOffset), lineSegment.EndVisualColumn));
             textArea.Document.Insert(lineSegment.StartOffset, newText);
         }
     }
     else
     {
         ISegment[] segmentsToDelete = textArea.GetDeletableSegments(lineSegment);
         for (int i = segmentsToDelete.Length - 1; i >= 0; i--)
         {
             if (i == segmentsToDelete.Length - 1)
             {
                 if (segmentsToDelete[i].Offset == SurroundingSegment.Offset && segmentsToDelete[i].Length == SurroundingSegment.Length)
                 {
                     newText = AddSpacesIfRequired(newText, new TextViewPosition(document.GetLocation(lineSegment.StartOffset), lineSegment.StartVisualColumn), new TextViewPosition(document.GetLocation(lineSegment.EndOffset), lineSegment.EndVisualColumn));
                 }
                 textArea.Document.Replace(segmentsToDelete[i], newText);
             }
             else
             {
                 textArea.Document.Remove(segmentsToDelete[i]);
             }
         }
     }
     insertionLength = newText.Length;
 }
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:31,代码来源:RectangleSelection.cs

示例3: ReplaceSingleLineText

 static void ReplaceSingleLineText(TextArea textArea, ISegment lineSegment, string newText)
 {
     if (lineSegment.Length == 0) {
         if (newText.Length > 0 && textArea.ReadOnlySectionProvider.CanInsert(lineSegment.Offset)) {
             textArea.Document.Insert(lineSegment.Offset, newText);
         }
     } else {
         ISegment[] segmentsToDelete = textArea.GetDeletableSegments(lineSegment);
         for (int i = segmentsToDelete.Length - 1; i >= 0; i--) {
             if (i == segmentsToDelete.Length - 1) {
                 textArea.Document.Replace(segmentsToDelete[i], newText);
             } else {
                 textArea.Document.Remove(segmentsToDelete[i]);
             }
         }
     }
 }
开发者ID:Amichai,项目名称:PhysicsPad,代码行数:17,代码来源:RectangleSelection.cs


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