CodeEdit

package
v0.0.0-...-ae8aae0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package CodeEdit provides methods for working with CodeEdit 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
	AsCodeEdit() Instance
}

type CodeCompletionKind

type CodeCompletionKind = gdclass.CodeEditCodeCompletionKind //gd:CodeEdit.CodeCompletionKind
const (
	/*Marks the option as a class.*/
	KindClass CodeCompletionKind = 0
	/*Marks the option as a function.*/
	KindFunction CodeCompletionKind = 1
	/*Marks the option as a Godot signal.*/
	KindSignal CodeCompletionKind = 2
	/*Marks the option as a variable.*/
	KindVariable CodeCompletionKind = 3
	/*Marks the option as a member.*/
	KindMember CodeCompletionKind = 4
	/*Marks the option as an enum entry.*/
	KindEnum CodeCompletionKind = 5
	/*Marks the option as a constant.*/
	KindConstant CodeCompletionKind = 6
	/*Marks the option as a Godot node path.*/
	KindNodePath CodeCompletionKind = 7
	/*Marks the option as a file path.*/
	KindFilePath CodeCompletionKind = 8
	/*Marks the option as unclassified or plain text.*/
	KindPlainText CodeCompletionKind = 9
)

type CodeCompletionLocation

type CodeCompletionLocation = gdclass.CodeEditCodeCompletionLocation //gd:CodeEdit.CodeCompletionLocation
const (
	/*The option is local to the location of the code completion query - e.g. a local variable. Subsequent value of location represent options from the outer class, the exact value represent how far they are (in terms of inner classes).*/
	LocationLocal CodeCompletionLocation = 0
	/*The option is from the containing class or a parent class, relative to the location of the code completion query. Perform a bitwise OR with the class depth (e.g. [code]0[/code] for the local class, [code]1[/code] for the parent, [code]2[/code] for the grandparent, etc.) to store the depth of an option in the class or a parent class.*/
	LocationParentMask CodeCompletionLocation = 256
	/*The option is from user code which is not local and not in a derived class (e.g. Autoload Singletons).*/
	LocationOtherUserCode CodeCompletionLocation = 512
	/*The option is from other engine code, not covered by the other enum constants - e.g. built-in classes.*/
	LocationOther CodeCompletionLocation = 1024
)

type CompletionInfo

type CompletionInfo struct {
	Kind        [1]gdclass.CodeEditCodeCompletionKind `gd:"kind"`
	DisplayText string                                `gd:"display_text"`
	InsertText  string                                `gd:"insert_text"`
	FontColor   struct {
		R float32
		G float32
		B float32
		A float32
	} `gd:"font_color"`
	Icon         Path.ToFile `gd:"icon"`
	DefaultValue string      `gd:"default_value"`
}

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.CodeEdit

CodeEdit is a specialized [TextEdit] designed for editing plain text code files. It has many features commonly found in code editors such as line numbers, line folding, code completion, indent management, and string/comment management. [b]Note:[/b] Regardless of locale, [CodeEdit] will by default always use left-to-right text direction to correctly display source code.

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

%!(EXTRA string=CodeEdit)

var Nil Instance

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

func New

func New() Instance

func (Instance) AddAutoBraceCompletionPair

func (self Instance) AddAutoBraceCompletionPair(start_key string, end_key string)

Adds a brace pair. Both the start and end keys must be symbols. Only the start key has to be unique.

func (Instance) AddCodeCompletionOption

func (self Instance) AddCodeCompletionOption(atype gdclass.CodeEditCodeCompletionKind, display_text string, insert_text string)

Submits an item to the queue of potential candidates for the autocomplete menu. Call [method update_code_completion_options] to update the list. [param location] indicates location of the option relative to the location of the code completion query. See [enum CodeEdit.CodeCompletionLocation] for how to set this value. [b]Note:[/b] This list will replace all current candidates.

func (Instance) AddCommentDelimiter

func (self Instance) AddCommentDelimiter(start_key string, end_key string)

Adds a comment delimiter from [param start_key] to [param end_key]. Both keys should be symbols, and [param start_key] must not be shared with other delimiters. If [param line_only] is [code]true[/code] or [param end_key] is an empty [String], the region does not carry over to the next line.

func (Instance) AddStringDelimiter

func (self Instance) AddStringDelimiter(start_key string, end_key string)

