TextEdit

package
v0.0.0-...-80877a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package TextEdit provides methods for working with TextEdit object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsTextEdit() Instance
}

type CaretType

type CaretType = gdclass.TextEditCaretType //gd:TextEdit.CaretType
const (
	/*Vertical line caret.*/
	CaretTypeLine CaretType = 0
	/*Block caret.*/
	CaretTypeBlock CaretType = 1
)

type EditAction

type EditAction = gdclass.TextEditEditAction //gd:TextEdit.EditAction
const (
	/*No current action.*/
	ActionNone EditAction = 0
	/*A typing action.*/
	ActionTyping EditAction = 1
	/*A backwards delete action.*/
	ActionBackspace EditAction = 2
	/*A forward delete action.*/
	ActionDelete EditAction = 3
)

type GutterType

type GutterType = gdclass.TextEditGutterType //gd:TextEdit.GutterType
const (
	/*When a gutter is set to string using [method set_gutter_type], it is used to contain text set via the [method set_line_gutter_text] method.*/
	GutterTypeString GutterType = 0
	/*When a gutter is set to icon using [method set_gutter_type], it is used to contain an icon set via the [method set_line_gutter_icon] method.*/
	GutterTypeIcon GutterType = 1
	/*When a gutter is set to custom using [method set_gutter_type], it is used to contain custom visuals controlled by a callback method set via the [method set_gutter_custom_draw] method.*/
	GutterTypeCustom GutterType = 2
)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.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]. [b]Note:[/b] Most viewport, caret, and edit methods contain a [code]caret_index[/code] argument for [member caret_multiple] support. The argument should be one of the following: [code]-1[/code] for all carets, [code]0[/code] for the main caret, or greater than [code]0[/code] for secondary carets in the order they were created. [b]Note:[/b] When holding down [kbd]Alt[/kbd], the vertical scroll wheel will scroll 5 times as fast as it would normally do. This also works in the Godot script editor.

See [Interface] for methods that can be overridden by a [Class] that extends it.

%!(EXTRA string=TextEdit)

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddCaret

func (self Instance) AddCaret(line int, column int) int

Adds a new caret at the given location. Returns the index of the new caret, or [code]-1[/code] if the location is invalid.

func (Instance) AddCaretAtCarets

func (self Instance) AddCaretAtCarets(below bool)

Adds an additional caret above or below every caret. If [param below] is [code]true[/code] the new caret will be added below and above otherwise.

func (Instance) AddGutter

func (self Instance) AddGutter()

Register a new gutter to this [TextEdit]. Use [param at] to have a specific gutter order. A value of [code]-1[/code] appends the gutter to the right.

func (Instance) AddSelectionForNextOccurrence

func (self Instance) 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 (Instance) AdjustCaretsAfterEdit

func (self Instance) AdjustCaretsAfterEdit(caret int, from_line int, from_col int, to_line int, to_col int)

This method does nothing.

func (Instance) AdjustViewportToCaret

func (self Instance) AdjustViewportToCaret()

Adjust the viewport so the caret is visible.

func (Instance) ApplyIme

func (self Instance) ApplyIme()

Applies text from the [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url] (IME) to each caret and closes the IME if it is open.

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsControl

func (self Instance) AsControl() Control.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsTextEdit

func (self Instance) AsTextEdit() Instance

func (Instance) AutowrapMode

func (self Instance) AutowrapMode() gdclass.TextServerAutowrapMode

func (Instance) Backspace

func (self Instance) Backspace()

Called when the user presses the backspace key. Can be overridden with [method _backspace].

func (Instance) BeginComplexOperation

func (self Instance) BeginComplexOperation()

Starts a multipart edit. All edits will be treated as one action until [method end_complex_operation] is called.

func (Instance) BeginMulticaretEdit

func (self Instance) BeginMulticaretEdit()

Starts an edit for multiple carets. The edit must be ended with [method end_multicaret_edit]. 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. [method begin_multicaret_edit] and [method end_multicaret_edit] can be nested, and the merge will happen at the last [method end_multicaret_edit]. Example usage: [codeblock] begin_complex_operation() begin_multicaret_edit() for i in range(get_caret_count()):

if multicaret_edit_ignore_caret(i):
    continue
# Logic here.

end_multicaret_edit() end_complex_operation() [/codeblock]

func (Instance) CancelIme

func (self Instance) CancelIme()

Closes the [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url] (IME) if it is open. Any text in the IME will be lost.

func (self Instance) CaretBlink() bool

func (Instance) CaretBlinkInterval

func (self Instance) CaretBlinkInterval() Float.X

func (Instance) CaretDrawWhenEditableDisabled

func (self Instance) CaretDrawWhenEditableDisabled() bool

func (Instance) CaretMidGrapheme

func (self Instance) CaretMidGrapheme() bool

func (Instance) CaretMoveOnRightClick

func (self Instance) CaretMoveOnRightClick() bool

func (Instance) CaretMultiple

func (self Instance) CaretMultiple() bool

func (Instance) CaretType

func (self Instance) CaretType() gdclass.TextEditCaretType

func (Instance) CenterViewportToCaret

func (self Instance) CenterViewportToCaret()

Centers the viewport on the line the editing caret is at. This also resets the [member scroll_horizontal] value to [code]0[/code].

func (Instance) Clear

func (self Instance) Clear()

Performs a full reset of [TextEdit], including undo history.

func (Instance) ClearUndoHistory

func (self Instance) ClearUndoHistory()

Clears the undo history.

func (Instance) CollapseCarets

func (self Instance) CollapseCarets(from_line int, from_column int, to_line int, to_column int)

Collapse all carets in the given range to the [param from_line] and [param from_column] position. [param inclusive] applies to both ends. If [method is_in_mulitcaret_edit] is [code]true[/code], carets that are collapsed will be [code]true[/code] for [method multicaret_edit_ignore_caret]. [method merge_overlapping_carets] will be called if any carets were collapsed.

func (Instance) ContextMenuEnabled

func (self Instance) ContextMenuEnabled() bool

