engine

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 0 Imported by: ? 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 engine is the input engine: it turns keystrokes into text to show while composing (preedit) and text to commit. This first version is a toy with a tiny built-in dictionary; it exists to prove the path from the system's input method framework to Go and back.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Composer

type Composer struct {
	// contains filtered or unexported fields
}

Composer holds one input session's state. Not safe for concurrent use; the host drives it from the main thread.

func New

func New() *Composer

New returns an empty Composer.

func (*Composer) Composing

func (c *Composer) Composing() bool

Composing reports whether there is text being composed.

func (*Composer) Feed

func (c *Composer) Feed(k Key) Result

Feed processes one keystroke.

func (*Composer) Flush

func (c *Composer) Flush() string

Flush ends composition and returns the raw letters to commit (used when the input field loses focus).

func (*Composer) Pick

func (c *Composer) Pick(index int) (string, bool)

Pick commits the candidate at index and ends composition.

type Key

type Key struct {
	Rune    rune
	Special Special
}

Key is one keystroke: a character (Rune) or a Special key.

type Result

type Result struct {
	Handled    bool
	Commit     string
	Preedit    string
	Candidates []string
}

Result is what the host must do after a keystroke. When Handled is false the host passes the key on to the application untouched. Otherwise it first inserts Commit (if any), then shows Preedit as the marked text ("" removes the marked text).

type Special

type Special int

Special names the non-character keys the engine cares about.

const (
	None Special = iota
	Space
	Enter
	Backspace
	Escape
)

Jump to

Keyboard shortcuts

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