ime

package
Version: v0.0.0-...-ffc66be Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package ime provides Go bindings of Chrome APIs to control IMEs.

Index

Constants

View Source
const ChromeIMEPrefix = "_comp_ime_jkghodnilhceideoidjikpgommlajknk"

ChromeIMEPrefix is the prefix of IME chrome extension.

View Source
const ChromiumIMEPrefix = "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkao"

ChromiumIMEPrefix is the prefix of IME chromium extension.

Variables

View Source
var AlphanumericWithJapaneseKeyboard = InputMethod{
	Name: "Alphanumeric with Japanese keyboard",
	ID:   "xkb:jp::jpn",
}

AlphanumericWithJapaneseKeyboard represents the input method of Alphanumeric with Japanese keyboard.

View Source
var Cantonese = InputMethod{
	Name: "Cantonese",
	ID:   "yue-hant-t-i0-und",
}

Cantonese represents the input method of Chinese Cantonese.

View Source
var ChineseCangjie = InputMethod{
	Name: "Chinese Cangjie",
	ID:   "zh-hant-t-i0-cangjie-1987",
}

ChineseCangjie represents the input method of Chinese Cangjie.

View Source
var ChinesePinyin = InputMethod{
	Name: "Chinese Pinyin",
	ID:   "zh-t-i0-pinyin",
}

ChinesePinyin represents the input method of Chinese Pinyin.

View Source
var DefaultInputMethod = EnglishUS

DefaultInputMethod is the default input method enabled for new users.

View Source
var EnglishCanada = InputMethod{
	Name: "English (Canada)",
	ID:   "xkb:ca:eng:eng",
}

EnglishCanada represents the input method of English (Canada).

View Source
var EnglishUK = InputMethod{
	Name: "English (UK)",
	ID:   "xkb:gb:extd:eng",
}

EnglishUK represents the input method of English (UK).

View Source
var EnglishUS = InputMethod{
	Name: "English (US)",
	ID:   "xkb:us::eng",
}

EnglishUS represents the input method of English (US).

View Source
var EnglishUSWithInternationalKeyboard = InputMethod{
	Name: "English (US) with International keyboard",
	ID:   "xkb:us:intl:eng",
}

EnglishUSWithInternationalKeyboard represents the input method of English (US) with International keyboard.

View Source
var FrenchFrance = InputMethod{
	Name: "French (France)",
	ID:   "xkb:fr::fra",
}

FrenchFrance represents the input method of French (France).

View Source
var Japanese = InputMethod{
	Name: "Japanese",
	ID:   "nacl_mozc_jp",
}

Japanese represents the input method of Japanese.

View Source
var JapaneseWithUSKeyboard = InputMethod{
	Name: "Japanese with US keyboard",
	ID:   "nacl_mozc_us",
}

JapaneseWithUSKeyboard represents the input method of Japanese with US keyboard.

View Source
var Korean = InputMethod{
	Name: "Korean",
	ID:   "ko-t-i0-und",
}

Korean represents the input method of Korean.

View Source
var SpanishSpain = InputMethod{
	Name: "Spanish (Spain)",
	ID:   "xkb:es::spa",
}

SpanishSpain represents the input method of Spanish (Spain).

View Source
var Swedish = InputMethod{
	Name: "Swedish",
	ID:   "xkb:se::swe",
}

Swedish represents the input method of Swedish.

Functions

func AddAndSetInputMethod

func AddAndSetInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error

AddAndSetInputMethod adds the IME identified by imeID and then sets it to the current input method. Note: this function will not do anything if the IME already exists.

func AddInputMethod

func AddInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error

AddInputMethod adds the IME identified by imeID via chorme.languageSettingsPrivate.addInputMethod API.

func CurrentInputMethod

func CurrentInputMethod(ctx context.Context, tconn *chrome.TestConn) (string, error)

CurrentInputMethod returns the ID of current IME obtained via chrome.inputMethodPrivate.getCurrentInputMethod API.

func DisableLanguage

func DisableLanguage(ctx context.Context, tconn *chrome.TestConn, lang string) error

