本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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 );
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例11: RemoveCharBeforeCaret
public static void RemoveCharBeforeCaret (TextEditorData data)
{
data.Remove (data.Caret.Offset - 1, 1);
data.Caret.Column--;
}
示例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 ();
}
示例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 ();
}
示例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 ();
}
}
示例15: DeleteWordBeforeCaret
static int DeleteWordBeforeCaret (TextEditorData editor)
{
int offset = editor.Caret.Offset;
int start = FindPrevWordStart (editor, offset);
editor.Remove (start, offset - start);
return start;
}