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


C# TextEditorData.Remove方法代码示例

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


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

示例1: RemoveTabInLine

		public static int RemoveTabInLine (TextEditorData data, DocumentLine line)
		{
			if (line.LengthIncludingDelimiter == 0)
				return 0;
			char ch = data.Document.GetCharAt (line.Offset); 
			if (ch == '\t') {
				data.Remove (line.Offset, 1);
				data.Document.CommitLineUpdate (line);
				return 1;
			} else if (ch == ' ') {
				int removeCount = 0;
				for (int i = 0; i < data.Options.IndentationSize;) {
					ch = data.Document.GetCharAt (line.Offset + i);
					if (ch == ' ') {
						removeCount ++;
						i++;
					} else if (ch == '\t') {
						removeCount ++;
						i += data.Options.TabSize;
					} else {
						break;
					}
				}
				data.Remove (line.Offset, removeCount);
				data.Document.CommitLineUpdate (line);
				return removeCount;
			}
			return 0;
		}
开发者ID:OnorioCatenacci,项目名称:monodevelop,代码行数:29,代码来源:MiscActions.cs

示例2: RemoveCharBeforCaret

		static void RemoveCharBeforCaret (TextEditorData data)
		{
			if (((ISourceEditorOptions)data.Options).AutoInsertMatchingBracket) {
				if (data.Caret.Offset > 0) {
					var line = data.GetLine (data.Caret.Line);
					var stack = line.StartSpan.Clone();
					if (stack.Any (s => s.Color == "string.other")) {
						DeleteActions.Backspace (data);
						return;
					}
					stack = line.StartSpan.Clone();
					if (stack.Any (s => s.Color == "string.other")) {
						DeleteActions.Backspace (data);
						return;
					}
					
					char ch = data.Document.GetCharAt (data.Caret.Offset - 1);
					int idx = open.IndexOf (ch);
					
					if (idx >= 0) {
						int nextCharOffset = GetNextNonWsCharOffset (data, data.Caret.Offset);
						if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt (nextCharOffset)) {
							bool updateToEnd = data.Document.OffsetToLineNumber (nextCharOffset) != data.Caret.Line;
							data.Remove (data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1);
						}
					}
				}
			}
			DeleteActions.Backspace (data);
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:30,代码来源:EditActions.cs