func (Instance) Copy

func (self Instance) Copy()

Copies the current text selection. Can be overridden with [method _copy].

func (Instance) CustomWordSeparators

func (self Instance) CustomWordSeparators() string

func (Instance) Cut

func (self Instance) Cut()

Cut's the current selection. Can be overridden with [method _cut].

func (Instance) DeleteSelection

func (self Instance) DeleteSelection()

Deletes the selected text.

func (Instance) Deselect

func (self Instance) Deselect()

Deselects the current selection.

func (Instance) DeselectOnFocusLossEnabled

func (self Instance) DeselectOnFocusLossEnabled() bool

func (Instance) DragAndDropSelectionEnabled

func (self Instance) DragAndDropSelectionEnabled() bool

func (Instance) DrawControlChars

func (self Instance) DrawControlChars() bool

func (Instance) DrawSpaces

func (self Instance) DrawSpaces() bool

func (Instance) DrawTabs

func (self Instance) DrawTabs() bool

func (Instance) Editable

func (self Instance) Editable() bool

func (Instance) EndAction

func (self Instance) EndAction()

Marks the end of steps in the current action started with [method start_action].

func (Instance) EndComplexOperation

func (self Instance) EndComplexOperation()

Ends a multipart edit, started with [method begin_complex_operation]. If called outside a complex operation, the current operation is pushed onto the undo/redo stack.

func (Instance) EndMulticaretEdit

func (self Instance) EndMulticaretEdit()

Ends an edit for multiple carets, that was started with [method begin_multicaret_edit]. If this was the last [method end_multicaret_edit] and [method merge_overlapping_carets] was called, carets will be merged.

func (Instance) GetCaretColumn

func (self Instance) GetCaretColumn() int

Returns the column the editing caret is at.

func (Instance) GetCaretCount

func (self Instance) GetCaretCount() int

Returns the number of carets in this [TextEdit].

func (Instance) GetCaretDrawPos

func (self Instance) GetCaretDrawPos() Vector2.XY

Returns the caret pixel draw position.

func (Instance) GetCaretIndexEditOrder

func (self Instance) GetCaretIndexEditOrder() []int32

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 [method insert_text_at_caret] are applied.

func (Instance) GetCaretLine

func (self Instance) GetCaretLine() int

Returns the line the editing caret is on.

func (Instance) GetCaretWrapIndex

func (self Instance) GetCaretWrapIndex() int

Returns the wrap index the editing caret is on.

func (Instance) GetFirstNonWhitespaceColumn

func (self Instance) GetFirstNonWhitespaceColumn(line int) int

Returns the first column containing a non-whitespace character.

func (Instance) GetFirstVisibleLine

func (self Instance) GetFirstVisibleLine() int

Returns the first visible line.

func (Instance) GetGutterCount

func (self Instance) GetGutterCount() int

Returns the number of gutters registered.

func (Instance) GetGutterName

func (self Instance) GetGutterName(gutter int) string

Returns the name of the gutter at the given index.

func (Instance) GetGutterType

func (self Instance) GetGutterType(gutter int) gdclass.TextEditGutterType

Returns the type of the gutter at the given index. Gutters can contain icons, text, or custom visuals. See [enum TextEdit.GutterType] for options.

func (Instance) GetGutterWidth

func (self Instance) GetGutterWidth(gutter int) int

Returns the width of the gutter at the given index.

func (Instance) GetHScrollBar

func (self Instance) GetHScrollBar() [1]gdclass.HScrollBar

Returns the [HScrollBar] used by [TextEdit].

func (Instance) GetIndentLevel

func (self Instance) GetIndentLevel(line int) int

Returns the number of spaces and [code]tab * tab_size[/code] before the first char.

func (Instance) GetLastFullVisibleLine

func (self Instance) GetLastFullVisibleLine() int

Returns the last visible line. Use [method get_last_full_visible_line_wrap_index] for the wrap index.

func (Instance) GetLastFullVisibleLineWrapIndex

func (self Instance) GetLastFullVisibleLineWrapIndex() int

Returns the last visible wrap index of the last visible line.

func (Instance) GetLastUnhiddenLine

func (self Instance) GetLastUnhiddenLine() int

Returns the last unhidden line in the entire [TextEdit].

func (Instance) GetLine

func (self Instance) GetLine(line int) string

Returns the text of a specific line.

func (Instance) GetLineBackgroundColor

func (self Instance) GetLineBackgroundColor(line int) Color.RGBA

Returns the current background color of the line. [code]Color(0, 0, 0, 0)[/code] is returned if no color is set.

func (Instance) GetLineColumnAtPos

func (self Instance) GetLineColumnAtPos(position Vector2i.XY) Vector2i.XY

Returns the line and column at the given position. In the returned vector, [code]x[/code] is the column, [code]y[/code] is the line. If [param allow_out_of_bounds] is [code]false[/code] and the position is not over the text, both vector values will be set to [code]-1[/code].

func (Instance) GetLineCount

func (self Instance) GetLineCount() int

Returns the number of lines in the text.

func (Instance) GetLineGutterIcon

func (self Instance) GetLineGutterIcon(line int, gutter int) [1]gdclass.Texture2D

Returns the icon currently in [param gutter] at [param line]. This only works when the gutter type is [constant GUTTER_TYPE_ICON] (see [method set_gutter_type]).

func (Instance) GetLineGutterItemColor

func (self Instance) GetLineGutterItemColor(line int, gutter int) Color.RGBA

Returns the color currently in [param gutter] at [param line].

func (Instance) GetLineGutterMetadata

func (self Instance) GetLineGutterMetadata(line int, gutter int) any

Returns the metadata currently in [param gutter] at [param line].

func (Instance) GetLineGutterText

func (self Instance) GetLineGutterText(line int, gutter int) string

Returns the text currently in [param gutter] at [param line]. This only works when the gutter type is [constant GUTTER_TYPE_STRING] (see [method set_gutter_type]).

func (Instance) GetLineHeight

func (self Instance) GetLineHeight() int

