Mono.TextEditor.TextEditorData.DeleteSelectedText C# (CSharp) Method

DeleteSelectedText() public method

public DeleteSelectedText ( ) : void
return void
		public void DeleteSelectedText ()
		{
			DeleteSelectedText (true);
		}
		

Same methods

TextEditorData::DeleteSelectedText ( bool clearSelection ) : void

Usage Example

Example #1
0
        static int PastePlainText(TextEditorData data, int offset, string text, bool preserveSelection = false, byte[] copyData = null)
        {
            int inserted = 0;
            var undo     = data.OpenUndoGroup();

            try {
                var version = data.Document.Version;
                if (!preserveSelection)
                {
                    data.DeleteSelectedText(!data.IsSomethingSelected || data.MainSelection.SelectionMode != MonoDevelop.Ide.Editor.SelectionMode.Block);
                }
                int startLine = data.Caret.Line;
                data.EnsureCaretIsNotVirtual();
                if (data.IsSomethingSelected && data.MainSelection.SelectionMode == MonoDevelop.Ide.Editor.SelectionMode.Block)
                {
                    var selection            = data.MainSelection;
                    var visualInsertLocation = data.LogicalToVisualLocation(selection.Anchor);
                    for (int lineNumber = selection.MinLine; lineNumber <= selection.MaxLine; lineNumber++)
                    {
                        var    lineSegment  = data.GetLine(lineNumber);
                        int    insertOffset = lineSegment.GetLogicalColumn(data, visualInsertLocation.Column) - 1;
                        string textToInsert;
                        if (lineSegment.Length < insertOffset)
                        {
                            int visualLastColumn = lineSegment.GetVisualColumn(data, lineSegment.Length + 1);
                            int charsToInsert    = visualInsertLocation.Column - visualLastColumn;
                            int spaceCount       = charsToInsert % data.Options.TabSize;
                            textToInsert = new string ('\t', (charsToInsert - spaceCount) / data.Options.TabSize) + new string (' ', spaceCount) + text;
                            insertOffset = lineSegment.Length;
                        }
                        else
                        {
                            textToInsert = text;
                        }
                        inserted = data.Insert(lineSegment.Offset + insertOffset, textToInsert);
                    }
                }
                else
                {
                    offset   = version.MoveOffsetTo(data.Document.Version, offset);
                    inserted = data.PasteText(offset, text, copyData, ref undo);
                }
                data.FixVirtualIndentation(startLine);
            } finally {
                undo.Dispose();
            }
            return(inserted);
        }
All Usage Examples Of Mono.TextEditor.TextEditorData::DeleteSelectedText