From: Kenichi H. <ha...@m1...> - 2004-11-03 23:59:02
|
In article <20041103053146.GA3669%ss...@sh...>, Seiichi SATO <ss...@sh...> writes: > I tested minput_toggle() with the following code: > minput_toggle(ic); > if (!ic->active) { > printf("length of preedit text: %d\n", mtext_len(ic->preedit)); > } > The result of this code is "length of preedit text: 1" after > msymbol("a") was through minput_filter(). If preedit text was > cleared by minput_toggle(), I think the length should be 0. It seems that you are using minput_default_driver without adding any callback functions. In that case, the above result is correct (i.e. ic->preedit is not cleard). It's completely under the control of a programmer how to treat `toggle' action. The default is just toggle ic->active flag. So, when you toggle it again, you can restart inputting from exactly the same state as before (i.e. typing 'k', toggle-off, toggle-on, typing 'a' will yield 'か'). If you want to clear ic->preedit, you must register a callback function to do that, or you must do that by yourself. In both cases, calling minput_filter with KEY as Mnil is a correct way to do that because key Mnil is never handled in an input method, thus preedit text in ic->predit is moved to ic->produced, and state if the input method is set back to initial one. > I modified above code as below and got an expected result. > minput_filter(ic, Mnil, Mnil); /* <-- added */ > minput_toggle(ic); > if (!ic->active) { > printf("length of preedit text: %d\n", mtext_len(ic->preedit)); > } > Am I using minput_filter() and minput_toggle() correctly? Yes, and if you want to get the last preedit text, get it from ic->preedit before the call of minput_filter, or get it from ic->produced after the call of minput_filter, or get it by calling minput_lookup after the call of minput_filter. If you want to discard the preedit text, you have to do nothing. --- Ken'ichi HANDA ha...@m1... |