DiffView
A virtualized split or unified file diff with synchronized rows and independent pane 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 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)},
})
}#Syntax highlighting
DiffView uses the same registered Tree-sitter grammars as Editor. When its document, language, or syntax palette changes, the Rust core parses each visible old/new file lane once and assigns capture fragments to logical rows. Styled text is materialized and cached only when a row is mounted, with inline addition/deletion emphasis merged at non-overlapping byte boundaries. Scrolling never invokes the parser.
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
editor.DiffView
View sourceeditor.DiffView(props DiffViewProps) *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—
Patchany—
Configures patch for this part. The declared type and source define the accepted value.
anyView sourceOldTextany—
Configures old text for this part. The declared type and source define the accepted value.
anyView sourceNewTextany—
Configures new text for this part. The declared type and source define the accepted value.
anyView sourceOldPathany—
Configures old path for this part. The declared type and source define the accepted value.
anyView sourceNewPathany—
Configures new path for this part. The declared type and source define the accepted value.
anyView sourceOptionsDiffOptions—
PresentationDiffPresentation—
Configures presentation for this part. The declared type and source define the accepted value.
DiffPresentationView sourceThemeDiffTheme—
Configures theme for this part. The declared type and source define the accepted value.
DiffThemeView sourceSyntaxThemeSyntaxTheme—
Configures syntax theme for this part. The declared type and source define the accepted value.
SyntaxThemeView source