DisableLanguage disables the given language via chrome.languageSettingsPrivate.disableLanguage API.

func EnableLanguage

func EnableLanguage(ctx context.Context, tconn *chrome.TestConn, lang string) error

EnableLanguage enables the given language via chrome.languageSettingsPrivate.enableLanguage API.

func Prefix

func Prefix(ctx context.Context, tconn *chrome.TestConn) (string, error)

Prefix returns the prefix of the default IME extension, depending on whether the build is Chrome (official build) or Chromium.

func RemoveInputMethod

func RemoveInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error

RemoveInputMethod removes the IME identified by imeID via chorme.languageSettingsPrivate.removeInputMethod API.

func SetCurrentInputMethod

func SetCurrentInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error

SetCurrentInputMethod sets the current input method to the IME identified imeID via chrome.inputMethodPrivate.setCurrentInputMethod API.

func WaitForInputMethodInstalled

func WaitForInputMethodInstalled(ctx context.Context, tconn *chrome.TestConn, imeID string, timeout time.Duration) error

WaitForInputMethodInstalled repeatedly checks until a certain IME is installed.

func WaitForInputMethodMatches

func WaitForInputMethodMatches(ctx context.Context, tconn *chrome.TestConn, imeID string, timeout time.Duration) error

WaitForInputMethodMatches repeatedly checks until the current IME matches expectation.

func WaitForInputMethodRemoved

func WaitForInputMethodRemoved(ctx context.Context, tconn *chrome.TestConn, imeID string, timeout time.Duration) error

WaitForInputMethodRemoved repeatedly checks until a certain IME is uninstalled.

Types

type BindingInputMethod

type BindingInputMethod struct {
	ID string `json:"id"`
}

BindingInputMethod is the Go binding struct of https://source.chromium.org/chromium/chromium/src/+/HEAD:chrome/common/extensions/api/language_settings_private.idl;l=55 The struct only defines the necessary fields.

func InstalledInputMethods

func InstalledInputMethods(ctx context.Context, tconn *chrome.TestConn) ([]BindingInputMethod, error)

InstalledInputMethods returns installed input methods via chrome.inputMethodPrivate.getInputMethods API.

type BindingInputMethodLists

type BindingInputMethodLists struct {
	ThirdPartyExtensionIMEs []BindingInputMethod `json:"thirdPartyExtensionImes"`
}

BindingInputMethodLists is the Go binding struct of https://source.chromium.org/chromium/chromium/src/+/HEAD:chrome/common/extensions/api/language_settings_private.idl;l=75 The struct only defines the necessary fields.

func BrowserInputMethodLists

func BrowserInputMethodLists(ctx context.Context, tconn *chrome.TestConn) (*BindingInputMethodLists, error)

BrowserInputMethodLists returns supported InputMethodLists obtained via chrome.languageSettingsPrivate.getInputMethodLists API.

type InputMethod

type InputMethod struct {
	Name string // The displayed name of the IME in OS Settings.
	ID   string // The code / id of the IME, e.g. "xkb:us::eng"
}

InputMethod represents an input method.

func ActiveInputMethod

func ActiveInputMethod(ctx context.Context, tconn *chrome.TestConn) (*InputMethod, error)

ActiveInputMethod returns the active input method via Chrome API.

func FindInputMethodByFullyQualifiedIMEID

func FindInputMethodByFullyQualifiedIMEID(ctx context.Context, tconn *chrome.TestConn, fullyQualifiedIMEID string) (*InputMethod, error)

FindInputMethodByFullyQualifiedIMEID finds the input method by fully qualified IME ID, e.g. _comp_ime_jkghodnilhceideoidjikpgommlajknkxkb:us::eng.

func FindInputMethodByID

func FindInputMethodByID(id string) (*InputMethod, error)

FindInputMethodByID finds the input method by ime id.

func FindInputMethodByName

func FindInputMethodByName(name string) (*InputMethod, error)

FindInputMethodByName finds the input method by displayed name.

func (InputMethod) Activate

func (im InputMethod) Activate(tconn *chrome.TestConn) action.Action

Activate sets the input method to use via Chrome API. It does nothing if the IME is already in use.

