Documentation
¶
Overview ¶
Package textedit is the model behind a text field that the platform keeps outside the framework (the hidden DOM field of the web, SPEC §23.5, and the Editable of the Android input method, SPEC §24.6), as plain Go: the editing state in UTF-16 units, the composition, and the editor that turns each change of the platform's field into the ui.TextInputEvent that makes the framework's field the same. It has no operating system code, so the web and Android platforms share it.
Index ¶
- type Composition
- type DOMWrite
- type EditingState
- type TextEditor
- func (e *TextEditor) BeforeInput(inputType, data string)
- func (e *TextEditor) Composing() bool
- func (e *TextEditor) CompositionEnd()
- func (e *TextEditor) CompositionStart()
- func (e *TextEditor) CompositionUpdate(data string)
- func (e *TextEditor) DOM() EditingState
- func (e *TextEditor) Handle(dom EditingState) (ui.TextInputEvent, bool)
- func (e *TextEditor) Paste(text string) (ui.TextInputEvent, bool)
- func (e *TextEditor) Reset()
- func (e *TextEditor) SetState(state ui.TextInputState) DOMWrite
- func (e *TextEditor) State() ui.TextInputState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Composition ¶
type Composition struct {
// contains filtered or unexported fields
}
Composition follows the composition events of the text field: the text the input method is composing, and where it began.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin
func (*Composition) Active ¶
func (c *Composition) Active() bool
Active says whether there is composing text: the composingText of Flutter is not null.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin.composingText
func (*Composition) Determine ¶
func (c *Composition) Determine(state EditingState) EditingState
Determine puts the composing range into the state: the composing text ends at the end of the selection when it began, and keeps its base while it grows. A state with no composing text, or one whose range would begin before the text, is returned as it is.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin.determineCompositionState
func (*Composition) End ¶
func (c *Composition) End()
End handles compositionend: the composition is over.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin._handleCompositionEnd
func (*Composition) Start ¶
func (c *Composition) Start()
Start handles compositionstart: no text is composing yet.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin._handleCompositionStart
func (*Composition) Text ¶
func (c *Composition) Text() string
Text is the composing text.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin.composingText
func (*Composition) Update ¶
func (c *Composition) Update(data string)
Update handles compositionupdate: data is the composing text.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin._handleCompositionUpdate
type DOMWrite ¶
DOMWrite is what to write into the element: its value and its selection in UTF-16 units. Write is false when the element already holds what the framework says.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.applyToDomElement
type EditingState ¶
type EditingState struct {
// Text is the value of the field.
Text string
// Base and Extent are the selection in UTF-16 code units: where it began and where it ends (the
// end that moves). They are never negative.
Base, Extent int
// ComposingBase and ComposingExtent are the text the input method is composing, in UTF-16 code
// units; -1 when there is none.
ComposingBase, ComposingExtent int
}
EditingState is the text and selection of the text field in the DOM.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState
func EditingStateFromDOM ¶
func EditingStateFromDOM(value string, selectionStart, selectionEnd int, direction string) EditingState
EditingStateFromDOM reads the value and selection of a DOM element: selectionStart, selectionEnd and selectionDirection. A backward selection has its base at the end.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.fromDomElement
func NewEditingState ¶
func NewEditingState(text string, base, extent int) EditingState
NewEditingState makes a state without a composing range. A negative offset becomes 0, because -1 is not a valid selection of a DOM element.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.new
func (EditingState) Composing ¶
func (e EditingState) Composing() (start, end int, ok bool)
Composing returns the composing range when the state has one that lies in the text and is not empty.
Flutter: no counterpart (the framework's TextEditingValue.isComposingRangeValid)
func (EditingState) Equal ¶
func (e EditingState) Equal(o EditingState) bool
Equal compares two states as Flutter does: the text, the ends of the selection whichever way it runs, and the composing range.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.==
func (EditingState) IsValid ¶
func (e EditingState) IsValid() bool
IsValid says whether the offsets of the selection are not negative.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.isValid
func (EditingState) MaxOffset ¶
func (e EditingState) MaxOffset() int
MaxOffset is the greater end of the selection.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.maxOffset
func (EditingState) MinOffset ¶
func (e EditingState) MinOffset() int
MinOffset is the smaller end of the selection.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.minOffset
func (EditingState) WithComposing ¶
func (e EditingState) WithComposing(base, extent int) EditingState
WithComposing returns the state with the composing range changed.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart EditingState.copyWith
type TextEditor ¶
type TextEditor struct {
// contains filtered or unexported fields
}
TextEditor is the model behind the hidden text field (SPEC §23.5), as plain Go: it knows what the framework last said about the field (a ui.TextInputState, UTF-8) and what the DOM element holds (an EditingState, UTF-16), turns the state of the framework into a write to the element, and turns each change in the element into the ui.TextInputEvent that makes the framework's field the same. The code that talks to the browser only copies the fields of the events into these values.
The framework owns the caret and the selection (it handles the arrow keys and the mouse), so only the text, and the text being composed, are sent from the element; a selection that the browser alone moved is not.
Deviation: Flutter's engine sends the framework the whole editing state, or the deltas, and the framework's text field takes the platform's word for the selection. Here the contract is the one the Linux input methods use, ui.TextInputEvent, so the change is found by comparing the element's text with the framework's (SPEC §12.10).
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart DefaultTextEditingStrategy
func (*TextEditor) BeforeInput ¶
func (e *TextEditor) BeforeInput(inputType, data string)
BeforeInput handles beforeinput. An insertCompositionText that no compositionupdate announced (browsers differ in the order of the two) starts the composition with its data.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart DefaultTextEditingStrategy.handleBeforeInput
func (*TextEditor) Composing ¶
func (e *TextEditor) Composing() bool
Composing says whether the input method is composing text.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin.composingText
func (*TextEditor) CompositionEnd ¶
func (e *TextEditor) CompositionEnd()
CompositionEnd handles compositionend. The caller reads the element and calls Handle afterwards, so that the composed text is committed (Flutter leaves that to the next input or selectionchange event).
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin._handleCompositionEnd
func (*TextEditor) CompositionStart ¶
func (e *TextEditor) CompositionStart()
CompositionStart handles compositionstart.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin._handleCompositionStart
func (*TextEditor) CompositionUpdate ¶
func (e *TextEditor) CompositionUpdate(data string)
CompositionUpdate handles compositionupdate; data is the composing text.
Flutter: lib/web_ui/lib/src/engine/text_editing/composition_aware_mixin.dart CompositionAwareMixin._handleCompositionUpdate
func (*TextEditor) DOM ¶
func (e *TextEditor) DOM() EditingState
DOM is the state of the element as the editor knows it.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart DefaultTextEditingStrategy.lastEditingState
func (*TextEditor) Handle ¶
func (e *TextEditor) Handle(dom EditingState) (ui.TextInputEvent, bool)
Handle takes the state of the element after a DOM event (input, selectionchange, compositionend, or a compositionupdate that changes the element) and returns the event that makes the framework's field the same, and whether there is one. The composing range comes from the composition events. A change of the selection alone is not sent.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart DefaultTextEditingStrategy.handleChange
func (*TextEditor) Paste ¶
func (e *TextEditor) Paste(text string) (ui.TextInputEvent, bool)
Paste takes the text of a paste event and returns the event that inserts it in place of the selection.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart DefaultTextEditingStrategy.handleClipboardEvent
func (*TextEditor) Reset ¶
func (e *TextEditor) Reset()
Reset forgets the field: the next state is written to a new element.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart DefaultTextEditingStrategy.disable
func (*TextEditor) SetState ¶
func (e *TextEditor) SetState(state ui.TextInputState) DOMWrite
SetState takes the state the framework gave the field and says what to write into the element. The element is written only when it differs from the state, leaving out the text being composed: writing to it would end the composition, and the framework's state of a composing field is the text without it.
Flutter: lib/web_ui/lib/src/engine/text_editing/text_editing.dart DefaultTextEditingStrategy.setEditingState
func (*TextEditor) State ¶
func (e *TextEditor) State() ui.TextInputState
State is what the editor believes the framework's field holds.
Flutter: no counterpart