From: handa Date: Mon, 15 Nov 2004 12:00:21 +0000 (+0000) Subject: (find_candidates_group): If INDEX is -1, find the last X-Git-Tag: REL-1-2-0~86 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=48bb8f8260bfbd9989e6435f5a517e99500d03bc;p=m17n%2Fm17n-lib.git (find_candidates_group): If INDEX is -1, find the last candidate group. (take_action_list): If the previous of the first candidate is requested, select the last candidate. --- diff --git a/src/input.c b/src/input.c index 8334543..20b9184 100644 --- a/src/input.c +++ b/src/input.c @@ -876,6 +876,11 @@ shift_state (MInputContext *ic, MSymbol state_name) } } +/* Find a candidate group that contains a candidate number INDEX from + PLIST. Set START_INDEX to the first candidate number of the group, + END_INDEX to the last candidate number plus 1, GROUP_INDEX to the + candidate group number if they are non-NULL. If INDEX is -1, find + the last candidate group. */ static MPlist * find_candidates_group (MPlist *plist, int index, @@ -889,7 +894,8 @@ find_candidates_group (MPlist *plist, int index, len = mtext_nchars (MPLIST_MTEXT (plist)); else len = mplist_length (MPLIST_PLIST (plist)); - if (i + len > index) + if (index < 0 ? MPLIST_TAIL_P (MPLIST_NEXT (plist)) + : i + len > index) { if (start_index) *start_index = i; @@ -1119,9 +1125,14 @@ take_action_list (MInputContext *ic, MPlist *action_list) end - start - 1, MPLIST_SYMBOL (args), NULL) : MPLIST_INTEGER (args))); - if (idx < 0 - || (idx >= end - && MPLIST_TAIL_P (MPLIST_NEXT (group)))) + if (idx < 0) + { + find_candidates_group (mtext_property_value (prop), -1, + NULL, &end, NULL); + idx = end - 1; + } + else if (idx >= end + && MPLIST_TAIL_P (MPLIST_NEXT (group))) idx = 0; } else