跳到正文

DiffView

虚拟化的分栏或统一文件差异视图,行同步且面板可独立横向滚动。

默认不包含任何语言语法。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 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.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
查看源码
Patchany—

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

any
查看源码
OldTextany—

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

any
查看源码
NewTextany—

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

any
查看源码
OldPathany—

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

any
查看源码
NewPathany—

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

any
查看源码
OptionsDiffOptions—

Ordered native picker options.

DiffOptions
查看源码
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
查看源码