Editor
A retained native code editor with syntax coloring, line numbers, indentation, and both-axis scrolling.
No language grammars are included by default. Register a linked grammar in Rust, or load one portable pack of selected Tree-sitter Wasm grammars and queries using loadLanguagePack (TypeScript) / LoadLanguagePack (Go).
Unstyled by default: text and line-number colors inherit, and the component adds no background, border, rounding, padding, or syntax/diff palette. Supply application styles and explicit colors to opt into an appearance.
#Import
go get github.com/egoist/quickgui/extensions/editorimport (
"github.com/egoist/quickgui/extensions/editor"
"github.com/egoist/quickgui/go/ui"
)#Usage
func EditorExample() *ui.Element {
source, setSource := ui.CreateSignal("package main\n\nfunc main() {}\n")
return editor.Editor(editor.EditorProps{
Value: source,
Language: "go",
LineNumbers: true,
TabSize: 4,
OnChange: setSource,
Props: ui.Props{Style: ui.Style().Width("100%").Height(360)},
})
}#Syntax highlighting
Language selects a registered Tree-sitter grammar and highlight query. Query captures map through SyntaxTheme to eight foreground-only paint classes, so color never changes text metrics. Source or language changes reparse the bounded document; palette changes only remap retained captures, and scrolling does no syntax work. Parsing is limited to 2 MiB, individual lines over 32 KiB stay plain, and the capture count is capped. This does not require a language server.
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
editor.Editor
View sourceeditor.Editor(props EditorProps) *ui.ElementStyleStyleBuilder—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
StyleBuilderView sourceChildrenany—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
anyView sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnInputfunc(*native.Event)—
Receives edits from the text control. Write the new text into the controlled value.
func(*native.Event)View sourceOnSubmitfunc(*native.Event)—
OnDismissfunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnPresentationChangefunc(*native.Event)—
Callback for presentation change. The signature below lists the event payload.
func(*native.Event)View sourceOnSelectfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnMouseMovefunc(*native.Event)—
OnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnWheelfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPinchfunc(*native.Event)—
OnRotatefunc(*native.Event)—
OnSmartMagnifyfunc(*native.Event)—
Callback for smart magnify. The signature below lists the event payload.
func(*native.Event)View sourceOnPressurefunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
OnActionfunc(*native.Event)—
OnDragStartfunc(*native.Event)—
OnDragEndfunc(*native.Event)—
OnDropfunc(*native.Event)—
OnFilesDroppedfunc(*native.Event)—
Callback for files dropped. The signature below lists the event payload.
func(*native.Event)View sourceOnComponentChangefunc(*native.Event)—
Receives the component change payload, including values for coordinated controls.
func(*native.Event)View sourceOnCommitfunc(*native.Event)—
Disabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceValueany—
The current controlled value. Update application state from the change callback to accept a new value.
anyView sourcePlaceholderstring—
Multilinebool—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceSelectedany—
Groupany—
FocusOnPointerany—
FocusableWhenDisabledany—
Allows a disabled button to remain keyboard focusable while activation stays disabled.
anyView sourceHitSlopany—
HitSlopTopany—
HitSlopRightany—
HitSlopBottomany—
HitSlopLeftany—
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourcePasswordany—
EstimatedItemHeightany—
Overscanany—
OverscanPixelsany—
ItemHeightsany—
ListAlignmentstring—
FollowModestring—
ObjectFitstring—
ShaderParametersany—
Invalidany—
Roleany—
TabIndexany—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
anyView sourceOverlayany—
FocusTrapany—
RestorePreviousFocusany—
AutoFocusany—
AriaModalany—
DismissOnEscapeany—
DismissOnPointerOutsideany—
TooltipTextany—
TooltipPlacementany—
TooltipDelayany—
TooltipGapany—
TooltipViewportMarginany—
AnchorTargetany—
AnchorPlacementany—
AnchorGapany—
ViewportMarginany—
Keymapany—
Draggableany—
DropKindsany—
Languageany—
Configures language for this part. The declared type and source define the accepted value.
anyView sourceLineNumbersany—
Configures line numbers for this part. The declared type and source define the accepted value.
anyView sourceTabSizeany—
Configures tab size for this part. The declared type and source define the accepted value.
anyView sourceInsertSpacesany—
AutoIndentany—
Configures auto indent for this part. The declared type and source define the accepted value.
anyView sourceReadOnlyany—
Preserves the current value while keeping the control available for focus and inspection.
anyView sourceContentPaddingContentPadding—
Configures content padding for this part. The declared type and source define the accepted value.
ContentPaddingView sourceGutterPaddingGutterPadding—
Configures gutter padding for this part. The declared type and source define the accepted value.
GutterPaddingView sourceGutterBackgroundany—
GutterColorany—
Configures gutter color for this part. The declared type and source define the accepted value.
anyView sourceActiveLineBackgroundany—
Configures active line background for this part. The declared type and source define the accepted value.
anyView sourceActiveLineNumberColorany—
Configures active line number color for this part. The declared type and source define the accepted value.
anyView sourceSyntaxThemeSyntaxTheme—
Configures syntax theme for this part. The declared type and source define the accepted value.
SyntaxThemeView source