Documentation
¶
Overview ¶
Package ime is the text input of the Windows backend as plain Go: the composition of an input method (IMM32, SPEC §25.7) turned into the ui.TextInputEvents of the framework by the model of internal/platform/textedit, the characters of the keyboard that no key made, and the places of the composition and candidate windows. It talks to Windows through the small interface IMM, which imm_windows.go implements with imm32.dll and the tests with a fake, so the model runs on any host.
Flutter: shell/platform/windows/text_input_manager.cc TextInputManager
Index ¶
- func CaretRect(r ui.Rect, scale float64) win32.Rect
- type IMM
- type Input
- func (in *Input) CaretRect() win32.Rect
- func (in *Input) Commit(text string)
- func (in *Input) Composing() bool
- func (in *Input) Enabled() bool
- func (in *Input) FocusChanged()
- func (in *Input) HandleChar(unit uint16)
- func (in *Input) HandleComposition(lparam uintptr) bool
- func (in *Input) HandleEndComposition()
- func (in *Input) HandleSetContext(wparam, lparam uintptr) uintptr
- func (in *Input) HandleStartComposition()
- func (in *Input) IMEOn() bool
- func (in *Input) Preedit() string
- func (in *Input) SetState(st ui.TextInputState, scale float64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IMM ¶
type IMM interface {
// Context returns the input context of the window, 0 when the input method is off for it.
// Release gives it back.
Context(hwnd uintptr) uintptr
Release(hwnd, ctx uintptr)
// String reads the composition string (win32.GCSCompStr) or the result string
// (win32.GCSResultStr) as UTF-16 units, and reports whether the call worked.
String(ctx uintptr, index uint32) ([]uint16, bool)
// Value reads a number of the composition, such as win32.GCSCursorPos; negative when the call
// failed.
Value(ctx uintptr, index uint32) int32
// SetCompositionWindow and SetCandidateWindow place the windows of the input method.
SetCompositionWindow(ctx uintptr, form *win32.CompositionForm) bool
SetCandidateWindow(ctx uintptr, form *win32.CandidateForm) bool
// Notify is ImmNotifyIME; SetCompositionString clears the composition string.
Notify(ctx uintptr, action, index, value uint32) bool
SetCompositionString(ctx uintptr, comp, read []uint16) bool
// AssociateContext and AssociateContextEx turn the input method off and on for the window.
AssociateContext(hwnd, ctx uintptr) uintptr
AssociateContextEx(hwnd, ctx uintptr, flags uint32) bool
// The system caret, and the window that has the keyboard focus.
CreateCaret(hwnd uintptr, w, h int32) bool
DestroyCaret() bool
SetCaretPos(x, y int32) bool
Focus() uintptr
}
IMM is what the text input asks of Windows: the input context of a window and its composition, the windows of the input method, the association of the window with its context and the system caret that some input methods read. All calls belong to the UI thread. The real implementation is System; the tests use a fake.
Flutter: shell/platform/windows/text_input_manager.h TextInputManager (the Win32 calls it makes)
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input is the text input of one window: it keeps the framework's text field as the editor of the platform knows it, and turns what the input method of Windows does into events for the field (SPEC §25.7). It belongs to the UI thread.
Flutter: shell/platform/windows/text_input_manager.cc TextInputManager
func New ¶
func New(imm IMM, hwnd uintptr, deliver func(ui.TextInputEvent)) *Input
New makes the text input of a window. The input method is off for the window until a text field has the focus. deliver gets the events for the framework.
Flutter: shell/platform/windows/text_input_manager.cc TextInputManager::SetWindowHandle
func (*Input) CaretRect ¶
CaretRect is the caret rectangle in client pixels, as the windows of the input method follow it.
Flutter: no counterpart
func (*Input) Commit ¶
Commit types text into the field at the caret, in place of the selection (and of the preedit).
Flutter: shell/platform/windows/text_input_plugin.cc TextInputPlugin::TextHook
func (*Input) Composing ¶
Composing says whether the input method is composing text.
Flutter: shell/platform/windows/text_input_model.h TextInputModel::composing
func (*Input) FocusChanged ¶
func (in *Input) FocusChanged()
FocusChanged puts the windows of the input method at the caret again: the window may have got the keyboard focus after the field asked for them (they are only placed while the window has it).
Flutter: no counterpart
func (*Input) HandleChar ¶
HandleChar handles a WM_CHAR that no key made (the character of an input method that composes nothing, a key that SendInput sent as a Unicode character, a script's text): a character is typed as a commit. The two messages of a surrogate pair make one character, a control character makes none, and nothing is typed while no text field has the focus.
Flutter: shell/platform/windows/flutter_window.cc FlutterWindow::OnText, text_input_plugin.cc TextInputPlugin::TextHook
func (*Input) HandleComposition ¶
HandleComposition handles WM_IME_COMPOSITION and reports whether the window procedure answers 0 without DefWindowProc: when the message carries the result string or the composition string (otherwise DefWindowProc would make WM_IME_CHAR and WM_CHAR messages of the result). The result string is a commit, the composition string is the preedit with the caret inside it; a message that carries both (Google Japanese Input and ATOK do) makes one event, in the order of the event: the commit, then the new preedit. A message with no flag cancels the composition.
Flutter: shell/platform/windows/flutter_window.cc FlutterWindow::OnImeComposition
func (*Input) HandleEndComposition ¶
func (in *Input) HandleEndComposition()
HandleEndComposition handles WM_IME_ENDCOMPOSITION: what is still being composed is committed (an input method that ends with a composition string and no result), and the composition is over.
Flutter: shell/platform/windows/flutter_window.cc FlutterWindow::OnImeEndComposition, text_input_plugin.cc TextInputPlugin::ComposeEndHook
func (*Input) HandleSetContext ¶
HandleSetContext handles WM_IME_SETCONTEXT and returns the lParam for DefWindowProc: the flag that asks the input method to draw its own composition window is cleared, because the field draws the preedit. A context that becomes active places the windows of the input method.
Flutter: shell/platform/windows/flutter_window.cc FlutterWindow::HandleMessage (WM_IME_SETCONTEXT), OnImeSetContext
func (*Input) HandleStartComposition ¶
func (in *Input) HandleStartComposition()
HandleStartComposition handles WM_IME_STARTCOMPOSITION: a composition begins. The window procedure answers 0 without DefWindowProc, so the system draws no composition window of its own.
Flutter: shell/platform/windows/flutter_window.cc FlutterWindow::OnImeStartComposition, OnComposeBegin
func (*Input) IMEOn ¶
IMEOn says whether the window has its input context: the input method is on for it.
Flutter: no counterpart
func (*Input) SetState ¶
func (in *Input) SetState(st ui.TextInputState, scale float64)
SetState takes what the framework says about the focused text field (platform.Window.SetTextInput). A field that gets the focus turns the input method on and puts its windows at the caret; the caret rectangle (logical pixels of the view, scale pixels each) moves them when it changes; no field turns the input method off and ends a composition that was going on. A change of the text or the selection leaves the input method's composition alone: the next message of the input method is applied to the new text (Flutter does the same).
Flutter: shell/platform/windows/text_input_plugin.cc TextInputPlugin::HandleMethodCall (TextInput.setClient, TextInput.setEditingState, TextInput.clearClient, TextInput.setMarkedTextRect)
Directories
¶
| Path | Synopsis |
|---|---|
|
Package imetest is a fake of the input method manager (ime.IMM) for the tests of the text input of Windows, in the ime package and in the window code that uses it.
|
Package imetest is a fake of the input method manager (ime.IMM) for the tests of the text input of Windows, in the ime package and in the window code that uses it. |