本文へスキップ

Editor

シンタックスカラー、行番号、インデント、両軸スクロールに対応した保持型ネイティブコードエディターです。

既定では言語文法を含みません。Rust はリンク済み文法を登録でき、Go / TypeScript は LoadLanguagePack / loadLanguagePack で選択した Tree-sitter Wasm 文法とクエリをまとめた単一の移植可能なパックを読み込めます。

既定では見た目のスタイルを持ちません。文字と行番号の色は継承され、背景、枠線、角丸、余白、構文・差分の配色は追加されません。外観はアプリ側で明示的に指定します。

#インポート

go get github.com/egoist/quickgui/extensions/editor
import (
	"github.com/egoist/quickgui/extensions/editor"
	"github.com/egoist/quickgui/go/ui"
)

#使い方

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)},
	})
}

#シンタックスハイライト

Language は同梱の Tree-sitter 文法とハイライトクエリを選択します。クエリのキャプチャは SyntaxTheme を通して 8 種類の前景色だけの描画クラスへ変換されるため、色はテキスト寸法を変えません。ソースまたは言語が変わると上限付きドキュメントを再解析し、配色変更では保持済みキャプチャだけを再マッピングします。スクロール時に構文処理は行いません。解析は最大 2 MiB、32 KiB を超える単一行は通常色のまま、キャプチャ数にも上限があり、言語サーバーは不要です。

#API リファレンス

項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。

editor.Editor

ソースを見る
editor.Editor(props EditorProps) *ui.Element
StyleStyleBuilder—

Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.

StyleBuilder
ソースを見る
Childrenany—

Content mounted inside the component. Compound child callbacks run after the parent context exists.

any
ソースを見る
OnClickfunc(*native.Event)—

Called after QuickGUI resolves an activation, including supported keyboard activation.

func(*native.Event)
ソースを見る
OnMouseEnterfunc(*native.Event)—

Callback for mouse enter. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnMouseLeavefunc(*native.Event)—

Callback for mouse leave. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnInputfunc(*native.Event)—

Receives edits from the text control. Write the new text into the controlled value.

func(*native.Event)
ソースを見る
OnSubmitfunc(*native.Event)—

Called when the control submits its current value.

func(*native.Event)
ソースを見る
OnDismissfunc(*native.Event)—

Reports toast identifiers dismissed by the core.

func(*native.Event)
ソースを見る
OnPointerfunc(*native.Event)—

Callback for pointer. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnPresentationChangefunc(*native.Event)—

Callback for presentation change. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnSelectfunc(*native.Event)—

Reports the menu entry selected by the core.

func(*native.Event)
ソースを見る
OnKeyDownfunc(*native.Event)—

Callback for key down. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnKeyUpfunc(*native.Event)—

Callback for key up. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnMouseDownfunc(*native.Event)—

Callback for mouse down. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnMouseUpfunc(*native.Event)—

Callback for mouse up. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnMouseMovefunc(*native.Event)—

Callback for mouse move. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnDoubleClickfunc(*native.Event)—

Callback for double click. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnWheelfunc(*native.Event)—

Callback for wheel. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnContextMenufunc(*native.Event)—

Callback for context menu. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnPinchfunc(*native.Event)—

Callback for pinch. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnRotatefunc(*native.Event)—

Callback for rotate. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnSmartMagnifyfunc(*native.Event)—

Callback for smart magnify. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnPressurefunc(*native.Event)—

Callback for pressure. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnFocusfunc(*native.Event)—

Callback for focus. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnBlurfunc(*native.Event)—

Callback for blur. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnActionfunc(*native.Event)—

Callback for action. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnDragStartfunc(*native.Event)—

Callback for drag start. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnDragEndfunc(*native.Event)—

Callback for drag end. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnDropfunc(*native.Event)—

Callback for drop. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnFilesDroppedfunc(*native.Event)—

Callback for files dropped. The signature below lists the event payload.

func(*native.Event)
ソースを見る
OnComponentChangefunc(*native.Event)—

Receives the component change payload, including values for coordinated controls.

func(*native.Event)
ソースを見る
OnCommitfunc(*native.Event)—

Reports one explicit commit boundary and its final value details.

func(*native.Event)
ソースを見る
Disabledany—

Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.

any
ソースを見る
Valueany—

The current controlled value. Update application state from the change callback to accept a new value.

any
ソースを見る
Placeholderstring—

Hint displayed while the text value is empty.

string
ソースを見る
Multilinebool—

Allows multiple lines in the core text editor.

bool
ソースを見る
AriaLabelany—

Accessible name, especially for icon-only controls or controls without a visible label.

any
ソースを見る
Selectedany—

Exposes the selected state of this item.

any
ソースを見る
Groupany—

Names this element as a group for descendant interaction-state styling.

any
ソースを見る
FocusOnPointerany—

Whether a pointer press moves keyboard focus to the control.

any
ソースを見る
FocusableWhenDisabledany—

Allows a disabled button to remain keyboard focusable while activation stays disabled.

