Documentation
¶
Overview ¶
Package edit owns headless, grapheme-safe text state. Offsets are UTF-8 bytes; caret movement is logical, not visual. Rendering may project these offsets onto bidi runs to paint discontiguous selection rectangles.
Index ¶
- Constants
- func Boundaries(s string) []int
- type AsyncClipboard
- type Clipboard
- type IME
- type IMEBatch
- type State
- func (s *State) Blur(ime IME)
- func (s *State) Copy(c Clipboard, password bool) error
- func (s *State) Cut(c Clipboard, password bool) (bool, error)
- func (s *State) Delete(backward bool, word bool) bool
- func (s *State) Done(b IMEBatch) bool
- func (s *State) Focus(ime IME, password, multiline bool)
- func (s *State) IMEActive() bool
- func (s *State) Insert(text string) bool
- func (s *State) Left(shift bool)
- func (s *State) Mask() string
- func (s *State) Move(to int, shift bool)
- func (s *State) Paste(c Clipboard) (bool, error)
- func (s *State) PasteAsync(data []byte, err error) (bool, error)
- func (s *State) Range() (int, int)
- func (s *State) Right(shift bool)
- func (s *State) Select(start, end int)
- func (s *State) Surround(ime IME, password bool)
- func (s *State) Sync(value string)
- func (s *State) WordAt(offset int) (int, int)
- func (s *State) WordLeft() int
- func (s *State) WordRight() int
Constants ¶
const MaxClipboardBytes = 1 << 20
Variables ¶
This section is empty.
Functions ¶
func Boundaries ¶
Types ¶
type AsyncClipboard ¶
type AsyncClipboard interface {
ReadTextAsync(ctx context.Context, limit int, deliver func([]byte, error)) error
WriteText([]byte) error
}
AsyncClipboard starts an asynchronous paste. The callback must be delivered to the UI loop, never invoked by a Wayland reader or transport goroutine. Unlike Clipboard.ReadText, ReadTextAsync does not wait for another process. Implementations must cap reads at limit bytes plus one and honor cancellation.
type Clipboard ¶
Clipboard is a bounded text/plain;charset=utf-8 port. Implementations own transport, cancellation and file descriptors; the editor never retains one.
type IME ¶
type IME interface {
Enable()
Disable()
Surrounding(text string, cursor, anchor int)
CursorRect(x, y, w, h float64)
ContentType(password, multiline bool)
}
IME is a text-input-v3-shaped output port. All offsets are UTF-8 bytes.
type IMEBatch ¶
IMEBatch is applied atomically on text-input-v3 done. Delete offsets are relative to the cursor in bytes, and rounded outwards to grapheme edges.
type State ¶
type State struct {
Value string
Cursor, Anchor int
PreferredX float64
PreferredXValid bool // retained across successive wrapped-line moves
Preedit string
PreeditBegin, PreeditEnd int
// contains filtered or unexported fields
}
func (*State) PasteAsync ¶
PasteAsync applies a completed paste on the UI loop. It is the counterpart of Paste for asynchronous transports. It retains the same UTF-8/size checks.