Documentation
¶
Overview ¶
Package ime provides Go bindings of Chrome APIs to control IMEs.
Index ¶
- Constants
- Variables
- func AddAndSetInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error
- func AddInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error
- func CurrentInputMethod(ctx context.Context, tconn *chrome.TestConn) (string, error)
- func DisableLanguage(ctx context.Context, tconn *chrome.TestConn, lang string) error
- func EnableLanguage(ctx context.Context, tconn *chrome.TestConn, lang string) error
- func Prefix(ctx context.Context, tconn *chrome.TestConn) (string, error)
- func RemoveInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error
- func SetCurrentInputMethod(ctx context.Context, tconn *chrome.TestConn, imeID string) error
- func SetCurrentInputMethodAndWaitWarmUp(ctx context.Context, tconn *chrome.TestConn, imeID string, ...) error
- func WaitForInputMethodActivated(ctx context.Context, tconn *chrome.TestConn, imeID string, ...) error
- func WaitForInputMethodInstalled(ctx context.Context, tconn *chrome.TestConn, imeID string, ...) error
- func WaitForInputMethodMatches(ctx context.Context, tconn *chrome.TestConn, imeID string, ...) error
- func WaitForInputMethodRemoved(ctx context.Context, tconn *chrome.TestConn, imeID string, ...) error
- type AutoCorrectionLevel
- type BindingInputMethod
- type BindingInputMethodLists
- type InputMethod
- func ActiveInputMethod(ctx context.Context, tconn *chrome.TestConn) (*InputMethod, error)
- func FindInputMethodByFullyQualifiedIMEID(ctx context.Context, tconn *chrome.TestConn, fullyQualifiedIMEID string) (*InputMethod, error)
- func FindInputMethodByID(id string) (*InputMethod, error)
- func FindInputMethodByName(name string) (*InputMethod, error)
- func (im InputMethod) Activate(tconn *chrome.TestConn) action.Action
- func (im InputMethod) Equal(imb InputMethod) bool
- func (im InputMethod) FullyQualifiedIMEID(ctx context.Context, tconn *chrome.TestConn) (string, error)
- func (im InputMethod) Install(tconn *chrome.TestConn) action.Action
- func (im InputMethod) InstallAndActivate(tconn *chrome.TestConn) action.Action
- func (im InputMethod) Remove(tconn *chrome.TestConn) action.Action
- func (im InputMethod) ResetSettings(tconn *chrome.TestConn) action.Action
- func (im InputMethod) SetPKAutoCorrection(tconn *chrome.TestConn, acLevel AutoCorrectionLevel) action.Action
- func (im InputMethod) SetSettings(tconn *chrome.TestConn, settings map[string]interface{}) action.Action
- func (im InputMethod) SetVKAutoCorrection(tconn *chrome.TestConn, acLevel AutoCorrectionLevel) action.Action
- func (im InputMethod) SetVKEnableCapitalization(tconn *chrome.TestConn, isEnabled bool) action.Action
- func (im InputMethod) String() string
- func (im InputMethod) WaitUntilActivated(tconn *chrome.TestConn) action.Action
- func (im InputMethod) WaitUntilInstalled(tconn *chrome.TestConn) action.Action
- func (im InputMethod) WaitUntilRemoved(tconn *chrome.TestConn) action.Action
- type Language
Constants ¶
const ChromeIMEPrefix = "_comp_ime_jkghodnilhceideoidjikpgommlajknk"
ChromeIMEPrefix is the prefix of IME chrome extension.
const ChromiumIMEPrefix = "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkao"
ChromiumIMEPrefix is the prefix of IME chromium extension.
Variables ¶
var AlphanumericWithJapaneseKeyboard = InputMethod{ Name: "Alphanumeric with Japanese keyboard", ID: "xkb:jp::jpn", ShortLabel: "JA", HandwritingLanguage: LanguageJa, VoiceLanguage: LanguageJa, }
AlphanumericWithJapaneseKeyboard represents the input method of Alphanumeric with Japanese keyboard.
var Arabic = InputMethod{ Name: "Arabic", ID: "vkd_ar", ShortLabel: "AR", HandwritingLanguage: LanguageAr, VoiceLanguage: LanguageAr, }
Arabic represents the input method of Arabic.
var Cantonese = InputMethod{ Name: "Cantonese", ID: "yue-hant-t-i0-und", ShortLabel: "粤", HandwritingLanguage: LanguageZhHant, VoiceLanguage: LanguageYueHant, }
Cantonese represents the input method of Chinese Cantonese.
var Catalan = InputMethod{ Name: "Catalan", ID: "xkb:es:cat:cat", HandwritingLanguage: LanguageCa, VoiceLanguage: LanguageCa, }
Catalan represents the input method of Catalan.
var ChineseCangjie = InputMethod{ Name: "Chinese Cangjie", ID: "zh-hant-t-i0-cangjie-1987", ShortLabel: "倉", HandwritingLanguage: LanguageZhHant, VoiceLanguage: LanguageZhHant, }
ChineseCangjie represents the input method of Chinese Cangjie.
var ChinesePinyin = InputMethod{ Name: "Chinese Pinyin", ID: "zh-t-i0-pinyin", ShortLabel: "拼", HandwritingLanguage: LanguageZhHans, VoiceLanguage: LanguageZhHans, }
ChinesePinyin represents the input method of Chinese Pinyin.
var DefaultInputMethod = EnglishUS
DefaultInputMethod is the default input method enabled for new users.
var EnglishCanada = InputMethod{ Name: "English (Canada)", ID: "xkb:ca:eng:eng", ShortLabel: "CA", HandwritingLanguage: LanguageEn, VoiceLanguage: LanguageEn, }
EnglishCanada represents the input method of English (Canada).
var EnglishSouthAfrica = InputMethod{ Name: "English (South Africa)", ID: "xkb:za:gb:eng", ShortLabel: "ZA", HandwritingLanguage: LanguageEn, VoiceLanguage: LanguageEn, }
EnglishSouthAfrica represents the input method of English (South Africa).
var EnglishUK = InputMethod{ Name: "English (UK)", ID: "xkb:gb:extd:eng", ShortLabel: "GB", HandwritingLanguage: LanguageEn, VoiceLanguage: LanguageEn, }
EnglishUK represents the input method of English (UK).
var EnglishUS = InputMethod{ Name: "English (US)", ID: "xkb:us::eng", ShortLabel: "US", HandwritingLanguage: LanguageEn, VoiceLanguage: LanguageEn, }
EnglishUS represents the input method of English (US).
var EnglishUSWithInternationalKeyboard = InputMethod{ Name: "English (US) with International keyboard", ID: "xkb:us:intl:eng", ShortLabel: "INTL", HandwritingLanguage: LanguageEn, VoiceLanguage: LanguageEn, }
EnglishUSWithInternationalKeyboard represents the input method of English (US) with International keyboard.
var FrenchFrance = InputMethod{ Name: "French (France)", ID: "xkb:fr::fra", ShortLabel: "FR", HandwritingLanguage: LanguageFr, VoiceLanguage: LanguageFr, }
FrenchFrance represents the input method of French (France).
var GreekTransliteration = InputMethod{ Name: "GreekTransliteration", ID: "el-t-i0-und", HandwritingLanguage: LanguageEl, VoiceLanguage: LanguageEl, }
GreekTransliteration represents the input method of Greek Transliteration.
var Gujarati = InputMethod{ Name: "Gujarati", ID: "gu-t-i0-und", HandwritingLanguage: LanguageGu, VoiceLanguage: LanguageGu, }
Gujarati represents the input method of Gujarati.
var Hindi = InputMethod{ Name: "Hindi", ID: "hi-t-i0-und", HandwritingLanguage: LanguageHi, VoiceLanguage: LanguageHi, }
Hindi represents the input method of Hindi.
var Japanese = InputMethod{ Name: "Japanese", ID: "nacl_mozc_jp", ShortLabel: "あ", HandwritingLanguage: LanguageJa, VoiceLanguage: LanguageJa, }
Japanese represents the input method of Japanese.
var JapaneseWithUSKeyboard = InputMethod{ Name: "Japanese with US keyboard", ID: "nacl_mozc_us", ShortLabel: "あ", HandwritingLanguage: LanguageJa, VoiceLanguage: LanguageJa, }
JapaneseWithUSKeyboard represents the input method of Japanese with US keyboard.
var Kannada = InputMethod{ Name: "Kannada", ID: "kn-t-i0-und", HandwritingLanguage: LanguageKn, VoiceLanguage: LanguageKn, }
Kannada represents the input method of Kannada.
var Korean = InputMethod{ Name: "Korean", ID: "ko-t-i0-und", ShortLabel: "한", HandwritingLanguage: LanguageKo, VoiceLanguage: LanguageKo, }
Korean represents the input method of Korean.
var Malayalam = InputMethod{ Name: "Malayalam", ID: "ml-t-i0-und", HandwritingLanguage: LanguageMl, VoiceLanguage: LanguageMl, }
Malayalam represents the input method of Malayalam.
var Marathi = InputMethod{ Name: "Marathi", ID: "mr-t-i0-und", HandwritingLanguage: LanguageMr, VoiceLanguage: LanguageMr, }
Marathi represents the input method of Marathi.
var NepaliTransliteration = InputMethod{ Name: "NepaliTransliteration", ID: "ne-t-i0-und", HandwritingLanguage: LanguageNe, VoiceLanguage: LanguageNe, }
NepaliTransliteration represents the input method of Nepali transliteration.
var Odia = InputMethod{ Name: "Odia", ID: "or-t-i0-und", HandwritingLanguage: LanguageOr, VoiceLanguage: LanguageOr, }
Odia represents the input method of Odia.
var PersianTransliteration = InputMethod{ Name: "PersianTransliteration", ID: "fa-t-i0-und", HandwritingLanguage: LanguageFa, VoiceLanguage: LanguageFa, }
PersianTransliteration represents the input method of Persian transliteration.
var Punjabi = InputMethod{ Name: "Punjabi", ID: "pa-t-i0-und", HandwritingLanguage: LanguagePa, VoiceLanguage: LanguagePa, }
Punjabi represents the input method of Punjabi.
var Sanskrit = InputMethod{ Name: "Sanskrit", ID: "sa-t-i0-und", HandwritingLanguage: LanguageSa, VoiceLanguage: LanguageSa, }
Sanskrit represents the input method of Sanskrit.
var SpanishSpain = InputMethod{ Name: "Spanish (Spain)", ID: "xkb:es::spa", ShortLabel: "ES", HandwritingLanguage: LanguageEs, VoiceLanguage: LanguageEs, }
SpanishSpain represents the input method of Spanish (Spain).
var Swedish = InputMethod{ Name: "Swedish", ID: "xkb:se::swe", ShortLabel: "SE", HandwritingLanguage: LanguageSv, VoiceLanguage: LanguageSv, }
Swedish represents the input method of Swedish.
var Tamil = InputMethod{ Name: "Tamil", ID: "ta-t-i0-und", HandwritingLanguage: LanguageTa, VoiceLanguage: LanguageTa, }
Tamil represents the input method of Tamil.
var Telugu = InputMethod{ Name: "Telugu", ID: "te-t-i0-und", HandwritingLanguage: LanguageTe, VoiceLanguage: LanguageTe, }
Telugu represents the input method of Telugu.
var Urdu = InputMethod{ Name: "Urdu", ID: "ur-t-i0-und", HandwritingLanguage: LanguageUr, VoiceLanguage: LanguageUr, }
Urdu represents the input method of Urdu.
Functions ¶
func AddAndSetInputMethod ¶
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 ¶
AddInputMethod adds the IME identified by imeID via chorme.languageSettingsPrivate.addInputMethod API.
func CurrentInputMethod ¶
CurrentInputMethod returns the ID of current IME obtained via chrome.inputMethodPrivate.getCurrentInputMethod API.
func DisableLanguage ¶
DisableLanguage disables the given language via chrome.languageSettingsPrivate.disableLanguage API.
func EnableLanguage ¶
EnableLanguage enables the given language via chrome.languageSettingsPrivate.enableLanguage API.
func Prefix ¶
Prefix returns the prefix of the default IME extension, depending on whether the build is Chrome (official build) or Chromium.
func RemoveInputMethod ¶
RemoveInputMethod removes the IME identified by imeID via chorme.languageSettingsPrivate.removeInputMethod API.
func SetCurrentInputMethod ¶
SetCurrentInputMethod sets the current input method to the IME identified imeID via chrome.inputMethodPrivate.setCurrentInputMethod API. It also waits 10s for new IME warming up.
func SetCurrentInputMethodAndWaitWarmUp ¶
func SetCurrentInputMethodAndWaitWarmUp(ctx context.Context, tconn *chrome.TestConn, imeID string, warmUpTime time.Duration) error
SetCurrentInputMethodAndWaitWarmUp sets the current input method to the IME identified imeID via chrome.inputMethodPrivate.setCurrentInputMethod API.
func WaitForInputMethodActivated ¶
func WaitForInputMethodActivated(ctx context.Context, tconn *chrome.TestConn, imeID string, warmUpTime time.Duration) error
WaitForInputMethodActivated waits for expected input method and warming up.
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.
Types ¶
type AutoCorrectionLevel ¶
type AutoCorrectionLevel int
AutoCorrectionLevel describes the auto correction level of an input method.
const ( AutoCorrectionOff AutoCorrectionLevel = iota AutoCorrectionModest AutoCorrectionProgressive )
Available auto correction levels.
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". ShortLabel string // The short label displayed in VK language menu & System IME tray to represent the input method. HandwritingLanguage Language // The language for handwriting. VoiceLanguage Language // The language for voice dictation. }
InputMethod represents an input method.
func ActiveInputMethod ¶
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) ResetSettings ¶
func (im InputMethod) ResetSettings(tconn *chrome.TestConn) action.Action
ResetSettings empties IME settings to reset.
func (InputMethod) SetPKAutoCorrection ¶
func (im InputMethod) SetPKAutoCorrection(tconn *chrome.TestConn, acLevel AutoCorrectionLevel) action.Action
SetPKAutoCorrection whether enables or disables the physical keyboard auto correction.
func (InputMethod) SetSettings ¶
func (im InputMethod) SetSettings(tconn *chrome.TestConn, settings map[string]interface{}) action.Action
SetSettings changes the IME setting via chrome api. `chrome.inputMethodPrivate.setSettings(
"xkb:us::eng", { "physicalKeyboardAutoCorrectionLevel": 1})`,
Note: Settings change won't take effect until the next input session. e.g. focus on a text field, or change input method. Live setting change is not supported because it never happens in a real user environment.
func (InputMethod) SetVKAutoCorrection ¶
func (im InputMethod) SetVKAutoCorrection(tconn *chrome.TestConn, acLevel AutoCorrectionLevel) action.Action
SetVKAutoCorrection whether enables or disables the physical keyboard auto correction.
func (InputMethod) SetVKEnableCapitalization ¶
func (im InputMethod) SetVKEnableCapitalization(tconn *chrome.TestConn, isEnabled bool) action.Action
SetVKEnableCapitalization whether enables or disables auto capitalization.
func (InputMethod) String ¶
func (im InputMethod) String() string
String returns the key representative string content of the input method.
func (InputMethod) WaitUntilActivated ¶
func (im InputMethod) WaitUntilActivated(tconn *chrome.TestConn) action.Action
WaitUntilActivated waits until the certain input method to be activated.
func (InputMethod) WaitUntilInstalled ¶
func (im InputMethod) WaitUntilInstalled(tconn *chrome.TestConn) action.Action
WaitUntilInstalled waits for the input method to be installed.
func (InputMethod) WaitUntilRemoved ¶
func (im InputMethod) WaitUntilRemoved(tconn *chrome.TestConn) action.Action
WaitUntilRemoved waits for the input method to be removed.
type Language ¶
type Language string
Language represents the handwriting/voice language for an input method.
const ( LanguageAr Language = "Arabic" LanguageCa Language = "Catalan" LanguageEl Language = "Greek" LanguageEn Language = "English" LanguageEs Language = "Spanish" LanguageFa Language = "Persian" LanguageFr Language = "French" LanguageGu Language = "Gujarati" LanguageHi Language = "Hindi" LanguageJa Language = "Japanese" LanguageKn Language = "Kannada" LanguageKo Language = "Korean" LanguageMl Language = "Malayalam" LanguageMr Language = "Marathi" LanguageNe Language = "Nepali" LanguageOr Language = "Odia" LanguagePa Language = "Punjabi" LanguageSa Language = "Sanskrit" LanguageSv Language = "Swedish" LanguageTa Language = "Tamil" LanguageTe Language = "Telugu" LanguageUr Language = "Urdu" LanguageYueHant Language = "Traditional Cantonese" LanguageZhHans Language = "Simplified Chinese" LanguageZhHant Language = "Traditional Chinese" )
List of languages, names are defined based on ISO 639.