Returns the maximum value of the line height among all lines. [b]Note:[/b] The return value is influenced by [theme_item line_spacing] and [theme_item font_size]. And it will not be less than [code]1[/code].

func (Instance) GetLineRangesFromCarets

func (self Instance) GetLineRangesFromCarets() []Vector2i.XY

Returns an [Array] of line ranges where [code]x[/code] is the first line and [code]y[/code] 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. If a selection's end column ([method get_selection_to_column]) is at column [code]0[/code], that line will not be included. If a selection begins on the line after another selection ends and [param merge_adjacent] is [code]true[/code], or they begin and end on the same line, one line range will include both selections.

func (Instance) GetLineWidth

func (self Instance) GetLineWidth(line int) int

Returns the width in pixels of the [param wrap_index] on [param line].

func (Instance) GetLineWrapCount

func (self Instance) GetLineWrapCount(line int) int

Returns the number of times the given line is wrapped.

func (Instance) GetLineWrapIndexAtColumn

func (self Instance) GetLineWrapIndexAtColumn(line int, column int) int

Returns the wrap index of the given line column.

func (Instance) GetLineWrappedText

func (self Instance) GetLineWrappedText(line int) []string

Returns an array of [String]s representing each wrapped index.

func (Instance) GetLocalMousePos

func (self Instance) GetLocalMousePos() Vector2.XY

Returns the local mouse position adjusted for the text direction.

func (Instance) GetMenu

func (self Instance) GetMenu() [1]gdclass.PopupMenu

Returns the [PopupMenu] of this [TextEdit]. By default, this menu is displayed when right-clicking on the [TextEdit]. You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see [enum MenuItems]). For example: [codeblocks] [gdscript] func _ready():

var menu = get_menu()
# Remove all items after "Redo".
menu.item_count = menu.get_item_index(MENU_REDO) + 1
# Add custom items.
menu.add_separator()
menu.add_item("Insert Date", MENU_MAX + 1)
# Connect callback.
menu.id_pressed.connect(_on_item_pressed)

func _on_item_pressed(id):

if id == MENU_MAX + 1:
    insert_text_at_caret(Time.get_date_string_from_system())

[/gdscript] [csharp] public override void _Ready()

{
    var menu = GetMenu();
    // Remove all items after "Redo".
    menu.ItemCount = menu.GetItemIndex(TextEdit.MenuItems.Redo) + 1;
    // Add custom items.
    menu.AddSeparator();
    menu.AddItem("Insert Date", TextEdit.MenuItems.Max + 1);
    // Add event handler.
    menu.IdPressed += OnItemPressed;
}

public void OnItemPressed(int id)

{
    if (id == TextEdit.MenuItems.Max + 1)
    {
        InsertTextAtCaret(Time.GetDateStringFromSystem());
    }
}

[/csharp] [/codeblocks] [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member Window.visible] property.

func (Instance) GetMinimapLineAtPos

func (self Instance) GetMinimapLineAtPos(position Vector2i.XY) int

Returns the equivalent minimap line at [param position].

func (Instance) GetMinimapVisibleLines

func (self Instance) GetMinimapVisibleLines() int

Returns the number of lines that may be drawn on the minimap.

func (Instance) GetNextVisibleLineIndexOffsetFrom

func (self Instance) GetNextVisibleLineIndexOffsetFrom(line int, wrap_index int, visible_amount int) Vector2i.XY

Similar to [method get_next_visible_line_offset_from], but takes into account the line wrap indexes. In the returned vector, [code]x[/code] is the line, [code]y[/code] is the wrap index.

func (Instance) GetNextVisibleLineOffsetFrom

func (self Instance) GetNextVisibleLineOffsetFrom(line int, visible_amount int) int

Returns the count to the next visible line from [param line] to [code]line + visible_amount[/code]. Can also count backwards. For example if a [TextEdit] has 5 lines with lines 2 and 3 hidden, calling this with [code]line = 1, visible_amount = 1[/code] would return 3.

func (Instance) GetPosAtLineColumn

func (self Instance) GetPosAtLineColumn(line int, column int) Vector2i.XY

Returns the local position for the given [param line] and [param column]. If [code]x[/code] or [code]y[/code] of the returned vector equal [code]-1[/code], the position is outside of the viewable area of the control. [b]Note:[/b] The Y position corresponds to the bottom side of the line. Use [method get_rect_at_line_column] to get the top side position.

func (Instance) GetRectAtLineColumn

func (self Instance) GetRectAtLineColumn(line int, column int) Rect2i.PositionSize

Returns the local position and size for the grapheme at the given [param line] and [param column]. If [code]x[/code] or [code]y[/code] position of the returned rect equal [code]-1[/code], the position is outside of the viewable area of the control. [b]Note:[/b] The Y position of the returned rect corresponds to the top side of the line, unlike [method get_pos_at_line_column] which returns the bottom side.

func (Instance) GetSavedVersion

func (self Instance) GetSavedVersion() int

Returns the last tagged saved version from [method tag_saved_version].

func (Instance) GetScrollPosForLine

func (self Instance) GetScrollPosForLine(line int) Float.X

Returns the scroll position for [param wrap_index] of [param line].

func (Instance) GetSelectedText

func (self Instance) GetSelectedText() string

Returns the text inside the selection of a caret, or all the carets if [param caret_index] is its default value [code]-1[/code].

func (Instance) GetSelectionAtLineColumn

func (self Instance) GetSelectionAtLineColumn(line int, column int) int

Returns the caret index of the selection at the given [param line] and [param column], or [code]-1[/code] if there is none. If [param include_edges] is [code]false[/code], the position must be inside the selection and not at either end. If [param only_selections] is [code]false[/code], carets without a selection will also be considered.

func (Instance) GetSelectionColumn

func (self Instance) GetSelectionColumn() int

Returns the original start column of the selection.

func (Instance) GetSelectionFromColumn

func (self Instance) GetSelectionFromColumn() int

Returns the selection begin column. Returns the caret column if there is no selection.

func (Instance) GetSelectionFromLine