Defines a string delimiter from [param start_key] to [param end_key]. Both keys should be symbols, and [param start_key] must not be shared with other delimiters. If [param line_only] is [code]true[/code] or [param end_key] is an empty [String], the region does not carry over to the next line.

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsCodeEdit

func (self Instance) AsCodeEdit() 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() TextEdit.Instance

func (Instance) AutoBraceCompletionEnabled

func (self Instance) AutoBraceCompletionEnabled() bool

func (Instance) AutoBraceCompletionHighlightMatching

func (self Instance) AutoBraceCompletionHighlightMatching() bool

func (Instance) AutoBraceCompletionPairs

func (self Instance) AutoBraceCompletionPairs() map[any]any

func (Instance) CanFoldLine

func (self Instance) CanFoldLine(line int) bool

Returns if the given line is foldable, that is, it has indented lines right below it or a comment / string block.

func (Instance) CancelCodeCompletion

func (self Instance) CancelCodeCompletion()

Cancels the autocomplete menu.

func (Instance) ClearBookmarkedLines

func (self Instance) ClearBookmarkedLines()

Clears all bookmarked lines.

func (Instance) ClearBreakpointedLines

func (self Instance) ClearBreakpointedLines()

Clears all breakpointed lines.

func (Instance) ClearCommentDelimiters

func (self Instance) ClearCommentDelimiters()

Removes all comment delimiters.

func (Instance) ClearExecutingLines

func (self Instance) ClearExecutingLines()

Clears all executed lines.

func (Instance) ClearStringDelimiters

func (self Instance) ClearStringDelimiters()

Removes all string delimiters.

func (Instance) CodeCompletionEnabled

func (self Instance) CodeCompletionEnabled() bool

func (Instance) CodeCompletionPrefixes

func (self Instance) CodeCompletionPrefixes() []string

func (Instance) ConfirmCodeCompletion

func (self Instance) ConfirmCodeCompletion()

Inserts the selected entry into the text. If [param replace] is [code]true[/code], any existing text is replaced rather than merged.

func (Instance) ConvertIndent

func (self Instance) ConvertIndent()

Converts the indents of lines between [param from_line] and [param to_line] to tabs or spaces as set by [member indent_use_spaces]. Values of [code]-1[/code] convert the entire text.

func (Instance) CreateCodeRegion

func (self Instance) CreateCodeRegion()

