Enumerationmigueldeicaza.swiftgodot 0.45.0SwiftGodot
SelectionMode
TextEdit.swift:189enum SelectionMode
Cases
case none
Not selecting.
case shift
Select as if
shift
is pressed.case pointer
Select single characters as if the user single clicked.
case word
Select whole words as if the user double clicked.
case line
Select whole lines as if the user triple clicked.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (192) members.
Types
enum CaretType
enum EditAction
enum GutterType
enum LineWrappingMode
enum MenuItems
enum SearchFlags
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 the 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 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.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 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.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 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, col: 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
is true 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
) Reposition the carets affected by the edit. This assumes edits are applied in edit order, see
getCaretIndexEditOrder
.func adjustViewportToCaret(caretIndex: Int32
) Adjust the viewport so the caret is visible.
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 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 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 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.
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
.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
.func getLineHeight(
) -> Int32 Returns the maximum value of the line height among all lines.
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 getSelectionColumn(caretIndex: Int32
) -> Int32 Returns the original start column of the selection.
func getSelectionFromColumn(caretIndex: Int32
) -> Int32 Returns the selection begin column.
func getSelectionFromLine(caretIndex: Int32
) -> Int32 Returns the selection begin line.
func getSelectionLine(caretIndex: Int32
) -> Int32 Returns the original start line of the selection.
func getSelectionMode(
) -> TextEdit.SelectionMode Returns the current selection mode.
func getSelectionToColumn(caretIndex: Int32
) -> Int32 Returns the selection end column.
func getSelectionToLine(caretIndex: Int32
) -> Int32 Returns the selection end line.
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 if the user has IME text.
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 insertTextAtCaret(text: String, caretIndex: Int32
) Insert the specified text at the caret position.
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 or selecting.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 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 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 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, fromColum: Int32
) -> Vector2i Perform a search inside the text. Search flags can be specified in the
SearchFlags
enum.func select(fromLine: Int32, fromColumn: Int32, toLine: Int32, toColumn: Int32, caretIndex: Int32
) Perform selection, from line/column to line/column.
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.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
.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.
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
.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
.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, line: Int32, column: Int32, caretIndex: Int32
) Sets the current selection mode.
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 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.
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.
Citizens in SwiftGodot
Conformances
protocol CaseIterable
A type that provides a collection of all of its values.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
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 RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
Type members
Instance members
var debugDescription: String
A textual representation of this instance, suitable for debugging
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.