ime

package
v1.17.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaretRect

func CaretRect(r ui.Rect, scale float64) win32.Rect

CaretRect is the caret rectangle of the framework (logical pixels of the view) in client pixels: each edge times the scale, cut to a whole number as the conversion to a LONG does in Flutter.

Flutter: shell/platform/windows/flutter_window.cc FlutterWindow::OnCursorRectUpdated

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

func (in *Input) CaretRect() win32.Rect

CaretRect is the caret rectangle in client pixels, as the windows of the input method follow it.

Flutter: no counterpart

func (*Input) Commit

func (in *Input) Commit(text string)

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

func (in *Input) Composing() bool

Composing says whether the input method is composing text.

Flutter: shell/platform/windows/text_input_model.h TextInputModel::composing

func (*Input) Enabled

func (in *Input) Enabled() bool

Enabled says whether a text field has the focus.

Flutter: no counterpart

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

func (in *Input) HandleChar(unit uint16)

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

func (in *Input) HandleComposition(lparam uintptr) bool

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

func (in *Input) HandleSetContext(wparam, lparam uintptr) uintptr

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

func (in *Input) IMEOn() bool

IMEOn says whether the window has its input context: the input method is on for it.

Flutter: no counterpart

func (*Input) Preedit

func (in *Input) Preedit() string

Preedit is the composing text the framework shows.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL