DiffView
行を同期しつつ各ペインを個別に横スクロールできる、仮想化された分割/統合ファイル差分ビューです。
既定では言語文法を含みません。Rust はリンク済み文法を登録でき、Go / TypeScript は LoadLanguagePack / loadLanguagePack で選択した Tree-sitter Wasm 文法とクエリをまとめた単一の移植可能なパックを読み込めます。
既定では見た目のスタイルを持ちません。文字と行番号の色は継承され、背景、枠線、角丸、余白、構文・差分の配色は追加されません。外観はアプリ側で明示的に指定します。
#インポート
go get github.com/egoist/quickgui/extensions/editorimport (
"github.com/egoist/quickgui/extensions/editor"
"github.com/egoist/quickgui/go/ui"
)#使い方
func DiffViewExample() *ui.Element {
return editor.DiffView(editor.DiffViewProps{
OldPath: "before.go",
NewPath: "after.go",
OldText: "func answer() int { return 41 }\n",
NewText: "func answer() int { return 42 }\n",
Options: editor.DiffOptions{
Layout: editor.DiffSplit,
Indicators: editor.DiffBars,
LineNumbers: true,
Language: "go",
},
Props: ui.Props{Style: ui.Style().Width("100%").Height(420)},
})
}#シンタックスハイライト
DiffView は Editor と同じ同梱 Tree-sitter 文法を使います。ドキュメント、言語、構文配色が変わると、Rust コアは表示対象となる各ファイルの新旧行シーケンスを一度ずつ解析し、キャプチャ断片を論理行へ割り当てます。スタイル付きテキストは行のマウント時にだけ生成してキャッシュし、重ならないバイト境界で行内の追加/削除強調を統合します。スクロール時にパーサーは動きません。
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
editor.DiffView
ソースを見るeditor.DiffView(props DiffViewProps) *ui.ElementStyleStyleBuilder—
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)—
OnMouseLeavefunc(*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)—
OnDismissfunc(*native.Event)—
OnPointerfunc(*native.Event)—
OnPresentationChangefunc(*native.Event)—
Callback for presentation change. The signature below lists the event payload.
func(*native.Event)ソースを見るOnSelectfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnMouseMovefunc(*native.Event)—
OnDoubleClickfunc(*native.Event)—
OnWheelfunc(*native.Event)—
OnContextMenufunc(*native.Event)—
OnPinchfunc(*native.Event)—
OnRotatefunc(*native.Event)—
OnSmartMagnifyfunc(*native.Event)—
OnPressurefunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
OnActionfunc(*native.Event)—
OnDragStartfunc(*native.Event)—
OnDragEndfunc(*native.Event)—
OnDropfunc(*native.Event)—
OnFilesDroppedfunc(*native.Event)—
OnComponentChangefunc(*native.Event)—
Receives the component change payload, including values for coordinated controls.
func(*native.Event)ソースを見るOnCommitfunc(*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—
Multilinebool—
AriaLabelany—
Selectedany—
Groupany—
FocusOnPointerany—
FocusableWhenDisabledany—
HitSlopany—
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)ソースを見るPasswordany—
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.
anyソースを見るOverlayany—
FocusTrapany—
RestorePreviousFocusany—
AutoFocusany—
AriaModalany—
DismissOnEscapeany—
DismissOnPointerOutsideany—
TooltipTextany—
TooltipPlacementany—
TooltipDelayany—
TooltipGapany—
TooltipViewportMarginany—
AnchorTargetany—
AnchorPlacementany—
AnchorGapany—
ViewportMarginany—
Keymapany—
Draggableany—
DropKindsany—
Patchany—
OldTextany—
NewTextany—
OldPathany—
NewPathany—
OptionsDiffOptions—
PresentationDiffPresentation—
Configures presentation for this part. The declared type and source define the accepted value.
DiffPresentationソースを見るThemeDiffTheme—
Configures theme for this part. The declared type and source define the accepted value.
DiffThemeソースを見るSyntaxThemeSyntaxTheme—
Configures syntax theme for this part. The declared type and source define the accepted value.
SyntaxThemeソースを見る