Documentation
¶
Index ¶
- Constants
- func ApplyTextEditsInRange(value string, selectionStart, selectionEnd, maxRunes int, multiline bool, ...) (string, int, int)
- 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) 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) 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 ( DeltaPixel = 0 DeltaLine = 1 DeltaPage = 2 )
const ( KeyLocationStandard = 0 KeyLocationLeft = 1 KeyLocationRight = 2 KeyLocationNumpad = 3 )
const ( MouseNone = MouseButton(-1) MouseLeft = MouseButton(0) MouseRight = MouseButton(2) MouseMiddle = MouseButton(1) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
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
const ( KeySpace KeyCode = 32 KeyApostrophe KeyCode = 222 KeyComma KeyCode = 188 KeyMinus KeyCode = 189 KeyPeriod KeyCode = 190 KeySlash KeyCode = 191 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 = 186 KeyEqual KeyCode = 187 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 = 219 KeyBackslash KeyCode = 220 KeyRightBracket KeyCode = 221 KeyGraveAccent KeyCode = 192 KeyWorld1 KeyCode = -iota - 1 KeyWorld2 KeyCode = -iota - 1 KeyEscape KeyCode = 27 KeyEnter KeyCode = 13 KeyTab KeyCode = 9 KeyBackspace KeyCode = 8 KeyInsert KeyCode = -iota - 1 KeyDelete KeyCode = 46 KeyRight KeyCode = 39 KeyLeft KeyCode = 37 KeyDown KeyCode = 40 KeyUp KeyCode = 38 KeyPageUp KeyCode = -iota - 1 KeyPageDown KeyCode = -iota - 1 KeyHome KeyCode = -iota - 1 KeyEnd KeyCode = -iota - 1 KeyCapsLock KeyCode = 20 KeyScrollLock KeyCode = -iota - 1 KeyNumLock KeyCode = -iota - 1 KeyPrintScreen KeyCode = -iota - 1 KeyPause KeyCode = -iota - 1 KeyF1 KeyCode = 112 KeyF2 KeyCode = 113 KeyF3 KeyCode = 114 KeyF4 KeyCode = 115 KeyF5 KeyCode = 116 KeyF6 KeyCode = 117 KeyF7 KeyCode = 118 KeyF8 KeyCode = 119 KeyF9 KeyCode = 120 KeyF10 KeyCode = 121 KeyF11 KeyCode = 122 KeyF12 KeyCode = 123 KeyF13 KeyCode = -iota - 1 KeyF14 KeyCode = -iota - 1 KeyF15 KeyCode = -iota - 1 KeyF16 KeyCode = -iota - 1 KeyF17 KeyCode = -iota - 1 KeyF18 KeyCode = -iota - 1 KeyF19 KeyCode = -iota - 1 KeyF20 KeyCode = -iota - 1 KeyF21 KeyCode = -iota - 1 KeyF22 KeyCode = -iota - 1 KeyF23 KeyCode = -iota - 1 KeyF24 KeyCode = -iota - 1 KeyF25 KeyCode = -iota - 1 KeyKP0 KeyCode = -iota - 1 KeyKP1 KeyCode = -iota - 1 KeyKP2 KeyCode = -iota - 1 KeyKP3 KeyCode = -iota - 1 KeyKP4 KeyCode = -iota - 1 KeyKP5 KeyCode = -iota - 1 KeyKP6 KeyCode = -iota - 1 KeyKP7 KeyCode = -iota - 1 KeyKP8 KeyCode = -iota - 1 KeyKP9 KeyCode = -iota - 1 KeyKPDecimal KeyCode = -iota - 1 KeyKPDivide KeyCode = -iota - 1 KeyKPMultiply KeyCode = -iota - 1 KeyKPSubtract KeyCode = -iota - 1 KeyKPAdd KeyCode = -iota - 1 KeyKPEnter KeyCode = -iota - 1 KeyKPEqual KeyCode = -iota - 1 KeyLeftShift KeyCode = 340 KeyLeftControl KeyCode = 341 KeyLeftAlt KeyCode = 342 KeyLeftSuper KeyCode = 91 KeyRightShift KeyCode = 344 KeyRightControl KeyCode = 345 KeyRightAlt KeyCode = 346 KeyRightSuper KeyCode = 93 KeyMenu KeyCode = -iota - 1 )
TODO: s defined as -iota-1 need to be set to a valid positive value that matches the keyCode
Key generated by browsers. -iota-1 is used as a temporary solution to have unique but invalid values. KeySee https://developer.mozilla.org/en-US/docs/Web/API/boardEvent/keyCode.
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) 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 )