How To Change Ibus Input Method In Python?
I am writing a Vim plugin to set iBus engines and input methods. So far I can change the engines with the code below: function! im#setEngine(name) python << EOF try: impor
Solution 1:
Reading the ibus library code I found an acceptable solution:
function! im#setInputMode(mode)
python << EOFtry:
importibus,dbus,vimbus = ibus.Bus()
conn = bus.get_dbusconn().get_object(ibus.common.IBUS_SERVICE_IBUS, bus.current_input_contxt())
ic = dbus.Interface(conn, dbus_interface=ibus.common.IBUS_IFACE_INPUT_CONTEXT)
mode = vim.eval("a:mode")
ic.PropertyActivate("InputMode." + mode, ibus.PROP_STATE_CHECKED)
exceptException, e:
print "FailedtoconnecttoiBus"
printeEOFendfunction
This method allows me to change the input method of iBus by passing it a name like:
callim#setInputMode("Hiragana")
Unfortunately the input method name depends on the engine being used. For example for mozc I need to set it to "Direct" while for anthy I have to use "WideLatin" in order get correct input in vim Normal Mode.
If someone knows a way to query the iBus engines to get a list of supported InputMode would be great. Also a way to query the engine for the current set InputMethod would help too.
Post a Comment for "How To Change Ibus Input Method In Python?"