Class TextEdit
Denotes an edit for text
public class TextEdit : IEquatable<TextEdit>
- Inheritance
-
TextEdit
- Implements
- Inherited Members
Constructors
TextEdit(ParsePosition, ParsePosition, string[])
Creates a new text edit
public TextEdit(ParsePosition start, ParsePosition end, string[] newText)
Parameters
startParsePositionthe start of the edit
endParsePositionthe end of the edit
newTextstring[]the new text inserted between start and end
Exceptions
- ArgumentException
thrown if start is after end
Properties
End
Gets the end of the edit
public ParsePosition End { get; }
Property Value
EndAfterEdit
Gets the end position after the edit has been applied
public ParsePosition EndAfterEdit { get; }
Property Value
NewText
Gets the new text inserted between start and end
public string[] NewText { get; }
Property Value
- string[]
Start
Gets the start of the edit
public ParsePosition Start { get; }
Property Value
Methods
AdjustPosition(ParsePosition)
Adjusts the given position due to the current text edit
public ParsePosition AdjustPosition(ParsePosition position)
Parameters
positionParsePositionthe incoming position
Returns
- ParsePosition
the position after the text edit has been applied. Throws if the position is inside the text edit
AdjustPosition(ParsePosition, bool)
Adjusts the given position due to the current text edit
public ParsePosition AdjustPosition(ParsePosition position, bool throwIfInvalid)
Parameters
positionParsePositionthe incoming position
throwIfInvalidboolif true, an exception is thrown if the position is inside the edit. Otherwise, the end of the edit is returned.
Returns
- ParsePosition
the position after the text edit has been applied.
Apply(string[])
Applies the text edit to the given input
public string[] Apply(string[] input)
Parameters
inputstring[]an input array of string lines
Returns
- string[]
a text array including the changes
Equals(TextEdit)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(TextEdit other)
Parameters
otherTextEditAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
UpdatePosition(ref ParsePosition)
Updates the position after applying this edit. Only Updates the Postion if it is fully after the Edit.
public void UpdatePosition(ref ParsePosition position)
Parameters
positionParsePositionThe position to update.