func (self Instance) GetSelectionFromLine() int

Returns the selection begin line. Returns the caret line if there is no selection.

func (Instance) GetSelectionLine

func (self Instance) GetSelectionLine() int

Returns the original start line of the selection.

func (Instance) GetSelectionMode

func (self Instance) GetSelectionMode() gdclass.TextEditSelectionMode

Returns the current selection mode.

func (Instance) GetSelectionOriginColumn

func (self Instance) GetSelectionOriginColumn() int

Returns the origin column of the selection. This is the opposite end from the caret.

func (Instance) GetSelectionOriginLine

func (self Instance) GetSelectionOriginLine() int

Returns the origin line of the selection. This is the opposite end from the caret.

func (Instance) GetSelectionToColumn

func (self Instance) GetSelectionToColumn() int

Returns the selection end column. Returns the caret column if there is no selection.

func (Instance) GetSelectionToLine

func (self Instance) GetSelectionToLine() int

Returns the selection end line. Returns the caret line if there is no selection.

func (Instance) GetSortedCarets

func (self Instance) GetSortedCarets() []int32

Returns the carets sorted by selection beginning from lowest line and column to highest (from top to bottom of text). If [param include_ignored_carets] is [code]false[/code], carets from [method multicaret_edit_ignore_caret] will be ignored.

func (Instance) GetTabSize

func (self Instance) GetTabSize() int

Returns the [TextEdit]'s' tab size.

func (Instance) GetTotalGutterWidth

func (self Instance) GetTotalGutterWidth() int

Returns the total width of all gutters and internal padding.

func (Instance) GetTotalVisibleLineCount

func (self Instance) GetTotalVisibleLineCount() int

Returns the number of lines that may be drawn.

func (Instance) GetVScrollBar

func (self Instance) GetVScrollBar() [1]gdclass.VScrollBar

Returns the [VScrollBar] of the [TextEdit].

func (Instance) GetVersion

func (self Instance) GetVersion() int

Returns the current version of the [TextEdit]. The version is a count of recorded operations by the undo/redo history.

func (Instance) GetVisibleLineCount

func (self Instance) GetVisibleLineCount() int

Returns the number of visible lines, including wrapped text.

func (Instance) GetVisibleLineCountInRange

func (self Instance) GetVisibleLineCountInRange(from_line int, to_line int) int

Returns the total number of visible + wrapped lines between the two lines.

func (Instance) GetWordAtPos

func (self Instance) GetWordAtPos(position Vector2.XY) string

Returns the word at [param position].

func (Instance) GetWordUnderCaret

func (self Instance) GetWordUnderCaret() string

Returns a [String] text with the word under the caret's location.

func (Instance) HasImeText

func (self Instance) HasImeText() bool

Returns [code]true[/code] if the user has text in the [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url] (IME).

func (Instance) HasRedo

func (self Instance) HasRedo() bool

Returns [code]true[/code] if a "redo" action is available.

func (Instance) HasSelection

func (self Instance) HasSelection() bool

Returns [code]true[/code] if the user has selected text.

func (Instance) HasUndo

func (self Instance) HasUndo() bool

Returns [code]true[/code] if an "undo" action is available.

func (Instance) HighlightAllOccurrences

func (self Instance) HighlightAllOccurrences() bool

func (Instance) HighlightCurrentLine

func (self Instance) HighlightCurrentLine() bool

func (Instance) IndentWrappedLines

func (self Instance) IndentWrappedLines() bool

func (Instance) InsertLineAt

func (self Instance) InsertLineAt(line int, text string)

Inserts a new line with [param text] at [param line].

func (Instance) InsertText

func (self Instance) InsertText(text string, line int, column int)

Inserts the [param text] at [param line] and [param column]. If [param before_selection_begin] is [code]true[/code], carets and selections that begin at [param line] and [param column] will moved to the end of the inserted text, along with all carets after it. If [param before_selection_end] is [code]true[/code], selections that end at [param line] and [param column] will be extended to the end of the inserted text. These parameters can be used to insert text inside of or outside of selections.

func (Instance) InsertTextAtCaret

func (self Instance) InsertTextAtCaret(text string)

Insert the specified text at the caret position.

func (Instance) IsCaretAfterSelectionOrigin

func (self Instance) IsCaretAfterSelectionOrigin() bool

Returns [code]true[/code] if the caret of the selection is after the selection origin. This can be used to determine the direction of the selection.

func (Instance) IsCaretVisible

func (self Instance) IsCaretVisible() bool

Returns [code]true[/code] if the caret is visible on the screen.

func (Instance) IsDraggingCursor

func (self Instance) IsDraggingCursor() bool

Returns [code]true[/code] if the user is dragging their mouse for scrolling, selecting, or text dragging.

func (Instance) IsGutterClickable

func (self Instance) IsGutterClickable(gutter int) bool

Returns whether the gutter is clickable.

func (Instance) IsGutterDrawn

func (self Instance) IsGutterDrawn(gutter int) bool

Returns whether the gutter is currently drawn.

func (Instance) IsGutterOverwritable

func (self Instance) IsGutterOverwritable(gutter int) bool

Returns whether the gutter is overwritable.

func (Instance) IsInMulitcaretEdit

func (self Instance) IsInMulitcaretEdit() bool

Returns [code]true[/code] if a [method begin_multicaret_edit] has been called and [method end_multicaret_edit] has not yet been called.

func (Instance) IsLineGutterClickable

func (self Instance) IsLineGutterClickable(line int, gutter int) bool

Returns whether the gutter on the given line is clickable.

func (Instance) IsLineWrapped

func (self Instance) IsLineWrapped(line int) bool

Returns if the given line is wrapped.

func (Instance) IsMenuVisible

func (self Instance) IsMenuVisible() bool

Returns whether the menu is visible. Use this instead of [code]get_menu().visible[/code] to improve performance (so the creation of the menu is avoided).

func (Instance) IsMouseOverSelection

func (self Instance) IsMouseOverSelection(edges bool) bool