示例3: NextWord

		static void NextWord (TextEditorData data, bool subword)
		{
			int oldLine = data.Caret.Line;
			int offset = subword? data.FindNextSubwordOffset (data.Caret.Offset) : data.FindNextWordOffset (data.Caret.Offset);
			if (data.Caret.Offset != offset && data.CanEdit (oldLine) && data.CanEdit (data.Caret.Line))  {
				data.Remove (data.Caret.Offset, offset - data.Caret.Offset);
				data.Document.CommitLineToEndUpdate (data.Caret.Line);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:9,代码来源:DeleteActions.cs

示例4: NextWord

		static void NextWord (TextEditorData data, bool subword)
		{
			int oldLine = data.Caret.Line;
			int caretOffset = data.Caret.Offset;
			int offset = subword? data.FindNextSubwordOffset (caretOffset) : data.FindNextWordOffset (caretOffset);
			if (caretOffset != offset && data.CanEdit (oldLine) && data.CanEdit (data.Caret.Line))  {
				data.Remove (caretOffset, offset - caretOffset);
			}
		}
开发者ID:slodge,项目名称:monodevelop,代码行数:9,代码来源:DeleteActions.cs

示例5: PreviousWord

		static void PreviousWord (TextEditorData data, bool subword)
		{
			int oldLine = data.Caret.Line;
			int offset = subword? data.FindPrevSubwordOffset (data.Caret.Offset) : data.FindPrevWordOffset (data.Caret.Offset);
			if (data.Caret.Offset != offset && data.CanEdit (oldLine) && data.CanEdit (data.Caret.Line)) {
				data.Remove (offset, data.Caret.Offset - offset);
				data.Caret.Offset = offset;
				if (oldLine != data.Caret.Line)
					data.Document.CommitLineToEndUpdate (data.Caret.Line);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:11,代码来源:DeleteActions.cs

示例6: PreviousWord

		static void PreviousWord (TextEditorData data, bool subword)
		{
			using (var undo = data.OpenUndoGroup ()) {
				int oldLine = data.Caret.Line;

				int caretOffset = data.Caret.Offset;
				int offset = subword ? data.FindPrevSubwordOffset (caretOffset) : data.FindPrevWordOffset (caretOffset);
				if (caretOffset != offset && data.CanEdit (oldLine) && data.CanEdit (data.Caret.Line)) {
					data.Remove (offset, caretOffset - offset);
				}
			}
		}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:12,代码来源:DeleteActions.cs

示例7: removeTrailingWhitespace

        public static void removeTrailingWhitespace( TextEditorData data, DocumentLine line )
        {
            if( line != null )
            {
                int num = 0;
                for( int i = line.Length - 1; i >= 0; i-- )
                {
                    if( !char.IsWhiteSpace( data.Document.GetCharAt( line.Offset + i ) ) )
                        break;
                    num++;
                }

                if( num > 0 )
                {
                    int offset = line.Offset + line.Length - num;
                    data.Remove( offset, num );
                }
            }
        }
开发者ID:prime31,项目名称:MonoDevelopBetterFileSaver,代码行数:19,代码来源:RemoveTrailingWhitespace.cs

示例8: RemoveCharBeforCaret

		static void RemoveCharBeforCaret (TextEditorData data)
		{
			if (((ISourceEditorOptions)data.Options).AutoInsertMatchingBracket) {
				if (data.Caret.Offset > 0) {
					char ch = data.Document.GetCharAt (data.Caret.Offset - 1);
					int idx = open.IndexOf (ch);
					
					if (idx >= 0) {
						int nextCharOffset = GetNextNonWsCharOffset (data, data.Caret.Offset);
						if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt (nextCharOffset)) {
							bool updateToEnd = data.Document.OffsetToLineNumber (nextCharOffset) != data.Caret.Line;
							data.Remove (data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1);
							if (updateToEnd)
								data.Document.CommitLineToEndUpdate (data.Caret.Line);
						}
					}
				}
			}
			DeleteActions.Backspace (data);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:20,代码来源:EditActions.cs

示例9: CaretLine

		public static void CaretLine (TextEditorData data)
		{
			if (data.Document.LineCount <= 1 || !data.CanEdit (data.Caret.Line))
				return;
			var start = GetStartOfLineOffset (data, data.Caret.Location);
			var end = GetEndOfLineOffset (data, data.Caret.Location);
			data.Remove (start, end - start);
			data.Caret.Column = DocumentLocation.MinColumn;
		}
开发者ID:slodge,项目名称:monodevelop,代码行数:9,代码来源:DeleteActions.cs

示例10: Delete

		public static void Delete (TextEditorData data)
		{
			if (!data.CanEditSelection)
				return;
			if (data.IsSomethingSelected) {
				data.DeleteSelectedText ();
				return;
			}
			if (data.Caret.Offset >= data.Document.Length)
				return;
			LineSegment line = data.Document.GetLine (data.Caret.Line);
			if (data.Caret.Column == line.EditableLength) {
				if (data.Caret.Line < data.Document.LineCount) { 
					data.Remove (line.EndOffset - line.DelimiterLength, line.DelimiterLength);
					if (line.EndOffset == data.Document.Length)
						line.DelimiterLength = 0;
				}
			} else {
				data.Remove (data.Caret.Offset, 1); 
				data.Document.CommitLineUpdate (data.Caret.Line);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:22,代码来源:DeleteActions.cs

示例11: RemoveCharBeforeCaret

		public static void RemoveCharBeforeCaret (TextEditorData data)
		{
			data.Remove (data.Caret.Offset - 1, 1);
			data.Caret.Column--;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:5,代码来源:DeleteActions.cs

示例12: Backspace

		public static void Backspace (TextEditorData data, Action<TextEditorData> removeCharBeforeCaret)
		{
			if (!data.CanEditSelection)
				return;
			if (data.IsSomethingSelected) {
				// case: zero width block selection
				if (data.MainSelection.SelectionMode == SelectionMode.Block && data.MainSelection.Anchor.Column == data.MainSelection.Lead.Column) {
					var col = data.MainSelection.Lead.Column;
					if (col <= DocumentLocation.MinColumn) {
						data.ClearSelection ();
						return;
					}
					bool preserve = data.Caret.PreserveSelection;
					data.Caret.PreserveSelection = true;
					col--;
					for (int lineNumber = data.MainSelection.MinLine; lineNumber <= data.MainSelection.MaxLine; lineNumber++) {
						data.Remove (data.Document.GetLine (lineNumber).Offset + col - 1, 1);
					}
					data.MainSelection.Lead = new DocumentLocation (data.MainSelection.Lead.Line, col);
					data.MainSelection.Anchor = new DocumentLocation (data.MainSelection.Anchor.Line, col);
					data.Caret.PreserveSelection = preserve;
					data.Document.CommitMultipleLineUpdate (data.MainSelection.MinLine, data.MainSelection.MaxLine);
					return;
				}
				data.DeleteSelectedText (data.MainSelection.SelectionMode != SelectionMode.Block);
				return;
			}

			if (data.Caret.Line == DocumentLocation.MinLine && data.Caret.Column == DocumentLocation.MinColumn)
				return;
			
			// Virtual indentation needs to be fixed before to have the same behavior
			// if it's there or not (otherwise user has to press multiple backspaces in some cases)
			data.EnsureCaretIsNotVirtual ();
			DocumentLine line = data.Document.GetLine (data.Caret.Line);
			if (data.Caret.Column > line.Length + 1) {
				data.Caret.Column = line.Length + 1;
			} else if (data.Caret.Offset == line.Offset) {
				DocumentLine lineAbove = data.Document.GetLine (data.Caret.Line - 1);
				data.Remove (lineAbove.EndOffsetIncludingDelimiter - lineAbove.DelimiterLength, lineAbove.DelimiterLength);
			} else {
				removeCharBeforeCaret (data);
			}

			// Needs to be fixed after, the line may just contain the indentation
			data.FixVirtualIndentation ();
		}
开发者ID:slodge,项目名称:monodevelop,代码行数:47,代码来源:DeleteActions.cs

示例13: MoveBlockDown

		public static void MoveBlockDown (TextEditorData data)
		{
			int lineStart = data.Caret.Line;
			int lineEnd = data.Caret.Line;
			bool setSelection = lineStart != lineEnd;
			if (data.IsSomethingSelected) {
				setSelection = true;
				lineStart = data.MainSelection.MinLine;
				lineEnd = data.MainSelection.MaxLine;
			}
			
			if (lineEnd + 1 >= data.Document.LineCount)
				return;
			
			Mono.TextEditor.LineSegment startLine = data.Document.GetLine (lineStart);
			Mono.TextEditor.LineSegment endLine = data.Document.GetLine (lineEnd);
			Mono.TextEditor.LineSegment nextLine = data.Document.GetLine (lineEnd + 1);
			int relCaretOffset = data.Caret.Offset - startLine.Offset;
			data.Document.BeginAtomicUndo ();
			string text = data.Document.GetTextBetween (startLine.Offset, endLine.EndOffset);
			
			int nextLineOffset = nextLine.EndOffset;
			int delta = endLine.EndOffset - startLine.Offset;
			int newStartOffset = nextLineOffset - delta;
			
			// handle the last line case
			if (nextLine.DelimiterLength == 0) {
				text = data.EolMarker + text.Substring (0, text.Length - endLine.DelimiterLength);
				newStartOffset += data.EolMarker.Length;
			}
			data.Insert (nextLineOffset, text);
			data.Remove (startLine.Offset, delta);
			
			// move markers
			List<TextMarker> markers = new List<TextMarker> (nextLine.Markers);
			nextLine.ClearMarker ();
			for (int i = lineEnd; i <= lineStart; i++) {
				foreach (TextMarker marker in data.Document.GetLine (i).Markers) {
					data.Document.GetLine (i + 1).AddMarker (marker);
				}
				data.Document.GetLine (i).ClearMarker ();
			}
			markers.ForEach (m => startLine.AddMarker (m));

			
			data.Caret.Offset = newStartOffset + relCaretOffset;
			if (setSelection)
				data.SetSelection (newStartOffset, newStartOffset + text.Length - endLine.DelimiterLength);
			data.Document.EndAtomicUndo ();
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:50,代码来源:DefaultEditActions.cs

示例14: Delete

		public static void Delete (TextEditorData data)
		{
			if (!data.CanEditSelection)
				return;

			using (var undoGroup = data.OpenUndoGroup ()) {
				if (data.IsSomethingSelected) {
					// case: zero width block selection
					if (data.MainSelection.SelectionMode == SelectionMode.Block && data.MainSelection.Anchor.Column == data.MainSelection.Lead.Column) {
						var col = data.MainSelection.Lead.Column;
						if (col <= DocumentLocation.MinColumn) {
							data.ClearSelection ();
							return;
						}
						bool preserve = data.Caret.PreserveSelection;
						data.Caret.PreserveSelection = true;
						col--;
						for (int lineNumber = data.MainSelection.MinLine; lineNumber <= data.MainSelection.MaxLine; lineNumber++) {
							DocumentLine lineSegment = data.Document.GetLine (lineNumber);
							if (col < lineSegment.Length)
								data.Remove (lineSegment.Offset + col, 1);
						}
						data.Caret.PreserveSelection = preserve;
						data.Document.CommitMultipleLineUpdate (data.MainSelection.MinLine, data.MainSelection.MaxLine);
						return;
					}
					data.DeleteSelectedText (data.MainSelection.SelectionMode != SelectionMode.Block);
					return;
				}
				if (data.Caret.Offset >= data.Document.TextLength)
					return;

				data.EnsureCaretIsNotVirtual ();

				DocumentLine line = data.Document.GetLine (data.Caret.Line);
				if (data.Caret.Column == line.Length + 1) {
					if (data.Caret.Line < data.Document.LineCount) { 
						data.Remove (line.EndOffsetIncludingDelimiter - line.DelimiterLength, line.DelimiterLength);
						if (line.EndOffsetIncludingDelimiter == data.Document.TextLength)
							line.UnicodeNewline = UnicodeNewline.Unknown;
					}
				} else {
					data.Remove (data.Caret.Offset, 1); 
					data.Document.CommitLineUpdate (data.Caret.Line);
				}
				data.FixVirtualIndentation ();
			}
		}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:48,代码来源:DeleteActions.cs

示例15: DeleteWordBeforeCaret

		static int DeleteWordBeforeCaret (TextEditorData editor)
		{
			int offset = editor.Caret.Offset;
			int start  = FindPrevWordStart (editor, offset);
			editor.Remove (start, offset - start);
			return start;
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:7,代码来源:CodeTemplate.cs


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