Documentation
¶
Index ¶
- Constants
- func ApplyTextEditsInRange(value string, selectionStart, selectionEnd, maxRunes int, multiline bool, ...) (string, int, int)
- type Cursor
- type Dispatch
- type Event
- type EventKind
- type KeyCode
- type Modifiers
- type MouseButton
- type Phase
- type Pointer
- type PointerDevice
- type State
- func (s *State) AppendTextEdits(dst []TextEdit) []TextEdit
- func (s *State) ApplyEvent(event Event)
- func (s *State) ApplyTextComposition(event TextComposition)
- func (s *State) ApplyTextEditsInRange(value string, selectionStart, selectionEnd, maxRunes int, multiline bool, ...) (string, int, int)
- func (s *State) ApplyTextSelection(selection TextSelection)
- func (s *State) BlurTextInput()
- func (s *State) ClipboardText() (string, bool)
- func (s *State) CommitText(text string)
- func (s *State) Composing() bool
- func (s *State) CompositionHandledKey() bool
- func (s *State) CompositionText() string
- func (s *State) ConsumeEvent(sequence uint64)
- func (s *State) ConsumePointerWheel()
- func (s *State) CopyFrom(source *State)
- func (s *State) Cursor() Cursor
- func (s *State) DrainEvents() []Event
- func (s *State) EndFrame()
- func (s *State) Enqueue(event Event)
- func (s *State) EventConsumed(sequence uint64) bool
- func (s *State) FocusTextInput(kind TextInputKind, multiline bool, initialValue string)
- func (s *State) HasPendingEvents() bool
- func (s *State) KeyHeld(key KeyCode) bool
- func (s *State) KeyModifiers(key KeyCode) Modifiers
- func (s *State) KeyPressed(key KeyCode) bool
- func (s *State) KeyPressedDuringComposition(key KeyCode) bool
- func (s *State) KeyReleased(key KeyCode) bool
- func (s *State) MouseHeld(button MouseButton) bool
- func (s *State) MousePressed(button MouseButton) bool
- func (s *State) MouseReleased(button MouseButton) bool
- func (s *State) MoveMouse(x, y float64)
- func (s *State) Pointer() Pointer
- func (s *State) PointerHeld() bool
- func (s *State) PointerPressed() bool
- func (s *State) PointerReleased() bool
- func (s *State) PressKey(key KeyCode)
- func (s *State) PressMouse(button MouseButton, x, y float64)
- func (s *State) PushTextCommand(command TextCommand)
- func (s *State) ReleaseKey(key KeyCode)
- func (s *State) ReleaseMouse(button MouseButton, x, y float64)
- func (s *State) ScrollMouse(xoff, yoff float64)
- func (s *State) SetClipboard(write func(string) bool, read func() (string, bool))
- func (s *State) SetClipboardText(text string) bool
- func (s *State) SetCursor(cursor Cursor)
- func (s *State) SetTextInputCaret(caret TextInputRect)
- func (s *State) SetTextInputSelection(start, end int)
- func (s *State) TextEdits() []TextEdit
- func (s *State) TextInputConfig() TextInputConfig
- func (s *State) TextSelection() (TextSelection, bool)
- func (s *State) TouchEnd(x, y float64)
- func (s *State) TouchMove(x, y float64)
- func (s *State) TouchStart(x, y float64)
- type TextBuffer
- func (b *TextBuffer) ApplyEdits(value piecetree.Snapshot, start, end, maxRunes int, multiline bool, ...) (piecetree.Snapshot, int, int)
- func (b *TextBuffer) ApplySnapshot(value string, start, oldEnd, newEnd int)
- func (b *TextBuffer) ApplyTextEditsInRange(value string, start, end, maxRunes int, multiline bool, edits []TextEdit) (string, int, int)
- func (b *TextBuffer) ChangedRange(before, after string) (start, oldEnd, newEnd, prefixRunes int, ok bool)
- func (b *TextBuffer) Matches(value string) bool
- func (b *TextBuffer) MatchesSnapshot(value piecetree.Snapshot) bool
- func (b *TextBuffer) ReplaceBytes(start, end int, text string)
- func (b *TextBuffer) Snapshot() piecetree.Snapshot
- func (b *TextBuffer) SnapshotChangedRange(before, after piecetree.Snapshot) (start, oldEnd, newEnd, prefixRunes int, ok bool)
- func (b *TextBuffer) String() string
- func (b *TextBuffer) Sync(value string)
- func (b *TextBuffer) SyncSnapshot(value piecetree.Snapshot)
- type TextCommand
- type TextComposition
- type TextEdit
- type TextInputConfig
- type TextInputKind
- type TextInputRect
- type TextSelection
Constants ¶
const ( KeySpace = KeyCode(32) KeyApostrophe = KeyCode(39) KeyComma = KeyCode(44) KeyMinus = KeyCode(45) KeyPeriod = KeyCode(46) KeySlash = KeyCode(47) KeyNum0 = KeyCode(48) KeyNum1 = KeyCode(49) KeyNum2 = KeyCode(50) KeyNum3 = KeyCode(51) KeyNum4 = KeyCode(52) KeyNum5 = KeyCode(53) KeyNum6 = KeyCode(54) KeyNum7 = KeyCode(55) KeyNum8 = KeyCode(56) KeyNum9 = KeyCode(57) KeySemicolon = KeyCode(59) KeyEqual = KeyCode(61) KeyA = KeyCode(65) KeyB = KeyCode(66) KeyC = KeyCode(67) KeyD = KeyCode(68) KeyE = KeyCode(69) KeyF = KeyCode(70) KeyG = KeyCode(71) KeyH = KeyCode(72) KeyI = KeyCode(73) KeyJ = KeyCode(74) KeyK = KeyCode(75) KeyL = KeyCode(76) KeyM = KeyCode(77) KeyN = KeyCode(78) KeyO = KeyCode(79) KeyP = KeyCode(80) KeyQ = KeyCode(81) KeyR = KeyCode(82) KeyS = KeyCode(83) KeyT = KeyCode(84) KeyU = KeyCode(85) KeyV = KeyCode(86) KeyW = KeyCode(87) KeyX = KeyCode(88) KeyY = KeyCode(89) KeyZ = KeyCode(90) KeyLeftBracket = KeyCode(91) KeyBackslash = KeyCode(92) KeyRightBracket = KeyCode(93) KeyGraveAccent = KeyCode(96) KeyWorld1 = KeyCode(161) KeyWorld2 = KeyCode(162) KeyEscape = KeyCode(256) KeyEnter = KeyCode(257) KeyTab = KeyCode(258) KeyBackspace = KeyCode(259) KeyInsert = KeyCode(260) KeyDelete = KeyCode(261) KeyRight = KeyCode(262) KeyLeft = KeyCode(263) KeyDown = KeyCode(264) KeyUp = KeyCode(265) KeyPageUp = KeyCode(266) KeyPageDown = KeyCode(267) KeyHome = KeyCode(268) KeyEnd = KeyCode(269) KeyCapsLock = KeyCode(280) KeyScrollLock = KeyCode(281) KeyNumLock = KeyCode(282) KeyPrintScreen = KeyCode(283) KeyPause = KeyCode(284) KeyF1 = KeyCode(290) KeyF2 = KeyCode(291) KeyF3 = KeyCode(292) KeyF4 = KeyCode(293) KeyF5 = KeyCode(294) KeyF6 = KeyCode(295) KeyF7 = KeyCode(296) KeyF8 = KeyCode(297) KeyF9 = KeyCode(298) KeyF10 = KeyCode(299) KeyF11 = KeyCode(300) KeyF12 = KeyCode(301) KeyF13 = KeyCode(302) KeyF14 = KeyCode(303) KeyF15 = KeyCode(304) KeyF16 = KeyCode(305) KeyF17 = KeyCode(306) KeyF18 = KeyCode(307) KeyF19 = KeyCode(308) KeyF20 = KeyCode(309) KeyF21 = KeyCode(310) KeyF22 = KeyCode(311) KeyF23 = KeyCode(312) KeyF24 = KeyCode(313) KeyF25 = KeyCode(314) KeyKP0 = KeyCode(320) KeyKP1 = KeyCode(321) KeyKP2 = KeyCode(322) KeyKP3 = KeyCode(323) KeyKP4 = KeyCode(324) KeyKP5 = KeyCode(325) KeyKP6 = KeyCode(326) KeyKP7 = KeyCode(327) KeyKP8 = KeyCode(328) KeyKP9 = KeyCode(329) KeyKPDecimal = KeyCode(330) KeyKPDivide = KeyCode(331) KeyKPMultiply = KeyCode(332) KeyKPSubtract = KeyCode(333) KeyKPAdd = KeyCode(334) KeyKPEnter = KeyCode(335) KeyKPEqual = KeyCode(336) KeyLeftShift = KeyCode(340) KeyLeftControl = KeyCode(341) KeyLeftAlt = KeyCode(342) KeyLeftSuper = KeyCode(343) KeyRightShift = KeyCode(344) KeyRightControl = KeyCode(345) KeyRightAlt = KeyCode(346) KeyRightSuper = KeyCode(347) KeyMenu = KeyCode(348) )
const ( MouseNone = MouseButton(-1) MouseLeft = MouseButton(0) MouseRight = MouseButton(1) MouseMiddle = MouseButton(2) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cursor ¶ added in v0.1.4
type Cursor uint8
Cursor is the system pointer shape, independent of keyboard focus.
const ( CursorDefault Cursor = iota CursorText CursorPointer CursorCrosshair CursorMove CursorEWResize CursorNSResize CursorNESWResize CursorNWSEResize CursorGrab CursorGrabbing CursorNotAllowed CursorWait CursorProgress CursorHelp CursorNone CursorVerticalText CursorAllScroll CursorContextMenu CursorCell CursorCopy CursorAlias CursorZoomIn CursorZoomOut )
func ParseCursor ¶ added in v0.1.4
ParseCursor resolves CSS cursor keywords to native pointer shapes.
type Event ¶
type Event struct {
// File is set for EventFilesDropped. One event is emitted per dropped file.
File string
Text string
Composition TextComposition
Selection TextSelection
WheelY float64
Y float64
DeltaX float64
DeltaY float64
WheelX float64
Seq uint64
X float64
Key KeyCode
Button MouseButton
Command TextCommand
Kind EventKind
}
Event is the normalized, ordered input stream produced by a window.
The platform boundary uses a tagged value so keyboard, pointer, and text events retain their relative order. Gameplay and UI events should continue to use typed ECS messages.
type EventKind ¶
type EventKind uint8
EventKind identifies one normalized platform input event.
const ( EventKeyDown EventKind = iota + 1 EventKeyUp EventTextInput EventTextComposition EventTextCommand EventTextSelection EventMouseDown EventMouseUp EventMouseMove EventMouseWheel EventTouchStart EventTouchMove EventTouchEnd // EventFilesDropped reports one file dropped onto the window. EventFilesDropped )
type KeyCode ¶
type KeyCode int
KeyCode is the canonical desktop key space used inside Onix. Native Windows/Linux key events are normalized to these values by each window backend.
type MouseButton ¶
type MouseButton int8
type PointerDevice ¶
type PointerDevice uint8
const ( PointerDeviceNone PointerDevice = iota PointerDeviceMouse PointerDeviceTouch )
type State ¶
type State struct {
// contains filtered or unexported fields
}
func (*State) AppendTextEdits ¶
AppendTextEdits appends this frame's effective text edits to dst.
func (*State) ApplyEvent ¶
ApplyEvent derives the queryable input state from one normalized event.
func (*State) ApplyTextComposition ¶
func (s *State) ApplyTextComposition(event TextComposition)
func (*State) ApplyTextEditsInRange ¶
func (s *State) ApplyTextEditsInRange(value string, selectionStart, selectionEnd, maxRunes int, multiline bool, edits []TextEdit) (string, int, int)
ApplyTextEditsInRange applies edits through the State's reusable piece tree. Keeping the buffer on the active input session avoids rebuilding a rune slice for every key press.
func (*State) ApplyTextSelection ¶
func (s *State) ApplyTextSelection(selection TextSelection)
func (*State) BlurTextInput ¶
func (s *State) BlurTextInput()
func (*State) ClipboardText ¶
func (*State) CommitText ¶
func (*State) CompositionHandledKey ¶
func (*State) CompositionText ¶
func (*State) ConsumeEvent ¶
ConsumeEvent prevents later input stages from handling the same event.
func (*State) ConsumePointerWheel ¶
func (s *State) ConsumePointerWheel()
func (*State) CopyFrom ¶
CopyFrom reuses storage for an isolated snapshot of keyboard and pointer state.
func (*State) DrainEvents ¶
DrainEvents returns events in platform arrival order. The returned slice is owned by the caller until the next Enqueue call.
func (*State) EventConsumed ¶
func (*State) FocusTextInput ¶
func (s *State) FocusTextInput(kind TextInputKind, multiline bool, initialValue string)
func (*State) HasPendingEvents ¶
func (*State) KeyModifiers ¶
KeyModifiers returns the modifiers held when key was pressed this frame. Later modifier presses or releases do not change the recorded chord.
func (*State) KeyPressed ¶
func (*State) KeyPressedDuringComposition ¶
func (*State) KeyReleased ¶
func (*State) MouseHeld ¶
func (s *State) MouseHeld(button MouseButton) bool
func (*State) MousePressed ¶
func (s *State) MousePressed(button MouseButton) bool
func (*State) MouseReleased ¶
func (s *State) MouseReleased(button MouseButton) bool
func (*State) PointerHeld ¶
func (*State) PointerPressed ¶
func (*State) PointerReleased ¶
func (*State) PressMouse ¶
func (s *State) PressMouse(button MouseButton, x, y float64)
func (*State) PushTextCommand ¶
func (s *State) PushTextCommand(command TextCommand)
func (*State) ReleaseKey ¶
func (*State) ReleaseMouse ¶
func (s *State) ReleaseMouse(button MouseButton, x, y float64)
func (*State) ScrollMouse ¶
func (*State) SetClipboard ¶
func (*State) SetClipboardText ¶
func (*State) SetCursor ¶ added in v0.1.4
SetCursor selects the pointer shape for the current UI hit.
func (*State) SetTextInputCaret ¶
func (s *State) SetTextInputCaret(caret TextInputRect)
func (*State) SetTextInputSelection ¶
func (*State) TextInputConfig ¶
func (s *State) TextInputConfig() TextInputConfig
func (*State) TextSelection ¶
func (s *State) TextSelection() (TextSelection, bool)
func (*State) TouchStart ¶
type TextBuffer ¶
TextBuffer owns a document's piece tree and reusable input scratch space. Keep one per editor document; String snapshots are immutable. Do not copy it.
func (*TextBuffer) ApplyEdits ¶
func (b *TextBuffer) ApplyEdits(value piecetree.Snapshot, start, end, maxRunes int, multiline bool, edits []TextEdit) (piecetree.Snapshot, int, int)
ApplyEdits publishes immutable pieces without materializing the document.
func (*TextBuffer) ApplySnapshot ¶
func (b *TextBuffer) ApplySnapshot(value string, start, oldEnd, newEnd int)
ApplySnapshot commits an external edit without allocating another full copy. The range must describe all differences from the current document.
func (*TextBuffer) ApplyTextEditsInRange ¶
func (b *TextBuffer) ApplyTextEditsInRange(value string, start, end, maxRunes int, multiline bool, edits []TextEdit) (string, int, int)
ApplyTextEditsInRange uses rune selections and returns one cached snapshot after applying the entire batch to the tree.
func (*TextBuffer) ChangedRange ¶
func (b *TextBuffer) ChangedRange(before, after string) (start, oldEnd, newEnd, prefixRunes int, ok bool)
ChangedRange reports the batch's byte delta without comparing document-sized snapshots. It is valid only for the exact before/after pair of the last edit.
func (*TextBuffer) Matches ¶
func (b *TextBuffer) Matches(value string) bool
func (*TextBuffer) MatchesSnapshot ¶
func (b *TextBuffer) MatchesSnapshot(value piecetree.Snapshot) bool
func (*TextBuffer) ReplaceBytes ¶
func (b *TextBuffer) ReplaceBytes(start, end int, text string)
ReplaceBytes applies an external byte-range edit and caches its snapshot.
func (*TextBuffer) Snapshot ¶
func (b *TextBuffer) Snapshot() piecetree.Snapshot
Snapshot returns the current immutable version, independent of future edits.
func (*TextBuffer) SnapshotChangedRange ¶
func (b *TextBuffer) SnapshotChangedRange(before, after piecetree.Snapshot) (start, oldEnd, newEnd, prefixRunes int, ok bool)
func (*TextBuffer) String ¶
func (b *TextBuffer) String() string
func (*TextBuffer) Sync ¶
func (b *TextBuffer) Sync(value string)
Sync installs an external snapshot only when the document has changed.
func (*TextBuffer) SyncSnapshot ¶
func (b *TextBuffer) SyncSnapshot(value piecetree.Snapshot)
type TextCommand ¶
type TextCommand uint8
const ( TextCommandBackspace TextCommand = iota + 1 TextCommandEnter )
type TextComposition ¶
type TextInputConfig ¶
type TextInputConfig struct {
InitialValue string
Revision uint64
SelectionStart int
SelectionEnd int
Caret TextInputRect
Kind TextInputKind
Active bool
Multiline bool
}
func (TextInputConfig) Value ¶
func (c TextInputConfig) Value() uint64
type TextInputKind ¶
type TextInputKind uint8
const ( TextInputText TextInputKind = iota TextInputDecimal TextInputInteger )