func (InputMethod) Equal

func (im InputMethod) Equal(imb InputMethod) bool

Equal compares two input methods by id and returns true if they equal.

func (InputMethod) FullyQualifiedIMEID

func (im InputMethod) FullyQualifiedIMEID(ctx context.Context, tconn *chrome.TestConn) (string, error)

FullyQualifiedIMEID returns the fully qualified IME id constructed by IMEPrefix + IME ID. In Chrome, the fully qualified IME id is Chrome IME prefix + id: e.g. _comp_ime_jkghodnilhceideoidjikpgommlajknkxkb:us::eng In Chromium, the fully qualified IME id is Chromium IME prefix + id: e.g. _comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us::eng

func (InputMethod) Install

func (im InputMethod) Install(tconn *chrome.TestConn) action.Action

Install installs the input method via Chrome API. It does nothing if the IME is already installed.

func (InputMethod) InstallAndActivate

func (im InputMethod) InstallAndActivate(tconn *chrome.TestConn) action.Action

InstallAndActivate installs the input method and set it to active via Chrome API.

func (InputMethod) Remove

func (im InputMethod) Remove(tconn *chrome.TestConn) action.Action

Remove uninstalls the input method via Chrome API.

func (InputMethod) String

func (im InputMethod) String() string

String returns the key representative string content of the input method.

type InputMethodCode

type InputMethodCode string

InputMethodCode represents an input method code. TODO(b/192819861): Defining new input method struct and migrating existing use of InputMethodCode.

const (
	INPUTMETHOD_XKB_US_ENG                    InputMethodCode = "xkb:us::eng"               // NOLINT: English (US)
	INPUTMETHOD_XKB_US_INTL                   InputMethodCode = "xkb:us:intl:eng"           // NOLINT: English (US) with International keyboard
	INPUTMETHOD_XKB_GB_EXTD_ENG               InputMethodCode = "xkb:gb:extd:eng"           // NOLINT: English (UK)
	INPUTMETHOD_XKB_ES_SPA                    InputMethodCode = "xkb:es::spa"               // NOLINT: Spanish (Spain)
	INPUTMETHOD_XKB_SE_SWE                    InputMethodCode = "xkb:se::swe"               // NOLINT: Swedish
	INPUTMETHOD_XKB_JP_JPN                    InputMethodCode = "xkb:jp::jpn"               // NOLINT: Alphanumeric with Japanese keyboard
	INPUTMETHOD_XKB_CA_ENG                    InputMethodCode = "xkb:ca:eng:eng"            // NOLINT: English (Canada)
	INPUTMETHOD_NACL_MOZC_JP                  InputMethodCode = "nacl_mozc_jp"              // NOLINT: Japanese
	INPUTMETHOD_XKB_FR_FRA                    InputMethodCode = "xkb:fr::fra"               // NOLINT: Franch (France)
	INPUTMETHOD_NACL_MOZC_US                  InputMethodCode = "nacl_mozc_us"              // NOLINT: Japanese with US keyboard
	INPUTMETHOD_PINYIN_CHINESE_SIMPLIFIED     InputMethodCode = "zh-t-i0-pinyin"            // NOLINT: Chinese Pinyin input method
	INPUTMETHOD_CANTONESE_CHINESE_TRADITIONAL InputMethodCode = "yue-hant-t-i0-und"         // NOLINT: Chinese Cantonese input method
	INPUTMETHOD_CANGJIE87_CHINESE_TRADITIONAL InputMethodCode = "zh-hant-t-i0-cangjie-1987" // NOLINT: Chinese Cangjie input method
	INPUTMETHOD_HANGEUL_HANJA_KOREAN          InputMethodCode = "ko-t-i0-und"               // NOLINT: Korean input method
)

List of input tool codes. Sorted by IME usage stat go/e14s-grades.

type Language

type Language string

Language represents a language.

const (
	LANGUAGE_EN      Language = "English"            //NOLINT
	LANGUAGE_ZH_HANS Language = "Simplified Chinese" //NOLINT
	LANGUAGE_JA      Language = "Japanese"           //NOLINT
)

List of languages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to