Creates a new code region with the selection. At least one single line comment delimiter have to be defined (see [method add_comment_delimiter]). A code region is a part of code that is highlighted when folded and can help organize your script. Code region start and end tags can be customized (see [method set_code_region_tags]). Code regions are delimited using start and end tags (respectively [code]region[/code] and [code]endregion[/code] by default) preceded by one line comment delimiter. (eg. [code]#region[/code] and [code]#endregion[/code])

func (Instance) DeleteLines

func (self Instance) DeleteLines()

Deletes all lines that are selected or have a caret on them.

func (Instance) DelimiterComments

func (self Instance) DelimiterComments() []string

func (Instance) DelimiterStrings

func (self Instance) DelimiterStrings() []string

func (Instance) DoIndent

func (self Instance) DoIndent()

Perform an indent as if the user activated the "ui_text_indent" action.

func (Instance) DuplicateLines

func (self Instance) DuplicateLines()

Duplicates all lines currently selected with any caret. Duplicates the entire line beneath the current one no matter where the caret is within the line.

func (Instance) DuplicateSelection

func (self Instance) DuplicateSelection()

Duplicates all selected text and duplicates all lines with a caret on them.

func (Instance) FoldAllLines

func (self Instance) FoldAllLines()

Folds all lines that are possible to be folded (see [method can_fold_line]).

func (Instance) FoldLine

func (self Instance) FoldLine(line int)

Folds the given line, if possible (see [method can_fold_line]).

func (Instance) GetAutoBraceCompletionCloseKey

func (self Instance) GetAutoBraceCompletionCloseKey(open_key string) string

Gets the matching auto brace close key for [param open_key].

func (Instance) GetBookmarkedLines

func (self Instance) GetBookmarkedLines() []int32

Gets all bookmarked lines.

func (Instance) GetBreakpointedLines

func (self Instance) GetBreakpointedLines() []int32

Gets all breakpointed lines.

func (Instance) GetCodeCompletionOption

func (self Instance) GetCodeCompletionOption(index int) CompletionInfo

Gets the completion option at [param index]. The return [Dictionary] has the following key-values: [code]kind[/code]: [enum CodeCompletionKind] [code]display_text[/code]: Text that is shown on the autocomplete menu. [code]insert_text[/code]: Text that is to be inserted when this item is selected. [code]font_color[/code]: Color of the text on the autocomplete menu. [code]icon[/code]: Icon to draw on the autocomplete menu. [code]default_value[/code]: Value of the symbol.

func (Instance) GetCodeCompletionOptions

func (self Instance) GetCodeCompletionOptions() []CompletionInfo

Gets all completion options, see [method get_code_completion_option] for return content.

func (Instance) GetCodeCompletionSelectedIndex

func (self Instance) GetCodeCompletionSelectedIndex() int

Gets the index of the current selected completion option.

func (Instance) GetCodeRegionEndTag

func (self Instance) GetCodeRegionEndTag() string

Returns the code region end tag (without comment delimiter).

func (Instance) GetCodeRegionStartTag

func (self Instance) GetCodeRegionStartTag() string

Returns the code region start tag (without comment delimiter).

func (Instance) GetDelimiterEndKey

func (self Instance) GetDelimiterEndKey(delimiter_index int) string

Gets the end key for a string or comment region index.

func (Instance) GetDelimiterEndPosition

func (self Instance) GetDelimiterEndPosition(line int, column int) Vector2.XY

If [param line] [param column] is in a string or comment, returns the end position of the region. If not or no end could be found, both [Vector2] values will be [code]-1[/code].

func (Instance) GetDelimiterStartKey

func (self Instance) GetDelimiterStartKey(delimiter_index int) string

Gets the start key for a string or comment region index.

func (Instance) GetDelimiterStartPosition

func (self Instance) GetDelimiterStartPosition(line int, column int) Vector2.XY

If [param line] [param column] is in a string or comment, returns the start position of the region. If not or no start could be found, both [Vector2] values will be [code]-1[/code].

func (Instance) GetExecutingLines

func (self Instance) GetExecutingLines() []int32

Gets all executing lines.

func (Instance) GetFoldedLines

func (self Instance) GetFoldedLines() []int

Returns all lines that are current folded.

func (Instance) GetTextForCodeCompletion

func (self Instance) GetTextForCodeCompletion() string

Returns the full text with char [code]0xFFFF[/code] at the caret location.

func (Instance) GetTextForSymbolLookup

func (self Instance) GetTextForSymbolLookup() string

Returns the full text with char [code]0xFFFF[/code] at the cursor location.

func (Instance) GetTextWithCursorChar

func (self Instance) GetTextWithCursorChar(line int, column int) string

Returns the full text with char [code]0xFFFF[/code] at the specified location.

func (Instance) GuttersDrawBookmarks

func (self Instance) GuttersDrawBookmarks() bool

func (Instance) GuttersDrawBreakpointsGutter

func (self Instance) GuttersDrawBreakpointsGutter() bool

func (Instance) GuttersDrawExecutingLines

func (self Instance) GuttersDrawExecutingLines() bool

func (Instance) GuttersDrawFoldGutter

func (self Instance) GuttersDrawFoldGutter() bool

func (Instance) GuttersDrawLineNumbers

func (self Instance) GuttersDrawLineNumbers() bool

func (Instance) GuttersZeroPadLineNumbers

func (self Instance) GuttersZeroPadLineNumbers() bool

func (Instance) HasAutoBraceCompletionCloseKey

func (self Instance) HasAutoBraceCompletionCloseKey(close_key string) bool

Returns [code]true[/code] if close key [param close_key] exists.

func (Instance) HasAutoBraceCompletionOpenKey

func (self Instance) HasAutoBraceCompletionOpenKey(open_key string) bool

Returns [code]true[/code] if open key [param open_key] exists.

func (Instance) HasCommentDelimiter

func (self Instance) HasCommentDelimiter(start_key string) bool

Returns [code]true[/code] if comment [param start_key] exists.

func (Instance) HasStringDelimiter

func (self Instance) HasStringDelimiter(start_key string) bool

Returns [code]true[/code] if string [param start_key] exists.

func (Instance) IndentAutomatic

func (self Instance) IndentAutomatic() bool

func (Instance) IndentAutomaticPrefixes

func (self Instance) IndentAutomaticPrefixes() []string

func (Instance) IndentLines

func (self Instance) IndentLines()

Indents selected lines, or in the case of no selection the caret line by one.

func (Instance) IndentSize

func (self Instance) IndentSize() int

func (Instance) IndentUseSpaces

func (self Instance) IndentUseSpaces() bool

func (Instance) IsInComment

func (self Instance) IsInComment(line int) int

Returns delimiter index if [param line] [param column] is in a comment. If [param column] is not provided, will return delimiter index if the entire [param line] is a comment. Otherwise [code]-1[/code].

func (Instance) IsInString

func (self Instance) IsInString(line int) int

Returns the delimiter index if [param line] [param column] is in a string. If [param column] is not provided, will return the delimiter index if the entire [param line] is a string. Otherwise [code]-1[/code].

func (Instance) IsLineBookmarked

func (self Instance) IsLineBookmarked(line int) bool

Returns whether the line at the specified index is bookmarked or not.

func (Instance) IsLineBreakpointed

func (self Instance) IsLineBreakpointed(line int) bool

Returns whether the line at the specified index is breakpointed or not.

func (Instance) IsLineCodeRegionEnd

func (self Instance) IsLineCodeRegionEnd(line int) bool

Returns whether the line at the specified index is a code region end.

func (Instance) IsLineCodeRegionStart

func (self Instance) IsLineCodeRegionStart(line int) bool

Returns whether the line at the specified index is a code region start.

func (Instance) IsLineExecuting

func (self Instance) IsLineExecuting(line int) bool

Returns whether the line at the specified index is marked as executing or not.

func (Instance) IsLineFolded

func (self Instance) IsLineFolded(line int) bool

Returns whether the line at the specified index is folded or not.

func (Instance) LineFolding

func (self Instance) LineFolding() bool

func (Instance) LineLengthGuidelines

func (self Instance) LineLengthGuidelines() []int

func (Instance) MoveLinesDown

func (self Instance) MoveLinesDown()

Moves all lines down that are selected or have a caret on them.

func (Instance) MoveLinesUp

func (self Instance) MoveLinesUp()

Moves all lines up that are selected or have a caret on them.

func (Instance) OnBreakpointToggled

func (self Instance) OnBreakpointToggled(cb func(line int))

func (Instance) OnCodeCompletionRequested

func (self Instance) OnCodeCompletionRequested(cb func())

func (Instance) OnSymbolLookup

func (self Instance) OnSymbolLookup(cb func(symbol string, line int, column int))

func (Instance) OnSymbolValidate

func (self Instance) OnSymbolValidate(cb func(symbol string))

func (Instance) RemoveCommentDelimiter

func (self Instance) RemoveCommentDelimiter(start_key string)

Removes the comment delimiter with [param start_key].

func (Instance) RemoveStringDelimiter

func (self Instance) RemoveStringDelimiter(start_key string)

Removes the string delimiter with [param start_key].

func (Instance) RequestCodeCompletion

func (self Instance) RequestCodeCompletion()

Emits [signal code_completion_requested], if [param force] is [code]true[/code] will bypass all checks. Otherwise will check that the caret is in a word or in front of a prefix. Will ignore the request if all current options are of type file path, node path, or signal.

func (Instance) SetAutoBraceCompletionEnabled

func (self Instance) SetAutoBraceCompletionEnabled(value bool)

func (Instance) SetAutoBraceCompletionHighlightMatching

func (self Instance) SetAutoBraceCompletionHighlightMatching(value bool)

func (Instance) SetAutoBraceCompletionPairs

func (self Instance) SetAutoBraceCompletionPairs(value map[any]any)

func (Instance) SetCodeCompletionEnabled

func (self Instance) SetCodeCompletionEnabled(value bool)

func (Instance) SetCodeCompletionPrefixes

func (self Instance) SetCodeCompletionPrefixes(value []string)

func (Instance) SetCodeCompletionSelectedIndex

func (self Instance) SetCodeCompletionSelectedIndex(index int)

Sets the current selected completion option.

func (Instance) SetCodeHint

func (self Instance) SetCodeHint(code_hint string)

Sets the code hint text. Pass an empty string to clear.

func (Instance) SetCodeHintDrawBelow

func (self Instance) SetCodeHintDrawBelow(draw_below bool)

Sets if the code hint should draw below the text.

func (Instance) SetCodeRegionTags

func (self Instance) SetCodeRegionTags()

Sets the code region start and end tags (without comment delimiter).

func (Instance) SetDelimiterComments

func (self Instance) SetDelimiterComments(value []string)

func (Instance) SetDelimiterStrings

func (self Instance) SetDelimiterStrings(value []string)

func (Instance) SetGuttersDrawBookmarks

func (self Instance) SetGuttersDrawBookmarks(value bool)

func (Instance) SetGuttersDrawBreakpointsGutter

func (self Instance) SetGuttersDrawBreakpointsGutter(value bool)

func (Instance) SetGuttersDrawExecutingLines

func (self Instance) SetGuttersDrawExecutingLines(value bool)

func (Instance) SetGuttersDrawFoldGutter

func (self Instance) SetGuttersDrawFoldGutter(value bool)

func (Instance) SetGuttersDrawLineNumbers

func (self Instance) SetGuttersDrawLineNumbers(value bool)

func (Instance) SetGuttersZeroPadLineNumbers

func (self Instance) SetGuttersZeroPadLineNumbers(value bool)

func (Instance) SetIndentAutomatic

func (self Instance) SetIndentAutomatic(value bool)

func (Instance) SetIndentAutomaticPrefixes

func (self Instance) SetIndentAutomaticPrefixes(value []string)

func (Instance) SetIndentSize

func (self Instance) SetIndentSize(value int)

func (Instance) SetIndentUseSpaces

func (self Instance) SetIndentUseSpaces(value bool)

func (Instance) SetLineAsBookmarked

func (self Instance) SetLineAsBookmarked(line int, bookmarked bool)

Sets the line as bookmarked.

func (Instance) SetLineAsBreakpoint

func (self Instance) SetLineAsBreakpoint(line int, breakpointed bool)

Sets the line as breakpointed.

func (Instance) SetLineAsExecuting

func (self Instance) SetLineAsExecuting(line int, executing bool)

Sets the line as executing.

func (Instance) SetLineFolding

func (self Instance) SetLineFolding(value bool)

func (Instance) SetLineLengthGuidelines

func (self Instance) SetLineLengthGuidelines(value []int)

func (Instance) SetSymbolLookupOnClick

func (self Instance) SetSymbolLookupOnClick(value bool)

func (Instance) SetSymbolLookupWordAsValid

func (self Instance) SetSymbolLookupWordAsValid(valid bool)

Sets the symbol emitted by [signal symbol_validate] as a valid lookup.

func (Instance) SymbolLookupOnClick

func (self Instance) SymbolLookupOnClick() bool

func (Instance) ToggleFoldableLine

func (self Instance) ToggleFoldableLine(line int)

Toggle the folding of the code block at the given line.

func (Instance) ToggleFoldableLinesAtCarets

func (self Instance) ToggleFoldableLinesAtCarets()

Toggle the folding of the code block on all lines with a caret on them.

func (Instance) UnfoldAllLines

func (self Instance) UnfoldAllLines()

Unfolds all lines, folded or not.

func (Instance) UnfoldLine

func (self Instance) UnfoldLine(line int)

Unfolds all lines that were previously folded.

func (Instance) UnindentLines

func (self Instance) UnindentLines()

Unindents selected lines, or in the case of no selection the caret line by one. Same as performing "ui_text_unindent" action.

func (*Instance) UnsafePointer

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

func (Instance) UpdateCodeCompletionOptions

func (self Instance) UpdateCodeCompletionOptions(force bool)

Submits all completion options added with [method add_code_completion_option]. Will try to force the autocomplete menu to popup, if [param force] is [code]true[/code]. [b]Note:[/b] This will replace all current candidates.

func (Instance) Virtual

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

type Interface

type Interface interface {
	//Override this method to define how the selected entry should be inserted. If [param replace] is [code]true[/code], any existing text should be replaced.
	ConfirmCodeCompletion(replace bool)
	//Override this method to define what happens when the user requests code completion. If [param force] is [code]true[/code], any checks should be bypassed.
	RequestCodeCompletion(force bool)
	//Override this method to define what items in [param candidates] should be displayed.
	//Both [param candidates] and the return is a [Array] of [Dictionary], see [method get_code_completion_option] for [Dictionary] content.
	FilterCodeCompletionCandidates(candidates []map[any]any) []map[any]any
}

Jump to

Keyboard shortcuts

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