Class TextSource
- Namespace
- Alternet.Editor.TextSource
- Assembly
- Alternet.Editor.v9.dll
Represents class that provides interface between edited text and Edit control.
[ToolboxBitmap(typeof(SyntaxEdit), "Images.TextSource.Icon.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, ICodeActions
- Inheritance
-
TextSource
- Implements
- Derived
Examples
Here is how to declare a TextSource from the C# code:
using System;
using Alternet.Editor;
using Alternet.Editor.TextSource;
public partial class Form1 : Form
{
private void Form1_Load(object sender, EventArgs e)
{
var textSource = new TextSource(this.components);
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 Alternet.Editor
Imports Alternet.Editor.TextSource
Partial Public Class Form1
Inherits Form
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim textSource = New TextSource(Me.components)
textSource.LoadFile("myfile.txt")
textSource.MoveToLine(textSource.Lines.Count - 1)
textSource.NewLine()
End Sub
End Class
Remarks
TextSource is a non-visual component designed to store and manipulate text content displayed in the SyntaxEdit 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
Constructors
- TextSource()
Initializes a new instance of the
TextSource
class with default settings.
- TextSource(IContainer)
Initializes a new instance of the
TextSource
class with specified container.
Properties
- ActiveEdit
Gets or sets an object that represent currently active (focused)
ISyntaxEdit
control linked to the text source.
- AutoInsertSnippet
Gets or sets the current
ICodeSnippetRange
object.
- BookMarks
Represents an object that implements
IBookMarks
interface holding collection ofIBookMark
objects each determining particular bookmark within the text source.
- BracesOptions
Gets or sets options specifying appearance and behaviour 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
ICodeSnippetRangeList
for Edit control.
- CurrentSnippet
Gets or sets the current
ICodeSnippetRange
object.
- Edits
Represents a collection of
ISyntaxEdit
controls linked to the text source.
- FileName
Gets or sets the name of the file that holds text source content.
- FirstChanged
Represents index of the first changed line.
- GlobalSearch
Specifies whether search should be global.
- 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 found references.
- IndentOptions
Gets or sets
Alternet.Editor.TextSource.IndentOptions
for this class, allowing to customize behavior of Edit control when user presses Enter to insert new text line.
- LastChanged
Represents index of the last changed line.
- Lexer
Gets or sets an object that can perform lexical analysis of the text source content.
- LineStyles
Represents an object that implements
ILineStyles
interface holding collection of line styles for this document.
- LineTerminator
Gets or sets a string value that terminates line.
- Lines
Represents the object that implements
ITextStrings
interface containing collection of strings determining text source content.
- MatchingBlocks
Gets or sets
IRangeList
of matching begin/end blocks for Edit control.
- 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
IRangeList
of found references for Edit control.
- SearchResults
Gets or sets
IRangeList
of search results for Edit control.
- SelectBlockRect
Represents a rectangular block of selected text.
- SelectedWords
Gets or sets
IRangeList
of search results for Edit control.
- SingleLineMode
Gets or sets a value indicating whether the control accepts only one line of the text.
- SpellDelimiterString
Gets or sets
Delimiters
as a single string.
- SpellDelimiters
Gets or sets an array of chars used to separate words in a text.
- 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
IRange
of the symbol reference for Edit control.
- SyntaxErrors
Represents a syntax errors collection.
- 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.
- UndoLimit
Gets or sets a value that limits number of undo operations.
- UndoList
Provides an indexed access to undo data.
- UndoOptions
Gets or sets options for undo and redo operations.
- UndoUpdateCount
Keeps track of calls to
BeginUndoUpdate
andEndUndoUpdate
so that they can be nested.
- UpdateCount
Keeps track of calls to
BeginUpdate
andEndUpdate
so that they can be nested.
- UrlTable
Represents hash table containing hyper-text characters.
Methods
- AbsolutePositionToTextPoint(int)
Converts given absolute position to position as Point value.
- AddNotifier(INotifier)
Adds new handler to respond for notification.
- AddUndo(UndoOperation, object)
Stores undo operation in the appropriate list.
- BeginUndoUpdate()
Allows to consider number of undo redo operations as single operation, until calling
EndUndoUpdate
method.
- BeginUpdate()
Prevents object state updating until calling
EndUpdate
method.
- BeginUpdate(UpdateReason)
Prevents object state updating until calling
EndUpdate
method.
- BeginUpdateSnippet()
Prevents the Edit control from updating snippets until the
EndUpdateSnippet
method is called.
- BreakLine(bool)
Breaks current line into two lines.
- CanDeleteBlock(Rectangle)
Determines if a specified block can be deleted.
- CanRedo()
Indicating whether the redo operation can be performed.
- CanUndo()
Indicating whether the undo operation can be performed.
- CancelParsing()
Stops formatting timer.
- Clear()
Clears content of the
TextSource
- ClearRedo()
Clears list of redo operations.
- ClearUndo()
Clears list of undo operations.
- CreateStringItem(string)
Create a new
IStringItem
object containing specified text.
- DeleteBlock(Rectangle, bool)
Deletes a specified block of characters.
- DeleteBlock(int, bool)
Deletes a specified block of characters.
- DeleteLeft(int, bool)
Deletes a specified number of characters to the left of the active point.
- DeleteRight(int, bool)
Deletes a specified number of characters to the right of the active point.
- DisablePositionUpdate()
Prevents notification of changing of caret position until calling
EnablePositionUpdate
method.
- DisableUndo()
Disables recording of undo/redo operations. EnableUndo()
- DisableUpdate()
Prevents object state updating until calling
EnableUpdate
method.
- Dispose(bool)
Releases the unmanaged resources used by the Component and optionally releases the managed resources.
- EnablePositionUpdate()
Re-enables notification of changing of caret position that was turn of by calling
DisablePositionUpdate
method.
- EnableUndo()
Re-enables recording of undo/redo operations, that was turn of by calling
DisableUndo
method. DisableUndo()
- EnableUpdate()
Re-enables object state updating, that was turn of by calling
DisableUpdate
method. Using DisableUpdate/EnableUpdate to prevent notifying about updating the object state.
- EndUndoUpdate()
Ends undo block, that was started by
BeginUndoUpdate
method.
- EndUpdate()
Re-enables object state updating, that was turn of by calling
BeginUpdate
method.
- EndUpdateSnippet()
Resumes updating snippets after updating is suspended by the
BeginUpdateSnippet
method.
- FindClosingBrace(ref Point)
Locates closing brace.
- FindClosingBrace(ref int, ref int)
Locates closing brace.
- FindCodeActions(Point, Point, Point, ISyntaxError, bool)
Locates and highlights available code fixes and code refactors for given position in the texts.
- FindOpenBrace(ref Point)
Locates open brace.
- FindOpenBrace(ref int, ref int)
Locates open brace.
- FormatText()
Tries to format and outline
TextSource
text using attachedLexer
.
- FormatText(bool, bool)
Tries to format and outline
Indicates if parsing should be performed without instantiating parser thread. Indicates if attached editors should be notified on reparsingTextSource
text using attachedLexer
.
- GetCharIndexFromPosition(Point)
Converts given Point value to the index of character.
- GetCodeFixes(ISyntaxError, bool)
Gets code fixes for a given syntax error.
- GetCodeFixesAsync(ISyntaxError, bool, CancellationToken)
Gets code fixes for a given syntax error in async mode.
- GetCodeSnippetRangeAt(Point)
Locates code snippet at specified position.
- GetIndentString()
Gets indentation string at current position.
- GetPositionFromCharIndex(int)
Converts given character index to position as Point value.
- GetStructureGuideLines(int, IList<IRange>)
Gets list of guide lines.
- GetSyntaxErrorAt(int, int)
Gets syntax error at specified position.
- HasCodeFixes(ISyntaxError, bool)
Determines if code fixes are available for a given syntax error.
- HasCodeFixesAsync(ISyntaxError, bool, CancellationToken)
Determines if code fixes are available for a given syntax error in async mode.
- HighlightBraces()
Highlights braces containing caret position. UnhighlightBraces()
- HighlightCodeActions()
Highlights code fixes if needed.
- HighlightCodeSnippets()
Highlights code snippets using appropriate style.
- HighlightSyntaxErrors()
Highlights syntax errors.
- IndentLine()
Inserts spaces to the start of the current line. Number of spaces is calculated from indent options or
SyntaxParser
if assigned.
- IndentLine(string, bool)
Inserts white space to the start of the current line.
white space string Indicates if the change needs to be translated to the parser
- Insert(string, bool)
Inserts the given string at the specified location.
- InsertBlock(ITextStrings, bool)
Inserts the given string collection at the specified location.
- InsertBlock(string, bool)
Inserts the given string at the specified location.
- InsertBlock(string[], bool)
Inserts the given string array at the specified location.
- InsertBlock(string[], bool, bool)
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.
- IsContentDivider(int)
Gets boolean value indicating whether text content is divided at given line.
- IsHyperText(string)
Indicates whether given text represents hypertext.
- IsWordCorrect(string)
Checks whether spelling for the given word is correct.
- IsWordCorrect(string, Point)
Checks whether spelling for the given word is correct.
- LineIsHidden(int)
Determines whether the given line is readonly.
- LineIsModified(int)
Indicates whether specified line already modified.
- LineIsModified(int, out bool)
Indicates whether specified line already modified.
- LineIsReadonly(int)
Determines whether the given line is readonly.
- LinesChanged(int, int)
Specifies range of lines that was changed.
- LinesChanged(int, int, bool)
Specifies range of lines that was changed.
- 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.
- MoveTo(Point)
Moves the current position to the given position.
- MoveTo(int, int)
Moves the current position to the given position.
- MoveToChar(int)
Moves the current position to the specified character in the current line.
- MoveToLine(int)
Moves the current position to the specified line.
- MoveToLine(int, int)
Moves the current position to the specified line.
- Navigate(int, int)
Moves current position by the given offset value.
- NeedAutoComplete()
Indicates whether
ITextSource
should try to autocomplete statements.
- NeedCacheIndent()
Indicates whether
ITextSource
can reuse previous indentation.
- NeedCodeCompletion()
Indicates whether
ITextSource
can provide code completion operation for its content.
- NeedCodeCompletionTabs(CodeCompletionType)
Indicates code completion content can be filtered based on its priority.
- NeedCodeFixes()
Indicates whether
ITextSource
can provide code fixes operation for its content.
- NeedCodeRefactors()
Indicates whether
ITextSource
can provide code fixes operation for its content.
- NeedContentDividers()
Indicates whether
ITextSource
can proceed syntax errors in its content.
- NeedFormatText()
Indicates whether
ITextSource
can format its content.
- NeedFormatTextOnLineChange()
Indicates whether
ITextSource
should format spaces and case when changing the current line.
- NeedIndentText()
Indicates whether
ITextSource
can indent its content.
- NeedOutlineText()
Indicates whether
ITextSource
can outline its content.
- 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
ITextSource
can obtain short description for syntax tokens within its content.
- NeedReparseText()
Indicates whether
ITextSource
can perform syntax analysis of its content.
- NeedReparseTextOnLineChange()
Indicates whether
ITextSource
should replace text when changing the current line.
- NeedStructureGuideLines()
Indicates whether
ITextSource
can proceed syntax errors in its content.
- NeedSyntaxErrors()
Indicates whether
ITextSource
can proceed syntax errors in its content.
- NeedWorkInThread()
Indicates whether
ITextSource
can perform syntax analysis in thread.
- NewLine()
Inserts a line break at the current position.
- NewLine(ref string, bool)
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.
- ParseString(int)
Perform lexical analysis of the specified string.
- ParseStrings(int, int)
Perform lexical analysis specified strings.
- ParseToString(int)
Perform lexical analysis of specified strings.
- 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.
- RemoveNotifier(INotifier)
Exclude specified handler from notification handlers list.
- ResetBracesOptions()
Resets the
BracesOptions
to its default value.
- ResetCheckSpelling()
Resets the
CheckSpelling
to the default value.
- ResetClosingBraces()
Resets the
ClosingBraces
to its default value.
- ResetHighlightHyperText()
Resets
HighlightHyperText
to the default value.
- ResetIndentOptions()
Resets the
IndentOptions
to the default value.
- ResetMaxLength()
Resets the
MaxLength
to the default value.
- ResetModified()
Resets the
Modified
to the default value.
- ResetNavigateOptions()
Resets the
NavigateOptions
to the default value.
- ResetOpenBraces()
Resets the
OpenBraces
to its default value.
- ResetOverWrite()
Resets the
OverWrite
to the default value.
- ResetReadOnly()
Resets the
ReadOnly
to the default value.
- ResetSingleLineMode()
Resets the
SingleLineMode
to the default value.
- ResetSpellDelimiters()
Resets the
SpellDelimiters
to the default value.
- ResetUndoLimit()
Resets the
UndoLimit
to the default value.
- ResetUndoOptions()
Resets the
UndoOptions
to the default value.
- RestorePosition(int)
Restores position from stored position list by given index.
- RestorePositionWithUndo(int)
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(int)
Updates the last parsed line and resets first changed line to it's default value.
- SetLineHidden(int, bool)
Sets readonly state for the given line.
- SetLineHidden(int[], bool)
Sets readonly state for the given line.
- SetLineReadonly(int, bool)
Sets readonly state for the given line.
- SetLineReadonly(int[], bool)
Sets readonly state for the given line.
- SetLineState(int[], ItemState, bool)
Sets item state for the given line.
- SetNavigateOptions(NavigateOptions)
Sets navigating options without validating position.
- ShouldSerializeClosingBraces()
Indicates whether the
ClosingBraces
property should be persisted.
- ShouldSerializeIndentOptions()
Indicates whether the
IndentOptions
property should be persisted.
- ShouldSerializeLexer()
Indicates whether the
Lexer
property should be persisted.
- ShouldSerializeNavigateOptions()
Indicates whether the
NavigateOptions
property should be persisted.
- ShouldSerializeOpenBraces()
Indicates whether the
OpenBraces
property should be persisted.
- ShouldSerializeText()
Indicates whether the
Text
property should be persisted.
- ShouldSerializeUndoOptions()
Indicates whether the
UndoOptions
property should be persisted.
- StartThread(ThreadProc, ThreadProc, ThreadProc, ThreadProc)
Executes action in thread.
- StopThread(ThreadProc, bool)
Aborts executing action in thread.
- StorePosition(Point)
Stores given position to stored position list.
- StorePosition(Point, bool)
Stores given position to stored position list.
- StorePositionWithUndo(Point)
Stores given position to stored position list preserving it for undo.
- SupportsAsyncParsing()
Indicates whether
ITextSource
can perform syntax analysis asynchronously.
- 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.
- TempHighlightSelectedWords(IRangeList)
Highlights selected words.
- TempUnhighlightBraces()
Cancels text highlighting turned on using
TempHighlightBraces
TempHighlightBraces(Rectangle[])
- TempUnhighlightBraces(bool)
Unhighlights temporary braces areas.
- TempUnhighlightReferences()
Unhighlights references highlighted with previous call of TempHighlightReferences.
- TempUnhighlightSearchResults()
Unhighlights search results highlighted with previous call of TempHighlightSearchResults.
- TempUnhighlightSelectedWords()
Unhighlights selected words highlighted with previous call of TempHighlightSelectedWords.
- TextPointToAbsolutePosition(Point)
Converts given Point value to the absolute position.
- UnBreakLine(bool)
Concatenates lines at current position.
- Undo(IUndoData, bool)
Performs the single undo operation.
- Undo(bool)
Performs the last undo operation.
- UnhighlightBraces()
Unhighlights braces containing caret position. HighlightBraces()
- UnhighlightBraces(bool)
Unhighlights braces.
- UnhighlightCodeSnippets()
Removes highlighting from code snippets and clears snippet collection.
- UnhighlightSyntaxErrors()
Removes syntax errors highlighting.
- Update()
Updates an object state.
- ValidatePosition(ref Point)
Validates given position within control's text content.
Events
- HyperText
Occurs when a control needs checking whether some string represents hypertext.
- UndoEvent
Occurs when undo/redo operation performed.
- WordSpell
Occurs when spelling of some word within the text needs checking.