CaretBounds#
func (diff *CodeDiff) CaretBounds() (ui.Rect, bool)CaretBounds implements ui.TextPlacement.
API 文档由 Go 源码生成,内容为英文。
type CodeDiff struct {
Geometry ScrollAreaGeometry
// widthKey names the text lineWidth was measured for, so it is measured again only when
// the comparison, the edited text or the font size changes, not on every scroll.
}CodeDiff paints a line-aligned source comparison. Its right pane is an input surface whose editing state remains owned by the caller. Pointer placement and IME location use the same byte offsets as a Textarea.
CaretBounds#func (diff *CodeDiff) CaretBounds() (ui.Rect, bool)CaretBounds implements ui.TextPlacement.
Move#func (diff *CodeDiff) Move(value string, caret int, movement TextareaMovement) intMove maps a multiline movement key to a UTF-8 byte offset on the editable right source. The application remains responsible for applying the returned offset to its text.Editor.
OffsetAt#func (diff *CodeDiff) OffsetAt(point ui.Point) (int, bool)OffsetAt implements ui.TextPlacement.
Paint#func (diff *CodeDiff) Paint(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect, snapshot CodeDiffSnapshot) ui.RectPaint renders an aligned comparison inside bounds. Both columns share the vertical and horizontal offsets and the two scrollbars.
Pointer#func (diff *CodeDiff) Pointer(event ui.PointerEvent) ui.EventResultPointer handles the two scrollbar drags. Text selection and caret placement remain native through the hit region and TextPlacement.
RevealCaret#func (diff *CodeDiff) RevealCaret(value string, caret int)RevealCaret scrolls the shared viewport enough to keep caret visible after a caller applies a keyboard movement to its native text.Editor.
Scroll#func (diff *CodeDiff) Scroll(event ui.ScrollEvent) ui.EventResultScroll applies a wheel or touchpad scroll to both panes. Horizontal deltas use horizontal movement; Shift turns vertical delta into horizontal movement.
ScrollBy#func (diff *CodeDiff) ScrollBy(dx, dy float32)ScrollBy moves the shared viewport.
ScrollForKey#func (diff *CodeDiff) ScrollForKey(key ui.Key, extend bool) (ui.EventResult, bool)ScrollForKey applies keyboard scrolling to the shared viewport.
ScrollTo#func (diff *CodeDiff) ScrollTo(x, y float32)ScrollTo sets the shared viewport offsets.