Returns whether the mouse is over selection. If [param edges] is [code]true[/code], the edges are considered part of the selection.

func (Instance) IsOvertypeModeEnabled

func (self Instance) IsOvertypeModeEnabled() bool

Returns whether the user is in overtype mode.

func (Instance) Language

func (self Instance) Language() string

func (Instance) MenuOption

func (self Instance) MenuOption(option int)

Executes a given action as defined in the [enum MenuItems] enum.

func (Instance) MergeGutters

func (self Instance) MergeGutters(from_line int, to_line int)

Merge the gutters from [param from_line] into [param to_line]. Only overwritable gutters will be copied.

func (Instance) MergeOverlappingCarets

func (self Instance) MergeOverlappingCarets()

Merges any overlapping carets. Will favor the newest caret, or the caret with a selection. If [method is_in_mulitcaret_edit] is [code]true[/code], the merge will be queued to happen at the end of the multicaret edit. See [method begin_multicaret_edit] and [method end_multicaret_edit]. [b]Note:[/b] This is not called when a caret changes position but after certain actions, so it is possible to get into a state where carets overlap.

func (Instance) MiddleMousePasteEnabled

func (self Instance) MiddleMousePasteEnabled() bool

func (Instance) MinimapDraw

func (self Instance) MinimapDraw() bool

func (Instance) MinimapWidth

func (self Instance) MinimapWidth() int

func (Instance) MulticaretEditIgnoreCaret

func (self Instance) MulticaretEditIgnoreCaret(caret_index int) bool

Returns [code]true[/code] if the given [param caret_index] should be ignored as part of a multicaret edit. See [method begin_multicaret_edit] and [method end_multicaret_edit]. 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. It is recommended to [code]continue[/code] within a loop iterating on multiple carets if a caret should be ignored.

func (Instance) OnCaretChanged

func (self Instance) OnCaretChanged(cb func())

func (Instance) OnGutterAdded

func (self Instance) OnGutterAdded(cb func())

func (Instance) OnGutterClicked

func (self Instance) OnGutterClicked(cb func(line int, gutter int))

func (Instance) OnGutterRemoved

func (self Instance) OnGutterRemoved(cb func())

func (Instance) OnLinesEditedFrom

func (self Instance) OnLinesEditedFrom(cb func(from_line int, to_line int))

func (Instance) OnTextChanged

func (self Instance) OnTextChanged(cb func())

func (Instance) OnTextSet

func (self Instance) OnTextSet(cb func())

func (Instance) Paste

func (self Instance) Paste()

Paste at the current location. Can be overridden with [method _paste].

func (Instance) PastePrimaryClipboard

func (self Instance) PastePrimaryClipboard()

Pastes the primary clipboard.

func (Instance) PlaceholderText

func (self Instance) PlaceholderText() string

func (Instance) Redo

func (self Instance) Redo()

Perform redo operation.

func (Instance) RemoveCaret

func (self Instance) RemoveCaret(caret int)

Removes the given caret index. [b]Note:[/b] This can result in adjustment of all other caret indices.

func (Instance) RemoveGutter

func (self Instance) RemoveGutter(gutter int)

Removes the gutter from this [TextEdit].

func (Instance) RemoveLineAt

func (self Instance) RemoveLineAt(line int)

Removes the line of text at [param line]. Carets on this line will attempt to match their previous visual x position. If [param move_carets_down] is [code]true[/code] carets will move to the next line down, otherwise carets will move up.

func (Instance) RemoveSecondaryCarets

func (self Instance) RemoveSecondaryCarets()

Removes all additional carets.

func (Instance) RemoveText

func (self Instance) RemoveText(from_line int, from_column int, to_line int, to_column int)

Removes text between the given positions.

func (Instance) ScrollFitContentHeight

func (self Instance) ScrollFitContentHeight() bool

func (Instance) ScrollHorizontal

func (self Instance) ScrollHorizontal() int

func (Instance) ScrollPastEndOfFile

func (self Instance) ScrollPastEndOfFile() bool

func (Instance) ScrollSmooth

func (self Instance) ScrollSmooth() bool

func (Instance) ScrollVScrollSpeed

func (self Instance) ScrollVScrollSpeed() Float.X

func (Instance) ScrollVertical

func (self Instance) ScrollVertical() Float.X

func (Instance) Search

func (self Instance) Search(text string, flags int, from_line int, from_column int) Vector2i.XY

Perform a search inside the text. Search flags can be specified in the [enum SearchFlags] enum. In the returned vector, [code]x[/code] is the column, [code]y[/code] is the line. If no results are found, both are equal to [code]-1[/code]. [codeblocks] [gdscript] var result = search("print", SEARCH_WHOLE_WORDS, 0, 0) if result.x != -1:

# Result found.
var line_number = result.y
var column_number = result.x

[/gdscript] [csharp] Vector2I result = Search("print", (uint)TextEdit.SearchFlags.WholeWords, 0, 0); if (result.X != -1)

{
    // Result found.
    int lineNumber = result.Y;
    int columnNumber = result.X;
}

[/csharp] [/codeblocks]

func (Instance) Select

func (self Instance) Select(origin_line int, origin_column int, caret_line int, caret_column int)

Selects text from [param origin_line] and [param origin_column] to [param caret_line] and [param caret_column] for the given [param caret_index]. This moves the selection origin and the caret. If the positions are the same, the selection will be deselected. If [member selecting_enabled] is [code]false[/code], no selection will occur. [b]Note:[/b] If supporting multiple carets this will not check for any overlap. See [method merge_overlapping_carets].

func (Instance) SelectAll

func (self Instance) SelectAll()

Select all the text. If [member selecting_enabled] is [code]false[/code], no selection will occur.

func (Instance) SelectWordUnderCaret

func (self Instance) SelectWordUnderCaret()

Selects the word under the caret.

func (Instance) SelectingEnabled

func (self Instance) SelectingEnabled() bool

func (Instance) SetAutowrapMode

func (self Instance) SetAutowrapMode(value gdclass.TextServerAutowrapMode)
func (self Instance) SetCaretBlink(value bool)