any
ソースを見る
HitSlopany—

Expands the pointer hit area without changing the visual bounds.

any
ソースを見る
HitSlopTopany—

Extra pointer hit area above the visual bounds.

any
ソースを見る
HitSlopRightany—

Extra pointer hit area to the right of the visual bounds.

any
ソースを見る
HitSlopBottomany—

Extra pointer hit area below the visual bounds.

any
ソースを見る
HitSlopLeftany—

Extra pointer hit area to the left of the visual bounds.

any
ソースを見る
Reffunc(*native.Node)—

Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.

func(*native.Node)
ソースを見る
Passwordany—

Conceals the entered text while preserving the editor’s value.

any
ソースを見る
EstimatedItemHeightany—

Initial logical row-height estimate used by virtualization.

any
ソースを見る
Overscanany—

Extra rows mounted before and after the visible range.

any
ソースを見る
OverscanPixelsany—

Extra logical distance mounted before and after the visible range.

any
ソースを見る
ItemHeightsany—

Exact row heights supplied without waiting for layout measurement.

any
ソースを見る
ListAlignmentstring—

Pins short list content to the top or bottom.

string
ソースを見る
FollowModestring—

Chooses ordinary scrolling or tail-following behavior.

string
ソースを見る
ObjectFitstring—

How image content fits its declared box.

string
ソースを見る
ShaderParametersany—

Up to sixteen numeric values packed into fixed shader parameter vectors.

any
ソースを見る
Invalidany—

Projects invalid state to the field and its parts.

any
ソースを見る
Roleany—

Accessibility role override. Prefer the component’s built-in semantics.

any
ソースを見る
TabIndexany—

Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.

any
ソースを見る
Overlayany—

Places this content in the overlay paint plane.

any
ソースを見る
FocusTrapany—

Keeps keyboard focus within the active modal surface.

any
ソースを見る
RestorePreviousFocusany—

Restores the previously focused element when the surface closes.

any
ソースを見る
AutoFocusany—

Requests initial keyboard focus when the element mounts.

any
ソースを見る
AriaModalany—

Exposes the modal state of the surface to accessibility.

any
ソースを見る
DismissOnEscapeany—

Allows Escape to dismiss the surface.

any
ソースを見る
DismissOnPointerOutsideany—

Allows a pointer press outside the surface to dismiss it.

any
ソースを見る
TooltipTextany—

Text displayed by the element’s tooltip.

any
ソースを見る
TooltipPlacementany—

Preferred side and alignment of the tooltip.

any
ソースを見る
TooltipDelayany—

Delay before the tooltip opens.

any
ソースを見る
TooltipGapany—

Space between the tooltip and its trigger.

any
ソースを見る
TooltipViewportMarginany—

Minimum space between the tooltip and the window edges.

any
ソースを見る
AnchorTargetany—

Identity of the element used to position the surface.

any
ソースを見る
AnchorPlacementany—

Preferred side and alignment relative to the anchor.

any
ソースを見る
AnchorGapany—

Space between the anchor and its surface, in logical pixels.

any
ソースを見る
ViewportMarginany—

Minimum space reserved around the surface within the viewport.

any
ソースを見る
Keymapany—

Keyboard bindings used by the editor.

any
ソースを見る
Draggableany—

Enables the element as a drag source.

any
ソースを見る
DropKindsany—

Kinds of drop payload this target accepts.

any
ソースを見る
Languageany—

Configures language for this part. The declared type and source define the accepted value.

any
ソースを見る
LineNumbersany—

Configures line numbers for this part. The declared type and source define the accepted value.

any
ソースを見る
TabSizeany—

Configures tab size for this part. The declared type and source define the accepted value.

any
ソースを見る
InsertSpacesany—

Inserts spaces instead of a tab character.

any
ソースを見る
AutoIndentany—

Configures auto indent for this part. The declared type and source define the accepted value.

any
ソースを見る
ReadOnlyany—

Preserves the current value while keeping the control available for focus and inspection.

any
ソースを見る
ContentPaddingContentPadding—

Configures content padding for this part. The declared type and source define the accepted value.

ContentPadding
ソースを見る
GutterPaddingGutterPadding—

Configures gutter padding for this part. The declared type and source define the accepted value.

GutterPadding
ソースを見る
GutterBackgroundany—

Overrides the line-number gutter background.

any
ソースを見る
GutterColorany—

Configures gutter color for this part. The declared type and source define the accepted value.

any
ソースを見る
ActiveLineBackgroundany—

Configures active line background for this part. The declared type and source define the accepted value.

any
ソースを見る
ActiveLineNumberColorany—

Configures active line number color for this part. The declared type and source define the accepted value.

any
ソースを見る
SyntaxThemeSyntaxTheme—

Configures syntax theme for this part. The declared type and source define the accepted value.

SyntaxTheme
ソースを見る
OnChangefunc(string)—

Callback for change. The signature below lists the event payload.

func(string)
ソースを見る