TextEdit
A multiline text editor.
TextEdit.swift:33class TextEdit
A multiline text editor. It also has limited facilities for editing code, such as syntax highlighting support. For more advanced facilities for editing code, see CodeEdit
.
This object emits the following signals:
Superclasses
class Control
Base class for all GUI controls. Adapts its position and size based on its parent control.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
enum CaretType
enum EditAction
enum GutterType
enum LineWrappingMode
enum MenuItems
enum SearchFlags
enum SelectionMode
class Signal1
Signal support.
class Signal2
Signal support.
Type members
Instance members
var autowrapMode: TextServer.AutowrapMode
If
wrapMode
is set to .lineWrappingBoundary, sets text wrapping mode. To see how each mode behaves, seeTextServer.AutowrapMode
.var caretBlink: Bool
If
true
, makes the caret blink.var caretBlinkInterval: Double
The interval at which the caret blinks (in seconds).
var caretChanged: SimpleSignal
Emitted when any caret changes position.
var caretDrawWhenEditableDisabled: Bool
If
true
, caret will be visible wheneditable
is disabled.var caretMidGrapheme: Bool
Allow moving caret, selecting and removing the individual composite character components.
var caretMoveOnRightClick: Bool
If
true
, a right-click moves the caret at the mouse position before displaying the context menu.var caretMultiple: Bool
Sets if multiple carets are allowed.
var caretType: TextEdit.CaretType
Set the type of caret to draw.
var contextMenuEnabled: Bool
If
true
, a right-click displays the context menu.var customWordSeparators: String
The characters to consider as word delimiters if
useCustomWordSeparators
istrue
. The characters should be defined without separation, for example#_!
.var deselectOnFocusLossEnabled: Bool
If
true
, the selected text will be deselected when focus is lost.var dragAndDropSelectionEnabled: Bool
If
true
, allow drag and drop of selected text. Text can still be dropped from other sources.var drawControlChars: Bool
If
true
, control characters are displayed.var drawSpaces: Bool
If
true
, the “space” character will have a visible representation.var drawTabs: Bool
If
true
, the “tab” character will have a visible representation.var editable: Bool
If
false
, existing text cannot be modified and new text cannot be added.var gutterAdded: SimpleSignal
Emitted when a gutter is added.
var gutterClicked: Signal2
Emitted when a gutter is clicked.
var gutterRemoved: SimpleSignal
Emitted when a gutter is removed.
var highlightAllOccurrences: Bool
If
true
, all occurrences of the selected text will be highlighted.var highlightCurrentLine: Bool
If
true
, the line containing the cursor is highlighted.var indentWrappedLines: Bool
If
true
, all wrapped lines are indented to the same amount as the unwrapped line.var language: String
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
var linesEditedFrom: Signal1
Emitted immediately when the text changes.
var middleMousePasteEnabled: Bool
If
false
, using middle mouse button to paste clipboard will be disabled.var minimapDraw: Bool
If
true
, a minimap is shown, providing an outline of your source code. The minimap uses a fixed-width text size.var minimapWidth: Int32
The width, in pixels, of the minimap.
var placeholderText: String
Text shown when the
TextEdit
is empty. It is not theTextEdit
’s default value (seetext
).var scrollFitContentHeight: Bool
If
true
,TextEdit
will disable vertical scroll and fit minimum height to the number of visible lines.var scrollHorizontal: Int32
If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels.
var scrollPastEndOfFile: Bool
Allow scrolling past the last line into “virtual” space.
var scrollSmooth: Bool
Scroll smoothly over the text rather than jumping to the next location.
var scrollVScrollSpeed: Double
Sets the scroll speed with the minimap or when
scrollSmooth
is enabled.var scrollVertical: Double
If there is a vertical scrollbar, this determines the current vertical scroll value in line numbers, starting at 0 for the top line.
var selectingEnabled: Bool
If
true
, text can be selected.var shortcutKeysEnabled: Bool
If
true
, shortcut keys for context menu items are enabled, even if the context menu is disabled.var structuredTextBidiOverride: TextServer.StructuredTextParser
Set BiDi algorithm override for the structured text.
var structuredTextBidiOverrideOptions: GArray
Set additional options for BiDi override.
var syntaxHighlighter: SyntaxHighlighter?
Sets the
SyntaxHighlighter
to use.var text: String
String value of the
TextEdit
.var textChanged: SimpleSignal
Emitted when the text changes.
var textDirection: Control.TextDirection
Base text writing direction.
var textSet: SimpleSignal
var useCustomWordSeparators: Bool
If
false
, using [kbd]Ctrl + Left[/kbd] or [kbd]Ctrl + Right[/kbd] ([kbd]Cmd + Left[/kbd] or [kbd]Cmd + Right[/kbd] on macOS) bindings will use the behavior ofuseDefaultWordSeparators
. Iftrue
, it will also stop the caret if a character withincustomWordSeparators
is detected. Useful for subword moving. This behavior also will be applied to the behavior of text selection.var useDefaultWordSeparators: Bool
If
false
, using [kbd]Ctrl + Left[/kbd] or [kbd]Ctrl + Right[/kbd] ([kbd]Cmd + Left[/kbd] or [kbd]Cmd + Right[/kbd] on macOS) bindings will stop moving caret only if a space or punctuation is detected. Iftrue
, it will also stop the caret if a character is part of!"#$%&'()*+,-./:;<=>?@[\]^
{|}~`, the Unicode General Punctuation table, or the Unicode CJK Punctuation table. Useful for subword moving. This behavior also will be applied to the behavior of text selection.var virtualKeyboardEnabled: Bool
If
true
, the native virtual keyboard is shown when focused on platforms that support it.var wrapMode: TextEdit.LineWrappingMode
Sets the line wrapping mode to use.
func addCaret(line: Int32, column: Int32
) -> Int32 Adds a new caret at the given location. Returns the index of the new caret, or
-1
if the location is invalid.func addCaretAtCarets(below: Bool
) Adds an additional caret above or below every caret. If
below
istrue
the new caret will be added below and above otherwise.func addGutter(at: Int32
) Register a new gutter to this
TextEdit
. Useat
to have a specific gutter order. A value of-1
appends the gutter to the right.func addSelectionForNextOccurrence(
) Adds a selection and a caret for the next occurrence of the current selection. If there is no active selection, selects word under caret.
func adjustCaretsAfterEdit(caret: Int32, fromLine: Int32, fromCol: Int32, toLine: Int32, toCol: Int32
) This method does nothing.
func adjustViewportToCaret(caretIndex: Int32
) Adjust the viewport so the caret is visible.
func applyIme(
) Applies text from the Input Method Editor (IME) to each caret and closes the IME if it is open.
func backspace(caretIndex: Int32
) Called when the user presses the backspace key. Can be overridden with
_backspace(caretIndex:)
.func beginComplexOperation(
) Starts a multipart edit. All edits will be treated as one action until
endComplexOperation
is called.func beginMulticaretEdit(
) Starts an edit for multiple carets. The edit must be ended with
endMulticaretEdit
. Multicaret edits can be used to edit text at multiple carets and delay merging the carets until the end, so the caret indexes aren’t affected immediately.beginMulticaretEdit
andendMulticaretEdit
can be nested, and the merge will happen at the lastendMulticaretEdit
.func cancelIme(
) Closes the Input Method Editor (IME) if it is open. Any text in the IME will be lost.
func centerViewportToCaret(caretIndex: Int32
) Centers the viewport on the line the editing caret is at. This also resets the
scrollHorizontal
value to0
.func clear(
) Performs a full reset of
TextEdit
, including undo history.func clearUndoHistory(
) Clears the undo history.
func collapseCarets(fromLine: Int32, fromColumn: Int32, toLine: Int32, toColumn: Int32, inclusive: Bool
) Collapse all carets in the given range to the
fromLine
andfromColumn
position.func copy(caretIndex: Int32
) Copies the current text selection. Can be overridden with
_copy(caretIndex:)
.func cut(caretIndex: Int32
) Cut’s the current selection. Can be overridden with
_cut(caretIndex:)
.func deleteSelection(caretIndex: Int32
) Deletes the selected text.
func deselect(caretIndex: Int32
) Deselects the current selection.
func endAction(
) Marks the end of steps in the current action started with
startAction(_:)
.func endComplexOperation(
) Ends a multipart edit, started with
beginComplexOperation
. If called outside a complex operation, the current operation is pushed onto the undo/redo stack.func endMulticaretEdit(
) Ends an edit for multiple carets, that was started with
beginMulticaretEdit
. If this was the lastendMulticaretEdit
andmergeOverlappingCarets
was called, carets will be merged.func getCaretColumn(caretIndex: Int32
) -> Int32 Returns the column the editing caret is at.
func getCaretCount(
) -> Int32 Returns the number of carets in this
TextEdit
.func getCaretDrawPos(caretIndex: Int32
) -> Vector2 Returns the caret pixel draw position.
func getCaretIndexEditOrder(
) -> PackedInt32Array Returns a list of caret indexes in their edit order, this done from bottom to top. Edit order refers to the way actions such as
insertTextAtCaret(text:caretIndex:)
are applied.func getCaretLine(caretIndex: Int32
) -> Int32 Returns the line the editing caret is on.
func getCaretWrapIndex(caretIndex: Int32
) -> Int32 Returns the wrap index the editing caret is on.
func getFirstNonWhitespaceColumn(line: Int32
) -> Int32 Returns the first column containing a non-whitespace character.
func getFirstVisibleLine(
) -> Int32 Returns the first visible line.
func getGutterCount(
) -> Int32 Returns the number of gutters registered.
func getGutterName(gutter: Int32
) -> String Returns the name of the gutter at the given index.
func getGutterType(gutter: Int32
) -> TextEdit.GutterType Returns the type of the gutter at the given index. Gutters can contain icons, text, or custom visuals. See
TextEdit.GutterType
for options.func getGutterWidth(gutter: Int32
) -> Int32 Returns the width of the gutter at the given index.
func getHScrollBar(
) -> HScrollBar? Returns the
HScrollBar
used byTextEdit
.func getIndentLevel(line: Int32
) -> Int32 Returns the number of spaces and
tab * tab_size
before the first char.func getLastFullVisibleLine(
) -> Int32 Returns the last visible line. Use
getLastFullVisibleLineWrapIndex
for the wrap index.func getLastFullVisibleLineWrapIndex(
) -> Int32 Returns the last visible wrap index of the last visible line.
func getLine(Int32
) -> String Returns the text of a specific line.
func getLineBackgroundColor(line: Int32
) -> Color Returns the current background color of the line.
Color(0, 0, 0, 0)
is returned if no color is set.func getLineColumnAtPos(position: Vector2i, allowOutOfBounds: Bool
) -> Vector2i Returns the line and column at the given position. In the returned vector,
x
is the column,y
is the line. IfallowOutOfBounds
isfalse
and the position is not over the text, both vector values will be set to-1
.func getLineCount(
) -> Int32 Returns the number of lines in the text.
func getLineGutterIcon(line: Int32, gutter: Int32
) -> Texture2D? Returns the icon currently in
gutter
atline
. This only works when the gutter type is .icon (seesetGutterType(gutter:type:)
).func getLineGutterItemColor(line: Int32, gutter: Int32
) -> Color Returns the color currently in
gutter
atline
.func getLineGutterMetadata(line: Int32, gutter: Int32
) -> Variant Returns the metadata currently in
gutter
atline
.func getLineGutterText(line: Int32, gutter: Int32
) -> String Returns the text currently in
gutter
atline
. This only works when the gutter type is .string (seesetGutterType(gutter:type:)
).func getLineHeight(
) -> Int32 Returns the maximum value of the line height among all lines.
func getLineRangesFromCarets(onlySelections: Bool, mergeAdjacent: Bool
) -> VariantCollection<Vector2i> Returns an
GArray
of line ranges wherex
is the first line andy
is the last line. All lines within these ranges will have a caret on them or be part of a selection. Each line will only be part of one line range, even if it has multiple carets on it.func getLineWidth(line: Int32, wrapIndex: Int32
) -> Int32 Returns the width in pixels of the
wrapIndex
online
.func getLineWrapCount(line: Int32
) -> Int32 Returns the number of times the given line is wrapped.
func getLineWrapIndexAtColumn(line: Int32, column: Int32
) -> Int32 Returns the wrap index of the given line column.
func getLineWrappedText(line: Int32
) -> PackedStringArray Returns an array of
String
s representing each wrapped index.func getLocalMousePos(
) -> Vector2 Returns the local mouse position adjusted for the text direction.
func getMenu(
) -> PopupMenu? Returns the
PopupMenu
of thisTextEdit
. By default, this menu is displayed when right-clicking on theTextEdit
.func getMinimapLineAtPos(position: Vector2i
) -> Int32 Returns the equivalent minimap line at
position
.func getMinimapVisibleLines(
) -> Int32 Returns the number of lines that may be drawn on the minimap.
func getNextVisibleLineIndexOffsetFrom(line: Int32, wrapIndex: Int32, visibleAmount: Int32
) -> Vector2i Similar to
getNextVisibleLineOffsetFrom(line:visibleAmount:)
, but takes into account the line wrap indexes. In the returned vector,x
is the line,y
is the wrap index.func getNextVisibleLineOffsetFrom(line: Int32, visibleAmount: Int32
) -> Int32 Returns the count to the next visible line from
line
toline + visible_amount
. Can also count backwards. For example if aTextEdit
has 5 lines with lines 2 and 3 hidden, calling this withline = 1, visible_amount = 1
would return 3.func getPosAtLineColumn(line: Int32, column: Int32
) -> Vector2i Returns the local position for the given
line
andcolumn
. Ifx
ory
of the returned vector equal-1
, the position is outside of the viewable area of the control.func getRectAtLineColumn(line: Int32, column: Int32
) -> Rect2i Returns the local position and size for the grapheme at the given
line
andcolumn
. Ifx
ory
position of the returned rect equal-1
, the position is outside of the viewable area of the control.func getSavedVersion(
) -> UInt32 Returns the last tagged saved version from
tagSavedVersion
.func getScrollPosForLine(Int32, wrapIndex: Int32
) -> Double Returns the scroll position for
wrapIndex
ofline
.func getSelectedText(caretIndex: Int32
) -> String Returns the text inside the selection of a caret, or all the carets if
caretIndex
is its default value-1
.func getSelectionAtLineColumn(line: Int32, column: Int32, includeEdges: Bool, onlySelections: Bool
) -> Int32 Returns the caret index of the selection at the given
line
andcolumn
, or-1
if there is none.func getSelectionColumn(caretIndex: Int32
) -> Int32 Returns the original start column of the selection.
func getSelectionFromColumn(caretIndex: Int32
) -> Int32 Returns the selection begin column. Returns the caret column if there is no selection.
func getSelectionFromLine(caretIndex: Int32
) -> Int32 Returns the selection begin line. Returns the caret line if there is no selection.
func getSelectionLine(caretIndex: Int32
) -> Int32 Returns the original start line of the selection.
func getSelectionMode(
) -> TextEdit.SelectionMode Returns the current selection mode.
func getSelectionOriginColumn(caretIndex: Int32
) -> Int32 Returns the origin column of the selection. This is the opposite end from the caret.
func getSelectionOriginLine(caretIndex: Int32
) -> Int32 Returns the origin line of the selection. This is the opposite end from the caret.
func getSelectionToColumn(caretIndex: Int32
) -> Int32 Returns the selection end column. Returns the caret column if there is no selection.
func getSelectionToLine(caretIndex: Int32
) -> Int32 Returns the selection end line. Returns the caret line if there is no selection.
func getSortedCarets(includeIgnoredCarets: Bool
) -> PackedInt32Array Returns the carets sorted by selection beginning from lowest line and column to highest (from top to bottom of text).
func getTabSize(
) -> Int32 Returns the
TextEdit
‘s’ tab size.func getTotalGutterWidth(
) -> Int32 Returns the total width of all gutters and internal padding.
func getTotalVisibleLineCount(
) -> Int32 Returns the number of lines that may be drawn.
func getVScrollBar(
) -> VScrollBar? Returns the
VScrollBar
of theTextEdit
.func getVersion(
) -> UInt32 Returns the current version of the
TextEdit
. The version is a count of recorded operations by the undo/redo history.func getVisibleLineCount(
) -> Int32 Returns the number of visible lines, including wrapped text.
func getVisibleLineCountInRange(fromLine: Int32, toLine: Int32
) -> Int32 Returns the total number of visible + wrapped lines between the two lines.
func getWordAtPos(position: Vector2
) -> String Returns the word at
position
.func getWordUnderCaret(caretIndex: Int32
) -> String Returns a
String
text with the word under the caret’s location.func hasImeText(
) -> Bool Returns
true
if the user has text in the Input Method Editor (IME).func hasRedo(
) -> Bool Returns
true
if a “redo” action is available.func hasSelection(caretIndex: Int32
) -> Bool Returns
true
if the user has selected text.func hasUndo(
) -> Bool Returns
true
if an “undo” action is available.func insertLineAt(line: Int32, text: String
) Inserts a new line with
text
atline
.func insertText(String, line: Int32, column: Int32, beforeSelectionBegin: Bool, beforeSelectionEnd: Bool
) Inserts the
text
atline
andcolumn
.func insertTextAtCaret(text: String, caretIndex: Int32
) Insert the specified text at the caret position.
func isCaretAfterSelectionOrigin(caretIndex: Int32
) -> Bool Returns
true
if the caret of the selection is after the selection origin. This can be used to determine the direction of the selection.func isCaretVisible(caretIndex: Int32
) -> Bool Returns
true
if the caret is visible on the screen.func isDraggingCursor(
) -> Bool Returns
true
if the user is dragging their mouse for scrolling, selecting, or text dragging.func isGutterClickable(gutter: Int32
) -> Bool Returns whether the gutter is clickable.
func isGutterDrawn(gutter: Int32
) -> Bool Returns whether the gutter is currently drawn.
func isGutterOverwritable(gutter: Int32
) -> Bool Returns whether the gutter is overwritable.
func isInMulitcaretEdit(
) -> Bool Returns
true
if abeginMulticaretEdit
has been called andendMulticaretEdit
has not yet been called.func isLineGutterClickable(line: Int32, gutter: Int32
) -> Bool Returns whether the gutter on the given line is clickable.
func isLineWrapped(line: Int32
) -> Bool Returns if the given line is wrapped.
func isMenuVisible(
) -> Bool Returns whether the menu is visible. Use this instead of
get_menu().visible
to improve performance (so the creation of the menu is avoided).func isMouseOverSelection(edges: Bool, caretIndex: Int32
) -> Bool Returns whether the mouse is over selection. If
edges
istrue
, the edges are considered part of the selection.func isOvertypeModeEnabled(
) -> Bool Returns whether the user is in overtype mode.
func mergeGutters(fromLine: Int32, toLine: Int32
) Merge the gutters from
fromLine
intotoLine
. Only overwritable gutters will be copied.func mergeOverlappingCarets(
) Merges any overlapping carets. Will favor the newest caret, or the caret with a selection.
func multicaretEditIgnoreCaret(caretIndex: Int32
) -> Bool Returns
true
if the givencaretIndex
should be ignored as part of a multicaret edit. SeebeginMulticaretEdit
andendMulticaretEdit
. Carets that should be ignored are ones that were part of removed text and will likely be merged at the end of the edit, or carets that were added during the edit.func paste(caretIndex: Int32
) Paste at the current location. Can be overridden with
_paste(caretIndex:)
.func pastePrimaryClipboard(caretIndex: Int32
) Pastes the primary clipboard.
func redo(
) Perform redo operation.
func removeCaret(Int32
) Removes the given caret index.
func removeGutter(Int32
) Removes the gutter from this
TextEdit
.func removeLineAt(line: Int32, moveCaretsDown: Bool
) Removes the line of text at
line
. Carets on this line will attempt to match their previous visual x position.func removeSecondaryCarets(
) Removes all additional carets.
func removeText(fromLine: Int32, fromColumn: Int32, toLine: Int32, toColumn: Int32
) Removes text between the given positions.
func search(text: String, flags: UInt32, fromLine: Int32, fromColumn: Int32
) -> Vector2i Perform a search inside the text. Search flags can be specified in the
SearchFlags
enum.func select(originLine: Int32, originColumn: Int32, caretLine: Int32, caretColumn: Int32, caretIndex: Int32
) Selects text from
originLine
andoriginColumn
tocaretLine
andcaretColumn
for the givencaretIndex
. This moves the selection origin and the caret. If the positions are the same, the selection will be deselected.func selectAll(
) Select all the text.
func selectWordUnderCaret(caretIndex: Int32
) Selects the word under the caret.
func setCaretColumn(Int32, adjustViewport: Bool, caretIndex: Int32
) Moves the caret to the specified
column
index.func setCaretLine(Int32, adjustViewport: Bool, canBeHidden: Bool, wrapIndex: Int32, caretIndex: Int32
) Moves the caret to the specified
line
index. The caret column will be moved to the same visual position it was at the last timesetCaretColumn(_:adjustViewport:caretIndex:)
was called, or clamped to the end of the line.func setGutterClickable(gutter: Int32, clickable: Bool
) Sets the gutter as clickable. This will change the mouse cursor to a pointing hand when hovering over the gutter.
func setGutterCustomDraw(column: Int32, drawCallback: Callable
) Set a custom draw method for the gutter. The callback method must take the following args:
line: int, gutter: int, Area: Rect2
. This only works when the gutter type is .custom (seesetGutterType(gutter:type:)
).func setGutterDraw(gutter: Int32, draw: Bool
) Sets whether the gutter should be drawn.
func setGutterName(gutter: Int32, name: String
) Sets the name of the gutter.
func setGutterOverwritable(gutter: Int32, overwritable: Bool
) Sets the gutter to overwritable. See
mergeGutters(fromLine:toLine:)
.func setGutterType(gutter: Int32, type: TextEdit.GutterType
) Sets the type of gutter. Gutters can contain icons, text, or custom visuals. See
TextEdit.GutterType
for options.func setGutterWidth(gutter: Int32, width: Int32
) Set the width of the gutter.
func setLine(Int32, newText: String
) Sets the text for a specific
line
.func setLineAsCenterVisible(line: Int32, wrapIndex: Int32
) Positions the
wrapIndex
ofline
at the center of the viewport.func setLineAsFirstVisible(line: Int32, wrapIndex: Int32
) Positions the
wrapIndex
ofline
at the top of the viewport.func setLineAsLastVisible(line: Int32, wrapIndex: Int32
) Positions the
wrapIndex
ofline
at the bottom of the viewport.func setLineBackgroundColor(line: Int32, color: Color
) Sets the current background color of the line. Set to
Color(0, 0, 0, 0)
for no color.func setLineGutterClickable(line: Int32, gutter: Int32, clickable: Bool
) If
clickable
istrue
, makes thegutter
online
clickable. See [signal gutter_clicked].func setLineGutterIcon(line: Int32, gutter: Int32, icon: Texture2D?
) Sets the icon for
gutter
online
toicon
. This only works when the gutter type is .icon (seesetGutterType(gutter:type:)
).func setLineGutterItemColor(line: Int32, gutter: Int32, color: Color
) Sets the color for
gutter
online
tocolor
.func setLineGutterMetadata(line: Int32, gutter: Int32, metadata: Variant
) Sets the metadata for
gutter
online
tometadata
.func setLineGutterText(line: Int32, gutter: Int32, text: String
) Sets the text for
gutter
online
totext
. This only works when the gutter type is .string (seesetGutterType(gutter:type:)
).func setOvertypeModeEnabled(Bool
) If
true
, sets the user into overtype mode. When the user types in this mode, it will override existing text.func setSearchFlags(UInt32
) Sets the search
flags
. This is used withsetSearchText(_:)
to highlight occurrences of the searched text. Search flags can be specified from theSearchFlags
enum.func setSearchText(String
) Sets the search text. See
setSearchFlags(_:)
.func setSelectionMode(TextEdit.SelectionMode
) Sets the current selection mode.
func setSelectionOriginColumn(Int32, caretIndex: Int32
) Sets the selection origin column to the
column
for the givencaretIndex
. If the selection origin is moved to the caret position, the selection will deselect.func setSelectionOriginLine(Int32, canBeHidden: Bool, wrapIndex: Int32, caretIndex: Int32
) Sets the selection origin line to the
line
for the givencaretIndex
. If the selection origin is moved to the caret position, the selection will deselect.func setTabSize(Int32
) Sets the tab size for the
TextEdit
to use.func setTooltipRequestFunc(callback: Callable
) Provide custom tooltip text. The callback method must take the following args:
hovered_word: String
.func skipSelectionForNextOccurrence(
) Moves a selection and a caret for the next occurrence of the current selection. If there is no active selection, moves to the next occurrence of the word under caret.
func startAction(TextEdit.EditAction
) Starts an action, will end the current action if
action
is different.func swapLines(fromLine: Int32, toLine: Int32
) Swaps the two lines. Carets will be swapped with the lines.
func tagSavedVersion(
) Tag the current version as saved.
func undo(
) Perform undo operation.
Show implementation details (6)
Hide implementation details
func _backspace(caretIndex: Int32
) Override this method to define what happens when the user presses the backspace key.
func _copy(caretIndex: Int32
) Override this method to define what happens when the user performs a copy operation.
func _cut(caretIndex: Int32
) Override this method to define what happens when the user performs a cut operation.
func _handleUnicodeInput(unicodeChar: Int32, caretIndex: Int32
) Override this method to define what happens when the user types in the provided key
unicodeChar
.func _paste(caretIndex: Int32
) Override this method to define what happens when the user performs a paste operation.
func _pastePrimaryClipboard(caretIndex: Int32
) Override this method to define what happens when the user performs a paste operation with middle mouse button.
Subclasses
class CodeEdit
A multiline text editor designed for editing code.