Seiichi SATO
ssato****@sh*****
2004年 9月 27日 (月) 08:08:25 JST
佐藤精一です。 m17n-*-* で候補一覧が正しく取得できないようなので 修正してみました。 gedit と m17n-{ja-anthy,zh-py} で動作を確認しました。 # m17nlib.scm は m17nlib.c の変更に合わせただけなので # 不十分かも... -- Seiichi -------------- next part -------------- Index: scm/m17nlib.scm =================================================================== --- scm/m17nlib.scm (revision 1296) +++ scm/m17nlib.scm (working copy) @@ -52,11 +52,15 @@ (let* ((c (find-context id)) (mc (context-data c)) (mid (m17nlib-context-id mc)) + (max (m17nlib-lib-get-nr-candidates mid)) (showing-candidate? (m17nlib-context-showing-candidate mc))) (if showing-candidate? (if (m17nlib-lib-candidate-show? mid) (begin - (im-select-candidate mid + (im-activate-candidate-selector + id + max m17nlib-candidate-max) + (im-select-candidate id (m17nlib-lib-get-candidate-index mid))) (begin (m17nlib-context-set-showing-candidate! mc #f) @@ -65,7 +69,7 @@ (begin (im-activate-candidate-selector id - 5 m17nlib-candidate-max) + max m17nlib-candidate-max) (im-select-candidate id (m17nlib-lib-get-candidate-index mid)) (m17nlib-context-set-showing-candidate! mc #t))) ))));nothing to do Index: uim/m17nlib.c =================================================================== --- uim/m17nlib.c (revision 1296) +++ uim/m17nlib.c (working copy) @@ -619,9 +619,39 @@ } static LISP +get_nr_candidates(LISP id_) +{ + MPlist *group; + MPlist *elm; + int result = 0; + int id = get_c_int(id_); + MInputContext *ic = ic_array[id].mic; + + if(!ic || !ic->candidate_list) + return siod_false_value(); + + group = ic->candidate_list; + + while(mplist_value(group) != Mnil) { + if(mplist_key(group) == Mtext) { + for (; mplist_key(group) != Mnil; group = mplist_next(group)) { + result += mtext_len(mplist_value(group)); + } + } else { + for (; mplist_key(group) != Mnil; group = mplist_next(group)) { + result += mplist_length(mplist_value(group)); + } + } + } + + return intcons(result); +} + +static LISP get_nth_candidate(LISP id_, LISP nth_) { MText *produced = NULL; /* Quiet gcc */ + MPlist *group; MPlist *elm; int i; unsigned char *buf = NULL; /* Quiet gcc */ @@ -633,15 +663,31 @@ if(!ic || !ic->candidate_list) return NIL; - elm = mplist_value(ic->candidate_list); + group = ic->candidate_list; - for (i=0; mplist_key(elm) != Mnil; elm = mplist_next(elm),i++) { - if(i == nth) { - produced = mplist_value(elm); - buf = convert_mtext2str(produced); - /* m17n_object_unref(produced); */ + if(mplist_key(group) == Mtext) { + for (i=0; mplist_key(group) != Mnil; group = mplist_next(group)) { + int j; + for (j=0; j < mtext_len(mplist_value(group)); j++, i++) { + if(i == nth) { + produced = mtext(); + mtext_cat_char(produced, mtext_ref_char(mplist_value(group), j)); + buf = convert_mtext2str(produced); + m17n_object_unref(produced); + } + } } + } else { + for (i=0; mplist_key(group) != Mnil; group = mplist_next(group)) { + for (elm = mplist_value(group); mplist_key(elm) != Mnil; elm = mplist_next(elm),i++) { + if(i == nth) { + produced = mplist_value(elm); + buf = convert_mtext2str(produced); + } + } + } } + if(!buf) { return strcons(0, ""); } else { @@ -691,6 +737,7 @@ init_subr_1("m17nlib-lib-get-commit-string", get_commit_string); init_subr_1("m17nlib-lib-commit", commit); init_subr_1("m17nlib-lib-candidate-show?", candidate_showp); + init_subr_1("m17nlib-lib-get-nr-candidates", get_nr_candidates); init_subr_2("m17nlib-lib-get-nth-candidate", get_nth_candidate); init_subr_1("m17nlib-lib-get-candidate-index", get_candidate_index); }