func (Instance) SetCaretBlinkInterval

func (self Instance) SetCaretBlinkInterval(value Float.X)

func (Instance) SetCaretColumn

func (self Instance) SetCaretColumn(column int)

Moves the caret to the specified [param column] index. If [param adjust_viewport] is [code]true[/code], the viewport will center at the caret position after the move occurs. [b]Note:[/b] If supporting multiple carets this will not check for any overlap. See [method merge_overlapping_carets].

func (Instance) SetCaretDrawWhenEditableDisabled

func (self Instance) SetCaretDrawWhenEditableDisabled(value bool)

func (Instance) SetCaretLine

func (self Instance) SetCaretLine(line int)

Moves the caret to the specified [param line] index. The caret column will be moved to the same visual position it was at the last time [method set_caret_column] was called, or clamped to the end of the line. If [param adjust_viewport] is [code]true[/code], the viewport will center at the caret position after the move occurs. If [param can_be_hidden] is [code]true[/code], the specified [param line] can be hidden. If [param wrap_index] is [code]-1[/code], the caret column will be clamped to the [param line]'s length. If [param wrap_index] is greater than [code]-1[/code], the column will be moved to attempt to match the visual x position on the line's [param wrap_index] to the position from the last time [method set_caret_column] was called. [b]Note:[/b] If supporting multiple carets this will not check for any overlap. See [method merge_overlapping_carets].

func (Instance) SetCaretMidGrapheme

func (self Instance) SetCaretMidGrapheme(value bool)

func (Instance) SetCaretMoveOnRightClick

func (self Instance) SetCaretMoveOnRightClick(value bool)

func (Instance) SetCaretMultiple

func (self Instance) SetCaretMultiple(value bool)

func (Instance) SetCaretType

func (self Instance) SetCaretType(value gdclass.TextEditCaretType)

func (Instance) SetContextMenuEnabled

func (self Instance) SetContextMenuEnabled(value bool)

func (Instance) SetCustomWordSeparators

func (self Instance) SetCustomWordSeparators(value string)

func (Instance) SetDeselectOnFocusLossEnabled

func (self Instance) SetDeselectOnFocusLossEnabled(value bool)

func (Instance) SetDragAndDropSelectionEnabled

func (self Instance) SetDragAndDropSelectionEnabled(value bool)

func (Instance) SetDrawControlChars

func (self Instance) SetDrawControlChars(value bool)

func (Instance) SetDrawSpaces

func (self Instance) SetDrawSpaces(value bool)

func (Instance) SetDrawTabs

func (self Instance) SetDrawTabs(value bool)

func (Instance) SetEditable

func (self Instance) SetEditable(value bool)

func (Instance) SetGutterClickable

func (self Instance) SetGutterClickable(gutter int, clickable bool)

Sets the gutter as clickable. This will change the mouse cursor to a pointing hand when hovering over the gutter.

func (Instance) SetGutterCustomDraw

func (self Instance) SetGutterCustomDraw(column int, draw_callback func(line int, gutter int, area Rect2.PositionSize))

Set a custom draw method for the gutter. The callback method must take the following args: [code]line: int, gutter: int, Area: Rect2[/code]. This only works when the gutter type is [constant GUTTER_TYPE_CUSTOM] (see [method set_gutter_type]).

func (Instance) SetGutterDraw

func (self Instance) SetGutterDraw(gutter int, draw bool)

Sets whether the gutter should be drawn.

func (Instance) SetGutterName

func (self Instance) SetGutterName(gutter int, name string)

Sets the name of the gutter.

func (Instance) SetGutterOverwritable

func (self Instance) SetGutterOverwritable(gutter int, overwritable bool)

Sets the gutter to overwritable. See [method merge_gutters].

func (Instance) SetGutterType

func (self Instance) SetGutterType(gutter int, atype gdclass.TextEditGutterType)

Sets the type of gutter. Gutters can contain icons, text, or custom visuals. See [enum TextEdit.GutterType] for options.

func (Instance) SetGutterWidth

func (self Instance) SetGutterWidth(gutter int, width int)

Set the width of the gutter.

func (Instance) SetHighlightAllOccurrences

func (self Instance) SetHighlightAllOccurrences(value bool)

func (Instance) SetHighlightCurrentLine

func (self Instance) SetHighlightCurrentLine(value bool)

func (Instance) SetIndentWrappedLines

func (self Instance) SetIndentWrappedLines(value bool)

func (Instance) SetLanguage

func (self Instance) SetLanguage(value string)

func (Instance) SetLine

func (self Instance) SetLine(line int, new_text string)

Sets the text for a specific [param line]. Carets on the line will attempt to keep their visual x position.

func (Instance) SetLineAsCenterVisible

func (self Instance) SetLineAsCenterVisible(line int)

Positions the [param wrap_index] of [param line] at the center of the viewport.

func (Instance) SetLineAsFirstVisible

func (self Instance) SetLineAsFirstVisible(line int)

Positions the [param wrap_index] of [param line] at the top of the viewport.

func (Instance) SetLineAsLastVisible

func (self Instance) SetLineAsLastVisible(line int)

Positions the [param wrap_index] of [param line] at the bottom of the viewport.

func (Instance) SetLineBackgroundColor

func (self Instance) SetLineBackgroundColor(line int, color Color.RGBA)

Sets the current background color of the line. Set to [code]Color(0, 0, 0, 0)[/code] for no color.

func (Instance) SetLineGutterClickable

func (self Instance) SetLineGutterClickable(line int, gutter int, clickable bool)

If [param clickable] is [code]true[/code], makes the [param gutter] on [param line] clickable. See [signal gutter_clicked].

func (Instance) SetLineGutterIcon

func (self Instance) SetLineGutterIcon(line int, gutter int, icon [1]gdclass.Texture2D)

Sets the icon for [param gutter] on [param line] to [param icon]. This only works when the gutter type is [constant GUTTER_TYPE_ICON] (see [method set_gutter_type]).

func (Instance) SetLineGutterItemColor

