class TextEditor
package moonshine.editor.text
extends FeathersControl
implements IStageFocusDelegate, IFocusObject
extended by LspTextEditor
A multiline text editor for code.
Static variables
staticfinalread onlyCHILD_VARIANT_LIST_VIEW:String = "textEditor_listView"
The variant used to style the ListView
child component in a theme.
Constructor
Variables
allowToggleBreakpoints:Bool
Indicates if the user is allowed to toggle breakpoints by clicking inside a line's gutter.
autoClosingPairs:Array<AutoClosingPair>
Defines sets of auto-closing character pairs for the current language.
backgroundSkin:DisplayObject
The default background skin to display behind the text editor's content.
blockComment:Array<String> = null
The opening and closing strings that define a block comment. The array must contain exactly two items. The first item is the opening string of the block comment, and the second item is the closing string of the block comment.
brackets:Array<Array<String>>
Defines sets of brackets for the current language.
Each item in the Array
must be an Array<String>
containing exactly
two items. The first item is the opening bracket, and the second item
is the closing bracket.
read onlycaretCharIndex:Int
The character index of the caret.
To set caretCharIndex
, use setSelection()
with both char values equal
read onlycaretLine:TextLineModel
The data displayed for the line where the caret is currently located.
read onlycaretLineIndex:Int
The line index of the caret.
To set caretLineIndex
, use setSelection()
with both char values equal
debuggerLineIndex:Int
The line index where the debugger is currently stopped. If the debugger
is not currently stopped on a line, the value is -1
.
disabledBackgroundSkin:DisplayObject
The background skin to display behind the text editor's content when the text editor is disabled.
read onlyexpandedCaretCharIndex:Int
Used by the SelectionManager
for smarter caret placement when moving
the caret between multiple lines.
highlightAllFindResults:Bool
Indicates if a special background appears behind all results when
find()
is called.
insertSpacesForTabs:Bool = false
Determines if the tab key should insert spaces instead of the tab \t
character.
See also:
read onlylineHeight:Float
The height of each line, measured in pixels, if wordWrap
is false
.
When wordWrap
is true
, lines may have different heights.
lineNumberWidth:Null<Float>
Allows the width of line numbers to be set to an exact value, instead of being calculated dynamically.
macHomeAndEndEnabled:Bool
Determines if Keyboard.HOME
and Keyboard.END
behave like native
macOS text editors (scroll to top or bottom, without changing the cursor
position), or if they change the cursor position to the beginning or
end of the current line (like most code editors).
minLineNumberCharacters:Int
When the line number widths are calculated automatically, this is the
minimum number of characters required for the calculation. This value
is ignored if lineNumberWidth
is set.
read onlyselectedText:String
The currently selected text. If no text is selected, returns an empty string.
read onlyselectionEndCharIndex:Int
The character index of the end of the selection.
To set selectionEndCharIndex
, call setSelection()
.
read onlyselectionEndLineIndex:Int
The line index of the end of the selection.
To set selectionEndLineIndex
, call setSelection()
.
read onlyselectionStartCharIndex:Int
The character index of the start of the selection.
To set selectionStartCharIndex
, call setSelection()
.
read onlyselectionStartLineIndex:Int
The line index of the start of the selection.
To set selectionStartLineIndex
, call setSelection()
.
textStyles:Map<Int, TextFormat>
The text styles used for syntax highlighting. The key corresponds to the syntax identifiers from the parser.
wordWrap:Bool
Determines if the lines wrap or scroll horizontally.
Warning: The wordWrap
property is currently supported only when
the readOnly
property is true
.
textLineModelFactory:(String, Int) ‑> TextLineModel
Used to customize how new TextLineModel
objects are created.
Methods
find(search:Any, backwards:Bool = false, allowWrap:Bool = true):TextEditorSearchResult
Searches for the specified String
or EReg
in the editor's text.
findNext(backwards:Bool = false, allowWrap:Bool = true):TextEditorSearchResult
Makes the next find()
result into the current result.
Must be called after find()
getTextEditorPositionBoundaries(pos:TextEditorPosition):Rectangle
Returns the boundaries of the specified character index.
Similar to TextField.getCharBoundaries()
localToTextEditorPosition(localXY:Point, forSelection:Bool = false):TextEditorPosition
Converts a Point
in the local coordinate system to a
TextEditorPosition
object.
replaceAll(newText:String):TextEditorSearchResult
Replaces all find()
results with the specified text.
Must be called after find()
replaceOne(newText:String, allowWrap:Bool = true):TextEditorSearchResult
Replaces the current find()
result with the specified text.
Must be called after find()
setParserAndTextStyles(parser:ILineParser, textStyles:Map<Int, TextFormat>):Void
Updates the code parser used for syntax highlighting.
setSelection(startLine:Int, startChar:Int, endLine:Int, endChar:Int):Void
Selects the specified range. If the start and end positions are the same, nothing will be selected, but the caret will move.
setSelectionAdvanced(startLine:Int, startChar:Int, endLine:Int, endChar:Int, expandCaret:Bool):Void
Used by SelectionManager
to preserve the expanded caret char index.
textEditorPositionToLocal(pos:TextEditorPosition):Point
Converts a TextEditorPosition
object to a Point
in the local
coordinate sytem.
toggleBlockComment():Void
Toggles line comments for the currently selected lines (or the line with the caret, if no lines are selected).
toggleBreakpoint(?lineIndex:Int):Void
Toggles a breakpoint at the specified line index. If no line index is specified, toggles a breakpoint at the current caret line index.
toggleLineComment():Void
Toggles line comments for the currently selected lines (or the line with the caret, if no lines are selected).