TextSource Class
Definition
Represents class that provides interface between edited text and Edit control.
Implements
Syntax
[ToolboxBitmap(typeof(TextEditor), "Images.TextSource.bmp")]
public class TextSource : Component, IComponent, IDisposable, ITextSource, IEdit, INavigate, IUndo, ITextNotify, INotify, IUpdate, INotifier, ITextImport, IImport, ITextExport, IExport, IHyperText, ISpelling, IBraceMatching, ITextParsing, ITextSnippets, ITextErrors, ITextThread, INotifyPropertyChanged
Remarks
TextSource is a non-visual component designed to store and manipulate text content displayed in the TextEditor control. TextSource allows you to separate data from visual controls and provides features like multiple views of the text.
Here are some of the essential features provided by the TextSource:
- Text editing
- Navigation
- Importing and Exporting
- Undo and Redo
- HyperText handling
- Integrating with spell-checker engines
- Handling matching braces
- Integrating with ISyntaxParser for text parsing
Examples
Here is how to declare a TextSource from the C# code:
using System;
using System.Windows;
using Alternet.Editor.Wpf;
public partial class MainWindow : Window
{
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var textSource = new TextSource();
textSource.LoadFile("myfile.txt");
textSource.MoveToLine(textSource.Lines.Count - 1);
textSource.NewLine();
}
}
Here is how to declare a TextSource from the Visual Basic code:
Imports System
Imports System.Windows
Imports Alternet.Editor.Wpf
Partial Public Class MainWindow
Inherits Window
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim textSource = New TextSource()
textSource.LoadFile("myfile.txt")
textSource.MoveToLine(textSource.Lines.Count - 1)
textSource.NewLine()
End Sub
End Class
Constructors
TextSource() | Initializes a new instance of the |
TextSource(IContainer) | Initializes a new instance of the |
Properties
ActiveEdit | Gets or sets an object that represent currently active (focused) |
AllowUndo | |
AutoInsertSnippet | Gets or sets current |
BookMarks | Represents an object that implements |
BracesOptions | Gets or sets options specifying appearance and behavior of matching braces within Edit control. |
CheckSpelling | Gets or sets a value indicating whether the document can check spelling for its content. |
ClosingBraces | Gets or sets an array of characters each one representing a closing brace. |
CodeSnippets | Gets or sets |
CurrentSnippet | Gets or sets current |
Edits | Represents a collection of |
FileName | Gets or sets name of file that holds text source content. |
FirstChanged | Represents index of the first changed line. |
GroupUndo | |
HasSpelling | Gets boolean value indicating that editor has external spell checker assigned. |
HighlightHyperText | Gets or sets a value indicating whether hypertext in the text should be highlighted. |
HighlightMatchingBlocks | Specifies that edit control should highlight found block matches. |
HighlightReferences | Specifies that edit control should highlight find references. |
IndentOptions | Gets or sets |
LastChanged | Represents index of the last changed line. |
Lexer | Gets or sets object that can perform lexical analysis of the text source content. |
Lines | Represents the object that implements |
LineStyles | Represents an object that implements |
LineTerminator | Gets or sets a string value that terminates line. |
MatchingBlocks | Gets or sets |
MaxLength | Specifies the maximum number of characters that can be entered into the edit control. |
Modified | Gets or sets a value indicating whether the control's text content is modified. |
ModifiedLineRegions | Gets modified lines information, grouped in regions. |
ModifiedLines | Gets modified lines information. |
NavigateOptions | Gets or sets navigating options. |
OpenBraces | Gets or sets an array of characters each one representing an open brace. |
OptimizedForMemory | Specifies whether internal text representation should optimized memory usage. |
Overwrite | Gets or sets a value indicating whether the inserted text overwrites existing text. |
ParserLine | Gets the line currently parsed by the attached Lexer, when text source performs syntax parsing of the text. |
Position | Gets or sets current position within the control's text content. |
PrevPosition | Gets previous position within the control's text content. |
ReadOnly | Gets or sets a value indicating whether the control's content is read-only. |
RedoList | Provides an indexed access to redo data. |
References | Gets or sets |
SearchResults | Gets or sets |
SelectBlockRect | Represents a rectangular block of selected text. |
SingleLineMode | Gets or sets a value indicating whether the control accepts only one line of the text. |
SnippetUpdateCount | |
SpellDelimiters | Gets or sets an array of chars used to separate words in a text. |
SpellDelimiterString | Gets or sets |
SpellTable | Represents a hash table containing delimiters. |
State | Gets or sets last changes to the text stored in the text source. |
Strings | Gets or sets text source content in the form of string array. |
StructureGuideLines | Represents a syntax errors collection. |
SymbolReference | Gets or sets |
SyntaxErrors | Represents a syntax errors collection. |
TempBraceRects | |
Text | Gets or sets text source content as a single string with the individual strings delimited by carriage returns. |
ThreadAction | Returns method executed in thread when parsing. |
UndefinedSections | |
UndoAfterSave | |
UndoLimit | Gets or sets a value that limits number of undo operations. |
UndoList | Provides an indexed access to undo data. |
UndoNavigations | |
UndoOptions | Gets or sets options for undo and redo operations. |
UndoUpdateCount | Keeps track of calls to |
UpdateCount | Keeps track of calls to |
UpdatePositionCount | |
UrlTable | Represents hash table containing hyper-text characters. |
Methods
AbsolutePositionToTextPoint(Int32) | Converts given absolute position to position as Point value. |
AddNotifier(INotifier) | Adds new handler to respond for notification. |
AddTextChange(String, Int32) | |
AddUndo(UndoOperation, Object) | Stores undo operation in the appropriate list. |
BeginUndoUpdate() | Allows to consider number of undo redo operations as single operation, until calling |
BeginUpdate() | Prevents object state updating until calling |
BeginUpdate(UpdateReason) | Prevents object state updating until calling |
BeginUpdateSnippet() | Prevents the Edit control from updating snippets until the |
BlockDeleting(Point, Int32) | |
BlockDeleting(Rectangle) | |
BreakLine(Boolean) | Breaks current line into two lines. |
CanDeleteBlock(Rectangle) | |
CanRedo() | Indicating whether the redo operation can be performed. |
CanUndo() | Indicating whether the undo operation can be performed. |
Clear() | Clears content of the |
ClearRedo() | Clears list of redo operations. |
ClearTrackChanges() | |
ClearUndo() | Clears list of undo operations. |
CreateBookMarks() | |
CreateCodeSnippets() | |
CreateContentDividers() | |
CreateLineStyles() | |
CreateStringItem(String) | Create a new |
CreateStructureGuideLines() | |
CreateSyntaxErrors() | |
CreateTextStrings() | |
DeleteBlock(Rectangle, Boolean) | Deletes a specified block of characters. |
DeleteBlock(Int32, Boolean) | Deletes a specified block of characters. |
DeleteLeft(Int32, Boolean) | Deletes a specified number of characters to the left of the active point. |
DeleteRight(Int32, Boolean) | Deletes a specified number of characters to the right of the active point. |
DisablePositionUpdate() | Prevents notification of changing of caret position until
calling |
DisableUndo() | Disables recording of undo/redo operations. EnableUndo() |
DisableUpdate() | Prevents object state updating until calling |
Dispose(Boolean) | |
DoCheckSpelling(IStringItem, Int32, Boolean) | |
DoHighlightMatchingBlocks(Boolean) | |
DoHighlightReferences(Boolean) | |
DoHighlightReferences(Object, EventArgs) | |
DoHighlightSymbolReferences(Boolean) | |
DoHighlightUrls(IStringItem) | |
EnablePositionUpdate() | Re-enables notification of changing of caret position
that was turn of by calling |
EnableUndo() | Re-enables recording of undo/redo operations, that was turn of by calling |
EnableUpdate() | Re-enables object state updating, that was turn of by calling |
EndUndoUpdate() | Ends undo block, that was started by |
EndUpdate() | Re-enables object state updating, that was turn of by calling |
EndUpdateSnippet() | Resumes updating snippets after updating is suspended by the |
FindClosingBrace(ref Point) | Locates closing brace. |
FindClosingBrace(ref Point, ref Int32, ref Int32) | |
FindClosingBrace(ref Int32, ref Int32) | Locates closing brace. |
FindOpenBrace(ref Point) | Locates open brace. |
FindOpenBrace(ref Point, ref Int32, ref Int32) | |
FindOpenBrace(ref Int32, ref Int32) | Locates open brace. |
FormatText() | Tries to format and outline |
FormatText(Boolean, Boolean) | Tries to format and outline |
FormatText(Boolean, Boolean, NotifyState) | |
GetCharIndexFromPosition(Point) | Converts given Point value to the index of character. |
GetCodeFixes(ISyntaxError, Boolean) | Gets code fixes for a given syntax error. |
GetCodeSnippetRangeAt(Point) | Locates code snippet at specified position. |
GetContentDividers() | |
GetErrorStyle(ISyntaxError) | |
GetFlowDocument(FlowDocumentExportOptions) | Gets FlowDocument object describes TextSource content accordingly to specified settings. |
GetIndentString() | Gets indentation string at current position. |
GetModifiedLineRegions(IEnumerable<ModifiedLine>) | |
GetPositionFromCharIndex(Int32) | Converts given character index to position as Point value. |
GetStructureGuideLines() | |
GetStructureGuideLines(Int32, IList<IRange>) | Gets list of guide lines. |
GetSyntaxErrorAt(Int32, Int32) | Gets syntax error at specified position. |
GetUndoList() | |
HighlightBraces() | Highlights braces containing caret position. UnhighlightBraces() |
HighlightBraces(Boolean) | |
HighlightCodeFixes() | Highlights code fixes if needed. |
HighlightCodeRefactors() | Highlights code fixes if needed. |
HighlightCodeSnippets() | Highlights code snippets using appropriate style. |
HighlightCodeSnippets(Boolean) | |
HighlightSearchResults(Boolean) | |
HighlightSyntaxErrors() | Highlights syntax errors. |
IncPosition(Point, Int32) | |
IndentLine() | Inserts spaces to the start of the current line.
Number of spaces is calculated from indent options or |
IndentLine(String, Boolean) | Inserts white space to the start of the current line. white space string Indicates if the change needs to be translated to the parser |
IndexOfNonWhitespaceChar(String) | |
Insert(String, Boolean) | Inserts the given string at the specified location. |
InsertBlock(ITextStrings, Boolean) | Inserts the given string collection at the specified location. |
InsertBlock(String, Boolean) | Inserts the given string at the specified location. |
InsertBlock(String[], Boolean) | Inserts the given string array at the specified location. |
InsertBlock(String[], Boolean, Boolean) | Inserts the given string array at the specified location. |
InsertFromFile(String) | Inserts the file text content at the specified location. |
InvalidateSyntaxErrors() | Invalidates highlighting of syntax errors. |
InvalidateSyntaxErrors(Boolean) | |
IsContentDivider(Int32) | Gets boolean value indicating whether text content is divided at given line. |
IsEmptyUndoList(IUndoList) | |
IsFirstSnippet(Point) | |
IsHyperText(String) | Indicates whether given text represents hypertext. |
IsSpellDelimiter(Char) | |
IsWhiteSpace(String) | |
IsWordCorrect(String) | Checks whether spelling for the given word is correct. |
IsWordCorrect(String, StringItemInfo) | |
IsWordCorrect(String, Point) | When implemented by a class, checks whether spelling for the given word is correct. |
LexStateChanged(Int32) | |
LineIsHidden(Int32) | Determines whether the given line is readonly. |
LineIsModified(Int32) | Indicates whether specified line already modified. |
LineIsModified(Int32, out Boolean) | Indicates whether specified line already modified. |
LineIsReadonly(Int32) | Determines whether the given line is readonly. |
LinesChanged(Int32, Int32) | Specifies range of lines that was changed. |
LinesChanged(Int32, Int32, Boolean) | Specifies range of lines that was changed. |
LinesChanged(Int32, Int32, Boolean, Boolean) | |
LoadFile(String) | Loads the contents of the specified file. |
LoadFile(String, IStringImport) | Loads content from the given file with specified importer. |
LoadFile(String, IStringImport, Encoding) | Loads content from the given file with specified importer and specific encoding. |
LoadFile(String, Encoding) | Loads the contents of the specified file with specified encoding. |
LoadStream(Stream) | Loads the contents of the specified stream. |
LoadStream(Stream, IStringImport) | Loads the text content from the given stream with specified importer. |
LoadStream(Stream, IStringImport, Encoding) | Loads the text content from the given stream with specified importer. |
LoadStream(Stream, Encoding) | Loads the contents of the specified stream. |
LoadStream(TextReader) | Loads the contents of the specified stream. |
LoadStream(TextReader, IStringImport) | Loads the contents of the specified stream. |
ModifiedChanged() | |
MoveTo(Point) | Moves the current position to the given position. |
MoveTo(Int32, Int32) | Moves the current position to the given position. |
MoveToChar(Int32) | Moves the current position to the specified character in the current line. |
MoveToLine(Int32) | Moves the current position to the specified line. |
MoveToLine(Int32, Int32) | Moves the current position to the specified line. |
Navigate(Int32, Int32) | Moves current position by the given offset value. |
NeedAutoComplete() | Indicates whether |
NeedCacheIndent() | Indicates whether |
NeedCodeCompletion() | Indicates whether |
NeedCodeCompletionTabs(CodeCompletionType) | Indicates code completion content can be filtered based on its priority. |
NeedCodeFixes() | Indicates whether |
NeedCodeRefactors() | Indicates whether |
NeedContentDividers() | Indicates whether |
NeedFormatText() | Indicates whether |
NeedFormatTextOnLineChange() | Indicates whether |
NeedIndentText() | Indicates whether |
NeedOutlineText() | Indicates whether |
NeedParse() | Indicates whether syntax parsing can be performed for the text, or some of formatting text elements, such as urls or braces, should be highlighted. |
NeedQuickInfoTips() | Indicates whether |
NeedReparseText() | Indicates whether |
NeedReparseTextOnLineChange() | Indicates whether |
NeedStructureGuideLines() | Indicates whether |
NeedSyntaxErrors() | Indicates whether |
NeedWorkInThread() | Indicates whether |
NewLine() | Inserts a line break at the current position. |
NewLine(ref String, Boolean) | Inserts a line break at the current position with indentation. |
NewLineAbove() | Inserts a line break above the current position. |
NewLineBelow() | Inserts a line break below the current position. |
Notification(Object, EventArgs) | Updates control's content according to parameters of notification. |
Notify(EventArgs) | Notifies all notifiers about changing source state. |
OnActiveEditChanged() | |
OnBookmarksChanged() | |
OnBracesOptionsChanged() | |
OnCheckSpellingChanged() | |
OnClosingBracesChanged() | |
OnFileNameChanged() | |
OnFormatting(Object, EventArgs) | |
OnHighlightBlockMatchChanged() | |
OnHighlightHyperTextChanged() | |
OnHighlightReferencesChanged() | |
OnIndentOptionsChanged() | |
OnLinesChanged() | |
OnLineStylesChanged() | |
OnMaxLengthChanged() | |
OnModifiedChanged() | |
OnNavigateOptionsChanged() | |
OnOpenBracesChanged() | |
OnOptimizedForMemoryChanged() | |
OnOverWriteChanged() | |
OnReadOnlyChanged() | |
OnSingleLineModeChanged() | |
OnSpellDelimitersChanged() | |
OnStateChanged() | |
OnTextChanged() | |
OnTextParsed() | |
OnTextParsed(Boolean, Boolean, Int32, Int32, NotifyState) | |
OnUndoLimitChanged() | |
OnUndoOptionsChanged() | |
OnUnhighlightBraces(Object, EventArgs) | |
ParseString(Int32) | Perform lexical analysis of the specified string. |
ParseStrings(Int32, Int32) | Perform lexical analysis specified strings. |
ParseText(Int32, IStringItem, Int32, Boolean) | |
ParseToString(Int32) | Perform lexical analysis of specified strings. |
PositionChanged(UpdateReason, Int32, Int32) | |
PositionIsReadonly(Point) | Determines whether the text at given position is readonly. |
ProcessAutoComplete(out String) | Inserts end-of-block code fragment if needed. |
Redo() | Performs the last redo operation. |
RemoveContentDividers() | |
RemoveNotifier(INotifier) | Exclude specified handler from notification handlers list. |
RemoveStructureGuidLines() | |
RemoveTrailingSpaces(Boolean, Boolean) | |
ResetBracesOptions() | Resets the |
ResetCheckSpelling() | Resets the |
ResetClosingBraces() | Resets the |
ResetHighlightHyperText() | Resets |
ResetIndentOptions() | Resets the |
ResetMaxLength() | Resets the |
ResetModified() | Resets the |
ResetNavigateOptions() | Resets the |
ResetOpenBraces() | Resets the |
ResetOverWrite() | Resets the |
ResetReadOnly() | Resets the |
ResetSingleLineMode() | Resets the |
ResetSpellDelimiters() | Resets the |
ResetUndoLimit() | Resets the |
ResetUndoOptions() | Resets the |
RestorePosition(Int32) | Restores position from stored position list by given index. |
RestorePositionWithUndo(Int32) | Restores position from stored position list by given index. |
SaveFile(String) | Saves text content to the specific file. |
SaveFile(String, IStringExport) | Saves text content to the specific file with specific exporter. |
SaveFile(String, IStringExport, Encoding) | Saves text content to the specific file with specific exporter and encoding. |
SaveFile(String, Encoding) | Saves text content to the specific file with specific encoding. |
SaveStream(Stream) | Saves the text content to the specified stream. |
SaveStream(Stream, IStringExport) | Saves the text content to the specified stream. |
SaveStream(Stream, IStringExport, Encoding) | Saves the text content to the specified stream. |
SaveStream(Stream, Encoding) | Saves the text content to the specified stream. |
SaveStream(TextWriter) | Saves the text content to the specified stream. |
SaveStream(TextWriter, IStringExport) | Saves the text content to the specified stream. |
SetLastParsed(Int32) | Updates the last parsed line and resets first changed line to it's default value. |
SetLineHidden(Int32, Boolean) | Sets readonly state for the given line. |
SetLineHidden(Int32[], Boolean) | Sets readonly state for the given line. |
SetLineReadonly(Int32, Boolean) | Sets readonly state for the given line. |
SetLineReadonly(Int32[], Boolean) | Sets readonly state for the given line. |
SetLineState(Int32[], ItemState, Boolean) | Sets item state for the given line. |
SetNavigateOptions(NavigateOptions) | Sets navigating options without validating position. |
SetTextStyle(Point, Int32, TextStyle, Boolean, Boolean) | |
SetTextStyle(Rectangle, TextStyle, Boolean, Boolean) | |
StartHighlightReferencesTimer(Boolean) | |
StartThread(ThreadProc, ThreadProc, ThreadProc, ThreadProc) | Executes action in thread. |
StartThread(Object) | |
StopHighlightReferencesTimer() | |
StopParserThread(Boolean) | |
StopThread(ThreadProc, Boolean) | Aborts executing action in thread. |
StorePosition(Point) | Stores given position to stored position list. |
StorePosition(Point, Boolean) | Stores given position to stored position list. |
StorePositionWithUndo(Point) | Stores given position to stored position list preserving it for undo. |
StringsChanged(Object, EventArgs) | |
SupportsAsyncParsing() | |
TempHighlightBraces(Rectangle[]) | Temporary highlights all text within the area specified by rects. TempUnhighlightBraces() |
TempHighlightMatchingBlocks() | Highlights block match. |
TempHighlightReferences() | Highlights found references. |
TempHighlightSearchResults(IRangeList) | Highlights search results. |
TempUnhighlightBraces() | Cancels text highlighting turned on using |
TempUnhighlightBraces(Boolean) | Unhighlights temporary braces areas. |
TempUnhighlightReferences() | Unhighlights references highlighted with previous call of TempHighlightReferences. |
TempUnhighlightSearchResults() | Unhighlights search results highlighted with previous call of TempHighlightSearchResults. |
TextPointToAbsolutePosition(Point) | Converts given Point value to the absolute position. |
TrackChanges() | |
TrackChanges(IUndoList, ISortList<TextSource.TrackChange>) | |
UnBreakLine(Boolean) | Concatenates lines at current position. |
Undo(IUndoData, Boolean) | Performs the single undo operation. |
Undo(Boolean) | Performs the last undo operation. |
UnhighlightBraces() | Unhighlights braces containing caret position. HighlightBraces() |
UnhighlightBraces(Boolean) | Unhighlights braces. |
UnhighlightCodeSnippets() | Removes highlighting from code snippets and clears snippet collection. |
UnhighlightCodeSnippets(Boolean) | |
UnhighlightMatchingBlocks(Boolean) | |
UnhighlightReferences(Boolean) | |
UnhighlightSearchResults(Boolean) | |
UnhighlightSymbolReferences(Boolean) | |
UnhighlightSyntaxErrors() | Removes syntax errors highlighting. |
UnhighlightSyntaxErrors(ISyntaxErrors, Boolean) | |
UnhighlightSyntaxErrors(ISyntaxErrors, Int32, Boolean) | |
Update() | Updates an object state. |
UpdateParsed(Int32, Int32) | |
ValidatePosition(ref Point) | Validates given position within control's text content. |
Events
HyperText | Occurs when a control needs checking whether some string represents hypertext. |
PropertyChanged | |
UndoEvent | Occurs when undo/redo operation performed. |
WordSpell | Occurs when spelling of some word within the text needs checking. |