TextDocumentBase Class
Represents a text document.
public abstract class TextDocumentBase : ITextDocument, INotifyPropertyChanged
- Inheritance:
- System.Object Object
- Derived:
- CodeDocument
- Implements:
- ITextDocument
Constructors
TextDocumentBase()
Initializes a new instance of the TextDocumentBase
class.
protected TextDocumentBase()
Properties
AutoCharacterCasing
Gets or sets how to modify the case of text that is inserted into the document.
public CharacterCasing AutoCharacterCasing { get; set; }
Property Value
- CharacterCasing:
A CharacterCasing indicating the desired case of inserted text.
AutoConvertTabsToSpaces
Gets or sets whether to convert tabs to spaces when the Tab key is pressed or indenting occurs.
public bool AutoConvertTabsToSpaces { get; set; }
Property Value
- System.Boolean:
true
if tabs should be converted to spaces when the Tab key is pressed or indenting occurs; otherwise,false
. The default value isfalse
.
Remarks
The number of spaces inserted is indicated by the TabSize property.
CurrentSnapshot
Gets the ITextSnapshot that contains the current text of the document.
public ITextSnapshot CurrentSnapshot { get; }
Property Value
- ITextSnapshot:
The ITextSnapshot that contains the current text of the document.
FileName
Gets or sets the name of the file currently loaded in the document.
public string FileName { get; set; }
Property Value
- System.String:
The name of the file currently loaded in the document.
Remarks
This property is automatically set whenever a LoadFile(String) overload is called that accepts a file path.
IsModified
Gets or sets whether the document has been modified.
public bool IsModified { get; set; }
Property Value
- System.Boolean:
true
if the document has been modified; otherwise,false
.
Remarks
This flag is reset to false
when the ActiproSoftware.Text property is set, or when a SaveFile(String, LineTerminator)
overload is used that accepts a path matching the current FileName property value.
IsReadOnly
Gets or sets whether the entire document is flagged as read-only.
public bool IsReadOnly { get; set; }
Property Value
- System.Boolean:
true
if the entire document is flagged as read-only; otherwise,false
. The default value isfalse
.
Remarks
When read-only, the document's contents should not be editable.
TabSize
Gets or sets the distance in spaces between tab stops.
public int TabSize { get; set; }
Property Value
- System.Int32:
The distance in spaces between tab stops. The default value is
4
spaces. The maximum tab size is32
.
UndoHistory
Gets an IUndoHistory that provides access to undo and redo functionality for the document.
public IUndoHistory UndoHistory { get; }
Property Value
- IUndoHistory:
An IUndoHistory that provides access to undo and redo functionality for the document.
Methods
AddTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs>, EventHandlerPriority)
Adds an event handler for the TextChanged event using the specified priority level.
public void AddTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs> handler, EventHandlerPriority priority)
Parameter | Type | Description |
---|---|---|
handler | System.EventHandler<TextSnapshotChangedEventArgs> | The delegate handler. |
priority | EventHandlerPriority | A EventHandlerPriority specifying the priority level. |
AddTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs>, EventHandlerPriority)
Adds an event handler for the TextChanging event using the specified priority level.
public void AddTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs> handler, EventHandlerPriority priority)
Parameter | Type | Description |
---|---|---|
handler | System.EventHandler<TextSnapshotChangingEventArgs> | The delegate handler. |
priority | EventHandlerPriority | A EventHandlerPriority specifying the priority level. |
AppendText(ITextChangeType, String)
Appends text to the end of the CurrentSnapshot text.
public bool AppendText(ITextChangeType type, string text)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
text | System.String | The text to append to the current contents of the snapshot. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds an append operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
AppendText(ITextChangeType, String, ITextChangeOptions)
Appends text to the end of the CurrentSnapshot text and allows for the specification of other options.
public bool AppendText(ITextChangeType type, string text, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
text | System.String | The text to append to the current contents of the snapshot. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds an append operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType, ITextChangeOptions) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
CreateTextChange(ITextChangeType)
Creates an ITextChange based on the CurrentSnapshot, whereby any following calls to methods such as ITextChange.ReplaceText(Int32, Int32, String) are grouped into the text change as operations and sequentially executed upon a ITextChange.Apply() call.
public ITextChange CreateTextChange(ITextChangeType type)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
Returns
- ITextChange:
The ITextChange that was created.
Remarks
The ITextChange.Apply() method must be called to apply the queued operations to the document.
CreateTextChange(ITextChangeType, ITextChangeOptions)
Creates an ITextChange based on the CurrentSnapshot, whereby any following calls to methods such as ITextChange.ReplaceText(Int32, Int32, String) are grouped into the text change as operations and sequentially executed upon a ITextChange.Apply() call.
public ITextChange CreateTextChange(ITextChangeType type, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- ITextChange:
The ITextChange that was created.
Remarks
The ITextChange.Apply() method must be called to apply the queued operations to the document.
DeleteText(ITextChangeType, TextRange)
Performs a delete text change in the CurrentSnapshot.
public bool DeleteText(ITextChangeType type, TextRange textRange)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
textRange | TextRange | The TextRange of offsets to delete. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a delete operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
DeleteText(ITextChangeType, TextRange, ITextChangeOptions)
Performs a delete text change in the CurrentSnapshot and allows for the specification of other options.
public bool DeleteText(ITextChangeType type, TextRange textRange, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
textRange | TextRange | The TextRange of offsets to delete. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a delete operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType, ITextChangeOptions) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
DeleteText(ITextChangeType, Int32, Int32)
Performs a delete text change in the CurrentSnapshot.
public bool DeleteText(ITextChangeType type, int offset, int length)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
offset | System.Int32 | The starting offset at which to delete. |
length | System.Int32 | The number of characters to delete. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a delete operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
DeleteText(ITextChangeType, Int32, Int32, ITextChangeOptions)
Performs a delete text change in the CurrentSnapshot and allows for the specification of other options.
public bool DeleteText(ITextChangeType type, int offset, int length, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
offset | System.Int32 | The starting offset at which to delete. |
length | System.Int32 | The number of characters to delete. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a delete operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType, ITextChangeOptions) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
GetReadOnlyRegions(TextRange)
Returns the collection of read-only region tag snapshot ranges.
protected virtual IEnumerable<TagSnapshotRange<IReadOnlyRegionTag>> GetReadOnlyRegions(TextRange textRange)
Parameter | Type | Description |
---|---|---|
textRange | TextRange | The text range relative to the current snapshot for which to locate read-only regions. |
Returns
- System.Collections.Generic.IEnumerable<TagSnapshotRange<IReadOnlyRegionTag>>:
The collection of read-only region tag snapshot ranges.
GetTextReplacementInsertText(ITextChangeOperation)
Returns the scrubbed text that should be inserted for an entire text replacement ITextChangeOperation.
protected virtual string GetTextReplacementInsertText(ITextChangeOperation operation)
Parameter | Type | Description |
---|---|---|
operation | ITextChangeOperation | The ITextChangeOperation containing default text to insert. |
Returns
- System.String:
The text to insert.
Remarks
This method can be overridden to scrub the text to insert, such as remove trailing whitespace, etc.
By default it returns a null
, meaning to use the unscrubbed InsertedText value.
InsertText(ITextChangeType, Int32, String)
Performs an insert text change in the CurrentSnapshot at the specified offset.
public bool InsertText(ITextChangeType type, int offset, string text)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
offset | System.Int32 | The offset at which to insert. |
text | System.String | The text to insert. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds an insert operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
InsertText(ITextChangeType, Int32, String, ITextChangeOptions)
Performs an insert text change in the CurrentSnapshot at the specified offset and allows for the specification of other options.
public bool InsertText(ITextChangeType type, int offset, string text, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
offset | System.Int32 | The offset at which to insert. |
text | System.String | The text to insert. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds an insert operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType, ITextChangeOptions) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
IsTextRangeReadOnly(TextRange)
Returns whether any character in the specified TextRange is flagged as read-only.
public bool IsTextRangeReadOnly(TextRange textRange)
Parameter | Type | Description |
---|---|---|
textRange | TextRange | The TextRange to examine. |
Returns
- System.Boolean:
true
if any character in the specified TextRange is flagged as read-only; otherwise,false
.
LoadFile(Stream, Encoding)
Loads document text from a System.IO.Stream using the specified encoding.
public LineTerminator LoadFile(Stream stream, Encoding encoding)
Parameter | Type | Description |
---|---|---|
stream | System.IO.Stream | The System.IO.Stream from which to load. |
encoding | System.Text.Encoding | The System.Text.Encoding to use when loading the file. |
Returns
- LineTerminator:
A LineTerminator indicating the line terminator of the file that was loaded.
LoadFile(String)
Loads document text from a file, using the default UTF-8 character encoding.
public LineTerminator LoadFile(string path)
Parameter | Type | Description |
---|---|---|
path | System.String | The full path of the file from which to load. |
Returns
- LineTerminator:
A LineTerminator indicating the line terminator of the file that was loaded.
Remarks
This method updates the value of the FileName property.
LoadFile(String, Encoding)
Loads document text from a file using the specified encoding.
public LineTerminator LoadFile(string path, Encoding encoding)
Parameter | Type | Description |
---|---|---|
path | System.String | The full path of the file from which to load. |
encoding | System.Text.Encoding | The System.Text.Encoding to use when loading the file. |
Returns
- LineTerminator:
A LineTerminator indicating the line terminator of the file that was loaded.
Remarks
This method updates the value of the FileName property.
NotifyPropertyChanged(String)
Notifies that a property's value has changed.
protected void NotifyPropertyChanged(string name)
Parameter | Type | Description |
---|---|---|
name | System.String | The name of the property. |
OnFileNameChanged(StringPropertyChangedEventArgs)
Raises the FileNameChanged
event.
protected virtual void OnFileNameChanged(StringPropertyChangedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | StringPropertyChangedEventArgs | An |
OnIsModifiedChanged(EventArgs)
Raises the IsModifiedChanged
event.
protected virtual void OnIsModifiedChanged(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | System.EventArgs | An |
OnIsReadOnlyChanged(EventArgs)
Raises the IsReadOnlyChanged
event.
protected virtual void OnIsReadOnlyChanged(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | System.EventArgs | An |
OnTabSizeChanged(EventArgs)
Raises the TabSizeChanged
event.
protected virtual void OnTabSizeChanged(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | System.EventArgs | An |
OnTextChanged(TextSnapshotChangedEventArgs)
Raises the TextChanged event.
protected virtual void OnTextChanged(TextSnapshotChangedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TextSnapshotChangedEventArgs | A |
OnTextChanging(TextSnapshotChangingEventArgs)
Raises the TextChanging event.
protected virtual void OnTextChanging(TextSnapshotChangingEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TextSnapshotChangingEventArgs | A |
RemoveTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs>, EventHandlerPriority)
Removes an event handler for the TextChanged event using the specified priority level.
public void RemoveTextChangedEventHandler(EventHandler<TextSnapshotChangedEventArgs> handler, EventHandlerPriority priority)
Parameter | Type | Description |
---|---|---|
handler | System.EventHandler<TextSnapshotChangedEventArgs> | The delegate handler. |
priority | EventHandlerPriority | A EventHandlerPriority specifying the priority level. |
RemoveTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs>, EventHandlerPriority)
Removes an event handler for the TextChanging event using the specified priority level.
public void RemoveTextChangingEventHandler(EventHandler<TextSnapshotChangingEventArgs> handler, EventHandlerPriority priority)
Parameter | Type | Description |
---|---|---|
handler | System.EventHandler<TextSnapshotChangingEventArgs> | The delegate handler. |
priority | EventHandlerPriority | A EventHandlerPriority specifying the priority level. |
ReplaceAll(ISearchOptions)
Performs a replace all operation in the CurrentSnapshot.
public ISearchResultSet ReplaceAll(ISearchOptions options)
Parameter | Type | Description |
---|---|---|
options | ISearchOptions | The ISearchOptions to use. |
Returns
- ISearchResultSet:
An ISearchResultSet that specifies the result of the operation.
ReplaceAll(ISearchOptions, TextRange[])
Performs a replace all operation in the CurrentSnapshot over a specific range of the snapshot.
public ISearchResultSet ReplaceAll(ISearchOptions options, params TextRange[] searchTextRanges)
Parameter | Type | Description |
---|---|---|
options | ISearchOptions | The ISearchOptions to use. |
searchTextRanges | TextRange[] | The TextRange array of offsets to search.
If everything should be searched, specify the range |
Returns
- ISearchResultSet:
An ISearchResultSet that specifies the result of the operation.
ReplaceNext(ISearchOptions, Int32, Boolean)
Performs a replace next operation in the CurrentSnapshot.
public ISearchResultSet ReplaceNext(ISearchOptions options, int startOffset, bool canWrap)
Parameter | Type | Description |
---|---|---|
options | ISearchOptions | The ISearchOptions to use. |
startOffset | System.Int32 | The offset at which to start the search. |
canWrap | System.Boolean | Whether the search can wrap at the end of the search text range. |
Returns
- ISearchResultSet:
An ISearchResultSet that specifies the result of the operation.
ReplaceNext(ISearchOptions, Int32, Boolean, TextRange)
Performs a replace next operation in the CurrentSnapshot over a specific range of the snapshot.
public ISearchResultSet ReplaceNext(ISearchOptions options, int startOffset, bool canWrap, TextRange searchTextRange)
Parameter | Type | Description |
---|---|---|
options | ISearchOptions | The ISearchOptions to use. |
startOffset | System.Int32 | The offset at which to start the search. |
canWrap | System.Boolean | Whether the search can wrap at the end of the search text range. |
searchTextRange | TextRange | The TextRange of offsets to search.
If all should be searched, specify the range |
Returns
- ISearchResultSet:
An ISearchResultSet that specifies the result of the operation.
ReplaceText(ITextChangeType, TextRange, String)
Performs a replace text change in the CurrentSnapshot at the specified offset.
public bool ReplaceText(ITextChangeType type, TextRange textRange, string text)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
textRange | TextRange | The TextRange of offsets to delete. |
text | System.String | The text to insert. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a replace operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
ReplaceText(ITextChangeType, TextRange, String, ITextChangeOptions)
Performs a replace text change in the CurrentSnapshot at the specified offset and allows for the specification of other options.
public bool ReplaceText(ITextChangeType type, TextRange textRange, string text, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
textRange | TextRange | The TextRange of offsets to delete. |
text | System.String | The text to insert. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a replace operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType, ITextChangeOptions) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
ReplaceText(ITextChangeType, Int32, Int32, String)
Performs a replace text change in the CurrentSnapshot at the specified offset.
public bool ReplaceText(ITextChangeType type, int offset, int length, string text)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
offset | System.Int32 | The offset at which to insert. |
length | System.Int32 | The number of characters to delete before inserting the text. |
text | System.String | The text to insert. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a replace operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
ReplaceText(ITextChangeType, Int32, Int32, String, ITextChangeOptions)
Performs a replace text change in the CurrentSnapshot at the specified offset and allows for the specification of other options.
public bool ReplaceText(ITextChangeType type, int offset, int length, string text, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
offset | System.Int32 | The offset at which to insert. |
length | System.Int32 | The number of characters to delete before inserting the text. |
text | System.String | The text to insert. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a replace operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType, ITextChangeOptions) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
SaveFile(Stream, Encoding, LineTerminator)
Saves document text to a System.IO.Stream using the specified encoding.
public void SaveFile(Stream stream, Encoding encoding, LineTerminator lineTerminator)
Parameter | Type | Description |
---|---|---|
stream | System.IO.Stream | The System.IO.Stream to write to. |
encoding | System.Text.Encoding | The System.Text.Encoding to use when loading the file. |
lineTerminator | LineTerminator | A LineTerminator specifying the output format. |
SaveFile(String, LineTerminator)
Saves document text to a UTF-8 encoded file.
public void SaveFile(string path, LineTerminator lineTerminator)
Parameter | Type | Description |
---|---|---|
path | System.String | The full path of the file of which to save. |
lineTerminator | LineTerminator | A LineTerminator specifying the output format. |
Remarks
The IsModified property is set to false
if the specified file path is the same as the
FileName property's current value.
SaveFile(String, Encoding, LineTerminator)
Saves document text to a file using the specified encoding.
public void SaveFile(string path, Encoding encoding, LineTerminator lineTerminator)
Parameter | Type | Description |
---|---|---|
path | System.String | The full path of the file of which to save. |
encoding | System.Text.Encoding | The System.Text.Encoding to use when saving the file. |
lineTerminator | LineTerminator | A LineTerminator specifying the output format. |
Remarks
The IsModified property is set to false
if the specified file path is the same as the
FileName property's current value.
SetHeaderAndFooterText(String, String)
Sets the HeaderText and FooterText, and creates a new snapshot with the results.
public bool SetHeaderAndFooterText(string headerText, string footerText)
Parameter | Type | Description |
---|---|---|
headerText | System.String | The new header text value. |
footerText | System.String | The new footer text value. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
SetText(ITextChangeType, String)
Replaces all the text in the CurrentSnapshot.
public bool SetText(ITextChangeType type, string text)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
text | System.String | The text to insert. Pass an empty string to "clear" the snapshot text. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a set text operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
SetText(ITextChangeType, String, ITextChangeOptions)
Replaces all the text in the CurrentSnapshot and allows for the specification of other options.
public bool SetText(ITextChangeType type, string text, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
type | ITextChangeType | An ITextChangeType specifying the type of change. |
text | System.String | The text to insert. Pass an empty string to "clear" the snapshot text. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
This method creates an ITextChange for the current snapshot, adds a set text operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType, ITextChangeOptions) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
SetText(String)
Replaces all the text in the CurrentSnapshot and marks the operation as a programmatic replacement.
public bool SetText(string text)
Parameter | Type | Description |
---|---|---|
text | System.String | The text to insert. Pass an empty string to "clear" the snapshot text. |
Returns
- System.Boolean:
true
if a text change was allowed to occur; otherwise,false
.
Remarks
A programmatic text replacement means that the undo history will be cleared, and any attached editors will reset the caret to offset 0
.
This method creates an ITextChange for the current snapshot, adds a set text operation, and immediately applies it. If you will be executing multiple text change operations in a row, for improved performance it is recommended that you call the CreateTextChange(ITextChangeType) method instead, add operations to the returned ITextChange, and then apply the text change.
See Also
Events
FileNameChanged
Occurs after the value of the FileName property has changed.
public event EventHandler<StringPropertyChangedEventArgs> FileNameChanged
Event Type
- System.EventHandler<StringPropertyChangedEventArgs>
IsModifiedChanged
Occurs after the value of the IsModified property has changed.
public event EventHandler IsModifiedChanged
Event Type
- System.EventHandler
IsReadOnlyChanged
Occurs after the value of the IsReadOnly property has changed.
public event EventHandler IsReadOnlyChanged
Event Type
- System.EventHandler
PropertyChanged
Occurs when a property value is changed.
public event PropertyChangedEventHandler PropertyChanged
Event Type
- System.ComponentModel.PropertyChangedEventHandler
TabSizeChanged
Occurs after the value of the TabSize property has changed.
public event EventHandler TabSizeChanged
Event Type
- System.EventHandler
TextChanged
Occurs after a text change occurs to this document.
public event EventHandler<TextSnapshotChangedEventArgs> TextChanged
Event Type
- System.EventHandler<TextSnapshotChangedEventArgs>
TextChanging
Occurs before a text change occurs to this document.
public event EventHandler<TextSnapshotChangingEventArgs> TextChanging
Event Type
- System.EventHandler<TextSnapshotChangingEventArgs>
Inherited Members
- System.Object.ToString()
- System.Object.Equals(System.Object)
- System.Object.Equals(System.Object, System.Object)
- System.Object.ReferenceEquals(System.Object, System.Object)
- System.Object.GetHashCode()
- System.Object.GetType()
- System.Object.MemberwiseClone()