[Uim] question about function uim_reset_context() (was: uim 0.4.5 released)

TOKUNAGA Hiroyuki tkng at xem.jp
Fri Dec 17 22:57:19 EET 2004


Hi, 

On Thu, 16 Dec 2004 18:39:21 +0100
Mike FABIAN <mfabian at suse.de> wrote:

> TOKUNAGA Hiroyuki <tkng at xem.jp> さんは書きました:
> 
> >  uim-0.4.5 is now available for download at:
> 
> I have a question concerning the function uim_reset_context() in
> uim-0.4.5 svn revision 1650. The header file uim.h says
> about this function:
> 
>     /**
>      * Reset input context.
>      * Pending string might be committed and preedit string might be
>      erased. (Not yet implemented so)*
>      * @param uc input context to reset
>      */
>     void
>     uim_reset_context(uim_context uc);
> 
> I added a call to this function from scim-uim to the focus_out()
> method
> 
>     UIMInstance::focus_out ()
>     {
>         SCIM_DEBUG_IMENGINE(2) << "focus_out.\n";
> 
>        // commit pending preedit strings:
>        uim_reset_context(m_uc); 
> 
>     }
> 
> which is called when the input method is switched off (with
> Shift+Space or Control+Space) or when the focus is moved to a
> different application.
>
> I tried this because I wanted to commit the current preedit string
> when the input method is switched off.  I believe this is more natural
> behavior. And it behaves like this when uim is used via uim-xim,
> GTK_IM_MODULE or QT_IM_MODULE. In these three cases, the current
> preedit string is committed when the input method is switched off.
> 
> Only when using scim-uim it is different. With scim-uim, currently the
> preedit string disappears when switching off the input method but it
> is remembered and appears again when the input method is switched on
> again. It is quite confusing when a previously edited preedit string
> suddenly appears again after one has typed Latin letters for a
> while.
> 
> So I wanted to make scim-uim behave like the other variants
> of using uim and added the call to uim_reset_context(m_uc)
> to UIMInstance::focus_out ().
> 
> Unfortunately this doesn't fix the problem.  After applying this
> change, the preedit string still isn't committed when switching off
> the input method. And it still comes back when switching the input
> method on although the old preedit string disappears as soon as one
> continues typing. I.e. effectively the old preedit string is
> discarded, it only briefly appears again after switching the input
> method on again and is then immediately discarded when the first new
> key is typed.
> 
> Probably the reason is that uim_reset_context() isn't yet
> completely implemented, just as the comment in uim.h says.
> What must be added to uim_reset_context() to make it really
> commit the pending preedit string and then erase it?
> Currently, uim_reset_context() looks like this:
> 
>     void
>     uim_reset_context(uim_context uc)
>     {
>        UIM_EVAL_FSTRING1(uc, "(reset-handler %d)", uc->id);
> 
>        /* delete all preedit segments */
>        uim_release_preedit_segments(uc);
>     }
> 
> I tried to add something like
> 
>     uc->commit_cb(uc->ptr, s);
> 
> but apparently that doesn't work and I don't know how to access
> the current preedit string to give it as an argument to commit_cb().
> The structure uim_context_ in context.h doesn't seem
> to contain the complete preedit string, only preedit segments.
> 
> How does this work in uim?

First, what you want to do is 'commit when switch off', not 'commit when
focus out', OK?

Personally I dislike the idea of on/off mode, but I can understand that.
I agree with you, preedit strings should be committed when input method
is disabled. But I don't think preedit strings should 'always' be
commited when input method is 'focused out'. That's only my opinion, you
may not agree.

In this mail, I want to write 2 things, the most ugly hack to commit
preedit strings and about semantic of reset.

The most ugly hack is that:

   if(there_is_preedit)
      rv = uim_press_key(context, UKey_Return, NULL);

instead of calling reset function. In most case, this will work. You
know, uim doesn't have explicit commit function. If we want to add the
explicit commit function to uim, we have to extend all input methods of
uim. Becausein uim, preedit strings != commited strings and there is no
way to know commit strings until commit_cb is called.

Below from this line is about the future of uim.

* semantic of reset

Determination of semancic of reset is difficult problem, so uim doesn't
have the policy about reset function (for now). A input method may
commit preedit strings, then may erase preedit strings. Another input
method may hold preedit strings (do nothing). For now, most of input
methods don't implement reset function. Obviously we should define the
policy about reset functionality.

Now I'm thinking that
 - Preedit string should be commited when reset function called
 - Focus out should not call reset function
 - Instead of caling reset function, focus in/out function of input
method should be called. 

If you agree/disagree this, please reply.


My explanation would not be enough, but that's my best for now. (I'm
very sleepy, now 5:00 A.M. in Japan... 睡眠不足はいい仕事の敵だ!) So if
you have any question, please send a mail to me.


Regards,

-- 
TOKUNAGA Hiroyuki
http://kodou.net/



More information about the uim mailing list