Class CodeEdit
- Namespace
- Forma
- Assembly
- Forma.dll
Godot-inspired code editor with indentation, brace completion and debugger-oriented gutters.
public sealed class CodeEdit : TextEdit, IAddChild<Control>, IAddChild, INotifyPropertyChanged, IDisposable
- Inheritance
-
CodeEdit
- Implements
- Inherited Members
Constructors
CodeEdit()
public CodeEdit()
Properties
AutoBraceCompletionEnabled
public bool AutoBraceCompletionEnabled { get; set; }
Property Value
AutoIndentEnabled
public bool AutoIndentEnabled { get; set; }
Property Value
AutoIndentPrefixes
public IReadOnlyList<string> AutoIndentPrefixes { get; }
Property Value
BookmarkColor
public Color BookmarkColor { get; set; }
Property Value
- Color
BreakpointColor
public Color BreakpointColor { get; set; }
Property Value
- Color
CodeCompletionEnabled
Enables Godot-style retained code-completion requests, candidate selection, and confirmation.
public bool CodeCompletionEnabled { get; set; }
Property Value
CodeCompletionMaxLines
public int CodeCompletionMaxLines { get; set; }
Property Value
CodeCompletionOptions
public IReadOnlyList<CodeCompletionOption> CodeCompletionOptions { get; }
Property Value
CodeCompletionPrefixes
public IReadOnlyList<string> CodeCompletionPrefixes { get; }
Property Value
CodeHint
Godot-style function/signature help text anchored at the active caret.
public string CodeHint { get; }
Property Value
CodeHintDrawBelow
Places the code hint below rather than above the caret when space permits.
public bool CodeHintDrawBelow { get; }
Property Value
DrawBookmarksGutter
public bool DrawBookmarksGutter { get; set; }
Property Value
DrawBreakpointsGutter
public bool DrawBreakpointsGutter { get; set; }
Property Value
DrawExecutingLinesGutter
public bool DrawExecutingLinesGutter { get; set; }
Property Value
DrawFoldGutter
Shows Godot's fold affordance beside the code line-number gutter.
public bool DrawFoldGutter { get; set; }
Property Value
DrawLineNumbers
public bool DrawLineNumbers { get; set; }
Property Value
DrawMinimap
public bool DrawMinimap { get; set; }
Property Value
ExecutingLineColor
public Color ExecutingLineColor { get; set; }
Property Value
- Color
IndentSize
public int IndentSize { get; set; }
Property Value
IndentText
public string IndentText { get; }
Property Value
IndentUsingSpaces
public bool IndentUsingSpaces { get; set; }
Property Value
IsCodeCompletionActive
public bool IsCodeCompletionActive { get; }
Property Value
LineCommentDelimiters
Configured one-line comment markers that can prefix Godot-style code-region tags.
public IReadOnlyList<string> LineCommentDelimiters { get; }
Property Value
LineFoldingEnabled
Enables indentation-based source-line folding without changing the underlying document text.
public bool LineFoldingEnabled { get; set; }
Property Value
LineLengthGuidelineColor
public Color LineLengthGuidelineColor { get; set; }
Property Value
- Color
LineLengthGuidelines
public IReadOnlyList<int> LineLengthGuidelines { get; }
Property Value
LineNumbersMinDigits
public int LineNumbersMinDigits { get; set; }
Property Value
LineNumbersZeroPadded
public bool LineNumbersZeroPadded { get; set; }
Property Value
SymbolLookupOnClickEnabled
public bool SymbolLookupOnClickEnabled { get; }
Property Value
SymbolLookupWord
Last host-validated Command/Ctrl-click symbol, or empty while no lookup is active.
public string SymbolLookupWord { get; }
Property Value
TextContentLeftInset
Extra horizontal space reserved by specialized text editors before their editable content.
protected override float TextContentLeftInset { get; }
Property Value
Methods
AddAutoBraceCompletionPair(string, string)
public void AddAutoBraceCompletionPair(string openKey, string closeKey)
Parameters
AddCodeCompletionOption(CodeCompletionKind, string, string, Color?, object, int, Texture2D)
public void AddCodeCompletionOption(CodeCompletionKind type, string displayText, string insertText, Color? textColor = null, object value = null, int location = 0, Texture2D icon = null)
Parameters
typeCodeCompletionKinddisplayTextstringinsertTextstringtextColorColor?valueobjectlocationinticonTexture2D
AddCommentDelimiter(string, string, bool)
Adds a comment delimiter. Line-only delimiters enable code-region tags; paired delimiters enable multiline comment folding.
public void AddCommentDelimiter(string startKey, string endKey = "", bool lineOnly = false)
Parameters
AddStringDelimiter(string, string, bool)
public void AddStringDelimiter(string startKey, string endKey, bool lineOnly = false)
Parameters
CanFoldLine(int)
Returns whether this non-empty line introduces an indented child block that can be folded.
public bool CanFoldLine(int line)
Parameters
lineint
Returns
CancelCodeCompletion()
public void CancelCodeCompletion()
ClearBookmarkedLines()
public void ClearBookmarkedLines()
ClearBreakpointedLines()
public void ClearBreakpointedLines()
ClearCommentDelimiters()
public void ClearCommentDelimiters()
ClearExecutingLines()
public void ClearExecutingLines()
ClearStringDelimiters()
public void ClearStringDelimiters()
ConfirmCodeCompletion(bool)
public void ConfirmCodeCompletion(bool replace = false)
Parameters
replacebool
CreateCodeRegion()
Wraps the selected line range in configured code-region tags and folds the new region.
public void CreateCodeRegion()
DeleteLines()
Deletes the selected lines, or the caret line, retaining a single empty line for an otherwise empty document.
public void DeleteLines()
DuplicateLines()
Duplicates the selected lines, or the caret line, immediately below the original range.
public void DuplicateLines()
DuplicateSelection()
Duplicates the selected text, or delegates to DuplicateLines() when no range is selected.
public void DuplicateSelection()
FoldAllLines()
public void FoldAllLines()
FoldLine(int)
Hides the contiguous indented block below line, matching Godot's source folding model.
public void FoldLine(int line)
Parameters
lineint
GetAutoBraceCompletionCloseKey(string)
public string GetAutoBraceCompletionCloseKey(string openKey)
Parameters
openKeystring
Returns
GetBookmarkedLines()
public IReadOnlyList<int> GetBookmarkedLines()
Returns
GetBreakpointedLines()
public IReadOnlyList<int> GetBreakpointedLines()
Returns
GetCodeCompletionOption(int)
public CodeCompletionOption GetCodeCompletionOption(int index)
Parameters
indexint
Returns
GetCodeCompletionSelectedIndex()
public int GetCodeCompletionSelectedIndex()
Returns
GetCodeHintBounds()
Returns the current caret-relative retained code-hint panel bounds, or an empty rectangle without a hint.
public Rectangle GetCodeHintBounds()
Returns
- Rectangle
GetCodeRegionEndTag()
public string GetCodeRegionEndTag()
Returns
GetCodeRegionStartTag()
public string GetCodeRegionStartTag()
Returns
GetExecutingLines()
public IReadOnlyList<int> GetExecutingLines()
Returns
GetFoldedLineHeader(int)
public int GetFoldedLineHeader(int line)
Parameters
lineint
Returns
GetFoldedLines()
public IReadOnlyList<int> GetFoldedLines()
Returns
GetLineLengthGuidelineX(int)
Returns the screen-space x coordinate for a configured guideline column.
public int GetLineLengthGuidelineX(int column)
Parameters
columnint
Returns
GetLineLengthGuidelines()
public IReadOnlyList<int> GetLineLengthGuidelines()
Returns
GetLookupWord(int, int)
public string GetLookupWord(int line, int column)
Parameters
Returns
GetMinimapBounds()
Returns the retained minimap lane, or an empty rectangle while minimap drawing is disabled.
public Rectangle GetMinimapBounds()
Returns
- Rectangle
GetMinimapViewportBounds()
Returns the minimap rectangle representing the current wrap-aware code viewport.
public Rectangle GetMinimapViewportBounds()
Returns
- Rectangle
GetTextForCodeCompletion()
Returns the complete text with U+FFFF at the active caret, matching Godot's completion-provider contract.
public string GetTextForCodeCompletion()
Returns
GetTextForSymbolLookup()
Returns complete source text with U+FFFF at the last pointer position used for symbol lookup, or the caret when there is none.
public string GetTextForSymbolLookup()
Returns
GetTextWithCursorChar(int, int)
public string GetTextWithCursorChar(int line, int column)
Parameters
Returns
HasAutoBraceCompletionCloseKey(string)
public bool HasAutoBraceCompletionCloseKey(string closeKey)
Parameters
closeKeystring
Returns
HasAutoBraceCompletionOpenKey(string)
public bool HasAutoBraceCompletionOpenKey(string openKey)
Parameters
openKeystring
Returns
HasCommentDelimiter(string)
public bool HasCommentDelimiter(string startKey)
Parameters
startKeystring
Returns
HasStringDelimiter(string)
public bool HasStringDelimiter(string startKey)
Parameters
startKeystring
Returns
IndentLines()
Indents the current selection, or the caret line when no selection exists.
public void IndentLines()
InsertCodeText(string)
public void InsertCodeText(string text)
Parameters
textstring
InsertText(string)
Routes normal window text input through CodeEdit's brace and indentation behavior.
public override void InsertText(string text)
Parameters
textstring
IsCodeCompletionEnabled()
public bool IsCodeCompletionEnabled()
Returns
IsDrawingFoldGutter()
public bool IsDrawingFoldGutter()
Returns
IsLineBookmarked(int)
public bool IsLineBookmarked(int line)
Parameters
lineint
Returns
IsLineBreakpointed(int)
public bool IsLineBreakpointed(int line)
Parameters
lineint
Returns
IsLineCodeRegionEnd(int)
public bool IsLineCodeRegionEnd(int line)
Parameters
lineint
Returns
IsLineCodeRegionStart(int)
public bool IsLineCodeRegionStart(int line)
Parameters
lineint
Returns
IsLineExecuting(int)
public bool IsLineExecuting(int line)
Parameters
lineint
Returns
IsLineFolded(int)
public bool IsLineFolded(int line)
Parameters
lineint
Returns
IsLineFoldingEnabled()
public bool IsLineFoldingEnabled()
Returns
IsLineHiddenForDisplay(int)
Allows specialized editors to hide document lines without mutating the underlying text.
protected override bool IsLineHiddenForDisplay(int line)
Parameters
lineint
Returns
IsSymbolLookupOnClickEnabled()
public bool IsSymbolLookupOnClickEnabled()
Returns
JoinLines(string)
Joins the selected line range, or the caret line and its next line, using lineEnding.
public void JoinLines(string lineEnding = " ")
Parameters
lineEndingstring
MoveLinesDown()
Moves the selected lines, or the caret line, one logical row downward without changing their contents.
public void MoveLinesDown()
MoveLinesUp()
Moves the selected lines, or the caret line, one logical row upward without changing their contents.
public void MoveLinesUp()
RemoveCommentDelimiter(string)
public void RemoveCommentDelimiter(string startKey)
Parameters
startKeystring
RemoveStringDelimiter(string)
public void RemoveStringDelimiter(string startKey)
Parameters
startKeystring
RequestCodeCompletion(bool)
public void RequestCodeCompletion(bool force = false)
Parameters
forcebool
SetAutoIndentPrefixes(IEnumerable<string>)
public void SetAutoIndentPrefixes(IEnumerable<string> prefixes)
Parameters
prefixesIEnumerable<string>
SetCodeCompletionEnabled(bool)
public void SetCodeCompletionEnabled(bool enabled)
Parameters
enabledbool
SetCodeCompletionPrefixes(IEnumerable<string>)
public void SetCodeCompletionPrefixes(IEnumerable<string> prefixes)
Parameters
prefixesIEnumerable<string>
SetCodeCompletionSelectedIndex(int)
public void SetCodeCompletionSelectedIndex(int index)
Parameters
indexint
SetCodeHint(string)
public void SetCodeHint(string hint)
Parameters
hintstring
SetCodeHintDrawBelow(bool)
public void SetCodeHintDrawBelow(bool below)
Parameters
belowbool
SetCodeRegionTags(string, string)
public void SetCodeRegionTags(string start = "region", string end = "endregion")
Parameters
SetDrawFoldGutter(bool)
public void SetDrawFoldGutter(bool draw)
Parameters
drawbool
SetLineAsBookmarked(int, bool)
public void SetLineAsBookmarked(int line, bool bookmarked)
Parameters
SetLineAsBreakpoint(int, bool)
public void SetLineAsBreakpoint(int line, bool breakpointed)
Parameters
SetLineAsExecuting(int, bool)
public void SetLineAsExecuting(int line, bool executing)
Parameters
SetLineFoldingEnabled(bool)
public void SetLineFoldingEnabled(bool enabled)
Parameters
enabledbool
SetLineLengthGuidelines(IEnumerable<int>)
public void SetLineLengthGuidelines(IEnumerable<int> guidelineColumns)
Parameters
guidelineColumnsIEnumerable<int>
SetSymbolLookupOnClickEnabled(bool)
public void SetSymbolLookupOnClickEnabled(bool enabled)
Parameters
enabledbool
SetSymbolLookupWordAsValid(bool)
Accepts or rejects the pending Command/Ctrl-click lookup word after the host resolves it.
public void SetSymbolLookupWordAsValid(bool valid)
Parameters
validbool
ToggleFoldableLine(int)
public void ToggleFoldableLine(int line)
Parameters
lineint
ToggleFoldableLinesAtCarets()
public void ToggleFoldableLinesAtCarets()
UnfoldAllLines()
public void UnfoldAllLines()
UnfoldLine(int)
Reveals a folded header, or the header that contains the requested hidden line.
public void UnfoldLine(int line)
Parameters
lineint
UnindentLines()
Removes one configured indentation level from the current selection or caret line.
public void UnindentLines()
UpdateCodeCompletionOptions(bool)
public void UpdateCodeCompletionOptions(bool forced = false)
Parameters
forcedbool
Events
CodeCompletionRequested
Raised synchronously when the host should submit candidates through AddCodeCompletionOption(CodeCompletionKind, string, string, Color?, object, int, Texture2D).
public event Action<CodeEdit, bool> CodeCompletionRequested
Event Type
FoldStateChanged
Raised after an indentation-based fold or unfold changes visible code lines.
public event Action<CodeEdit> FoldStateChanged
Event Type
LineChanged
public event Action<CodeEdit, int> LineChanged
Event Type
SymbolLookupRequested
Raised for a Command/Ctrl-click word when SymbolLookupOnClickEnabled is enabled.
public event Action<CodeEdit, string, int, int> SymbolLookupRequested