func (self Instance) SetLineGutterItemColor(line int, gutter int, color Color.RGBA)

Sets the color for [param gutter] on [param line] to [param color].

func (Instance) SetLineGutterMetadata

func (self Instance) SetLineGutterMetadata(line int, gutter int, metadata any)

Sets the metadata for [param gutter] on [param line] to [param metadata].

func (Instance) SetLineGutterText

func (self Instance) SetLineGutterText(line int, gutter int, text string)

Sets the text for [param gutter] on [param line] to [param text]. This only works when the gutter type is [constant GUTTER_TYPE_STRING] (see [method set_gutter_type]).

func (Instance) SetMiddleMousePasteEnabled

func (self Instance) SetMiddleMousePasteEnabled(value bool)

func (Instance) SetMinimapDraw

func (self Instance) SetMinimapDraw(value bool)

func (Instance) SetMinimapWidth

func (self Instance) SetMinimapWidth(value int)

func (Instance) SetOvertypeModeEnabled

func (self Instance) SetOvertypeModeEnabled(enabled bool)

If [code]true[/code], sets the user into overtype mode. When the user types in this mode, it will override existing text.

func (Instance) SetPlaceholderText

func (self Instance) SetPlaceholderText(value string)

func (Instance) SetScrollFitContentHeight

func (self Instance) SetScrollFitContentHeight(value bool)

func (Instance) SetScrollHorizontal

func (self Instance) SetScrollHorizontal(value int)

func (Instance) SetScrollPastEndOfFile

func (self Instance) SetScrollPastEndOfFile(value bool)

func (Instance) SetScrollSmooth

func (self Instance) SetScrollSmooth(value bool)

func (Instance) SetScrollVScrollSpeed

func (self Instance) SetScrollVScrollSpeed(value Float.X)

func (Instance) SetScrollVertical

func (self Instance) SetScrollVertical(value Float.X)

func (Instance) SetSearchFlags

func (self Instance) SetSearchFlags(flags int)

Sets the search [param flags]. This is used with [method set_search_text] to highlight occurrences of the searched text. Search flags can be specified from the [enum SearchFlags] enum.

func (Instance) SetSearchText

func (self Instance) SetSearchText(search_text string)

Sets the search text. See [method set_search_flags].

func (Instance) SetSelectingEnabled

func (self Instance) SetSelectingEnabled(value bool)

func (Instance) SetSelectionMode

func (self Instance) SetSelectionMode(mode gdclass.TextEditSelectionMode)

Sets the current selection mode.

func (Instance) SetSelectionOriginColumn

func (self Instance) SetSelectionOriginColumn(column int)

Sets the selection origin column to the [param column] for the given [param caret_index]. If the selection origin is moved to the caret position, the selection will deselect.

func (Instance) SetSelectionOriginLine

func (self Instance) SetSelectionOriginLine(line int)

Sets the selection origin line to the [param line] for the given [param caret_index]. If the selection origin is moved to the caret position, the selection will deselect. If [param can_be_hidden] is [code]false[/code], The line will be set to the nearest unhidden line below or above. If [param wrap_index] is [code]-1[/code], the selection origin column will be clamped to the [param line]'s length. If [param wrap_index] is greater than [code]-1[/code], the column will be moved to attempt to match the visual x position on the line's [param wrap_index] to the position from the last time [method set_selection_origin_column] or [method select] was called.

func (Instance) SetShortcutKeysEnabled

func (self Instance) SetShortcutKeysEnabled(value bool)

func (Instance) SetStructuredTextBidiOverride

func (self Instance) SetStructuredTextBidiOverride(value gdclass.TextServerStructuredTextParser)

func (Instance) SetStructuredTextBidiOverrideOptions

func (self Instance) SetStructuredTextBidiOverrideOptions(value []any)

func (Instance) SetSyntaxHighlighter

func (self Instance) SetSyntaxHighlighter(value [1]gdclass.SyntaxHighlighter)

func (Instance) SetTabSize

func (self Instance) SetTabSize(size int)

Sets the tab size for the [TextEdit] to use.

func (Instance) SetText

func (self Instance) SetText(value string)

func (Instance) SetTextDirection

func (self Instance) SetTextDirection(value gdclass.ControlTextDirection)

func (Instance) SetTooltipRequestFunc

func (self Instance) SetTooltipRequestFunc(callback func(hovered_word string) string)

Provide custom tooltip text. The callback method must take the following args: [code]hovered_word: String[/code].

func (Instance) SetUseCustomWordSeparators

func (self Instance) SetUseCustomWordSeparators(value bool)

func (Instance) SetUseDefaultWordSeparators

func (self Instance) SetUseDefaultWordSeparators(value bool)

func (Instance) SetVirtualKeyboardEnabled

func (self Instance) SetVirtualKeyboardEnabled(value bool)

func (Instance) SetWrapMode

func (self Instance) SetWrapMode(value gdclass.TextEditLineWrappingMode)

func (Instance) ShortcutKeysEnabled

func (self Instance) ShortcutKeysEnabled() bool

func (Instance) SkipSelectionForNextOccurrence

func (self Instance) 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 (Instance) StartAction

func (self Instance) StartAction(action gdclass.TextEditEditAction)

Starts an action, will end the current action if [param action] is different. An action will also end after a call to [method end_action], after [member ProjectSettings.gui/timers/text_edit_idle_detect_sec] is triggered or a new undoable step outside the [method start_action] and [method end_action] calls.

func (Instance) StructuredTextBidiOverride

func (self Instance) StructuredTextBidiOverride() gdclass.TextServerStructuredTextParser

func (Instance) StructuredTextBidiOverrideOptions

func (self Instance) StructuredTextBidiOverrideOptions() []any

func (Instance) SwapLines

func (self Instance) SwapLines(from_line int, to_line int)

Swaps the two lines. Carets will be swapped with the lines.

func (Instance) SyntaxHighlighter

func (self Instance) SyntaxHighlighter() [1]gdclass.SyntaxHighlighter

func (Instance) TagSavedVersion

func (self Instance) TagSavedVersion()

Tag the current version as saved.

func (Instance) Text

func (self Instance) Text() string

func (Instance) TextDirection

func (self Instance) TextDirection() gdclass.ControlTextDirection

func (Instance) Undo

func (self Instance) Undo()

Perform undo operation.

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) UseCustomWordSeparators

func (self Instance) UseCustomWordSeparators() bool

func (Instance) UseDefaultWordSeparators

func (self Instance) UseDefaultWordSeparators() bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) VirtualKeyboardEnabled

func (self Instance) VirtualKeyboardEnabled() bool

func (Instance) WrapMode

func (self Instance) WrapMode() gdclass.TextEditLineWrappingMode

type Interface

type Interface interface {
	//Override this method to define what happens when the user types in the provided key [param unicode_char].
	HandleUnicodeInput(unicode_char int, caret_index int)
	//Override this method to define what happens when the user presses the backspace key.
	Backspace(caret_index int)
	//Override this method to define what happens when the user performs a cut operation.
	Cut(caret_index int)
	//Override this method to define what happens when the user performs a copy operation.
	Copy(caret_index int)
	//Override this method to define what happens when the user performs a paste operation.
	Paste(caret_index int)
	//Override this method to define what happens when the user performs a paste operation with middle mouse button.
	//[b]Note:[/b] This method is only implemented on Linux.
	PastePrimaryClipboard(caret_index int)
}

type LineWrappingMode

type LineWrappingMode = gdclass.TextEditLineWrappingMode //gd:TextEdit.LineWrappingMode
const (
	/*Line wrapping is disabled.*/
	LineWrappingNone LineWrappingMode = 0
	/*Line wrapping occurs at the control boundary, beyond what would normally be visible.*/
	LineWrappingBoundary LineWrappingMode = 1
)
type MenuItems = gdclass.TextEditMenuItems //gd:TextEdit.MenuItems
const (
	/*Cuts (copies and clears) the selected text.*/
	MenuCut MenuItems = 0
	/*Copies the selected text.*/
	MenuCopy MenuItems = 1
	/*Pastes the clipboard text over the selected text (or at the cursor's position).*/
	MenuPaste MenuItems = 2
	/*Erases the whole [TextEdit] text.*/
	MenuClear MenuItems = 3
	/*Selects the whole [TextEdit] text.*/
	MenuSelectAll MenuItems = 4
	/*Undoes the previous action.*/
	MenuUndo MenuItems = 5
	/*Redoes the previous action.*/
	MenuRedo MenuItems = 6
	/*ID of "Text Writing Direction" submenu.*/
	MenuSubmenuTextDir MenuItems = 7
	/*Sets text direction to inherited.*/
	MenuDirInherited MenuItems = 8
	/*Sets text direction to automatic.*/
	MenuDirAuto MenuItems = 9
	/*Sets text direction to left-to-right.*/
	MenuDirLtr MenuItems = 10
	/*Sets text direction to right-to-left.*/
	MenuDirRtl MenuItems = 11
	/*Toggles control character display.*/
	MenuDisplayUcc MenuItems = 12
	/*ID of "Insert Control Character" submenu.*/
	MenuSubmenuInsertUcc MenuItems = 13
	/*Inserts left-to-right mark (LRM) character.*/
	MenuInsertLrm MenuItems = 14
	/*Inserts right-to-left mark (RLM) character.*/
	MenuInsertRlm MenuItems = 15
	/*Inserts start of left-to-right embedding (LRE) character.*/
	MenuInsertLre MenuItems = 16
	/*Inserts start of right-to-left embedding (RLE) character.*/
	MenuInsertRle MenuItems = 17
	/*Inserts start of left-to-right override (LRO) character.*/
	MenuInsertLro MenuItems = 18
	/*Inserts start of right-to-left override (RLO) character.*/
	MenuInsertRlo MenuItems = 19
	/*Inserts pop direction formatting (PDF) character.*/
	MenuInsertPdf MenuItems = 20
	/*Inserts Arabic letter mark (ALM) character.*/
	MenuInsertAlm MenuItems = 21
	/*Inserts left-to-right isolate (LRI) character.*/
	MenuInsertLri MenuItems = 22
	/*Inserts right-to-left isolate (RLI) character.*/
	MenuInsertRli MenuItems = 23
	/*Inserts first strong isolate (FSI) character.*/
	MenuInsertFsi MenuItems = 24
	/*Inserts pop direction isolate (PDI) character.*/
	MenuInsertPdi MenuItems = 25
	/*Inserts zero width joiner (ZWJ) character.*/
	MenuInsertZwj MenuItems = 26
	/*Inserts zero width non-joiner (ZWNJ) character.*/
	MenuInsertZwnj MenuItems = 27
	/*Inserts word joiner (WJ) character.*/
	MenuInsertWj MenuItems = 28
	/*Inserts soft hyphen (SHY) character.*/
	MenuInsertShy MenuItems = 29
	/*Represents the size of the [enum MenuItems] enum.*/
	MenuMax MenuItems = 30
)

type SearchFlags

type SearchFlags = gdclass.TextEditSearchFlags //gd:TextEdit.SearchFlags
const (
	/*Match case when searching.*/
	SearchMatchCase SearchFlags = 1
	/*Match whole words when searching.*/
	SearchWholeWords SearchFlags = 2
	/*Search from end to beginning.*/
	SearchBackwards SearchFlags = 4
)

type SelectionMode

type SelectionMode = gdclass.TextEditSelectionMode //gd:TextEdit.SelectionMode
const (
	/*Not selecting.*/
	SelectionModeNone SelectionMode = 0
	/*Select as if [code]shift[/code] is pressed.*/
	SelectionModeShift SelectionMode = 1
	/*Select single characters as if the user single clicked.*/
	SelectionModePointer SelectionMode = 2
	/*Select whole words as if the user double clicked.*/
	SelectionModeWord SelectionMode = 3
	/*Select whole lines as if the user triple clicked.*/
	SelectionModeLine SelectionMode = 4
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL