X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Finput.c;h=be065bdf7128b28d897d33983fdb348841b52919;hb=cecc80dea0a192be7f5d7661c6298eecd7f2a5c6;hp=091e7f59351c72fc64f6b4ff70e6658ab4bdf933;hpb=2d0576fec7defd57b47218b273d7a3214ca438d1;p=m17n%2Fm17n-lib.git diff --git a/src/input.c b/src/input.c index 091e7f5..be065bd 100644 --- a/src/input.c +++ b/src/input.c @@ -153,7 +153,7 @@ #include #endif -#include "m17n-gui.h" +#include "m17n.h" #include "m17n-misc.h" #include "internal.h" #include "mtext.h" @@ -163,7 +163,7 @@ #include "database.h" #include "charset.h" -static int mdebug_mask = MDEBUG_INPUT; +static int mdebug_flag = MDEBUG_INPUT; static int fully_initialized; @@ -174,7 +174,7 @@ static MSymbol Mtitle, Mmacro, Mmodule, Mstate, Minclude; /** Symbols for actions. */ static MSymbol Minsert, Mdelete, Mmark, Mmove, Mpushback, Mundo, Mcall, Mshift; -static MSymbol Mselect, Mshow, Mhide, Mcommit, Munhandle; +static MSymbol Mselect, Mshow, Mhide, Mcommit, Munhandle, Mpop; static MSymbol Mset, Madd, Msub, Mmul, Mdiv, Mequal, Mless, Mgreater; static MSymbol Mless_equal, Mgreater_equal; static MSymbol Mcond; @@ -402,6 +402,7 @@ fully_initialize () Mmove = msymbol ("move"); Mmark = msymbol ("mark"); Mpushback = msymbol ("pushback"); + Mpop = msymbol ("pop"); Mundo = msymbol ("undo"); Mcall = msymbol ("call"); Mshift = msymbol ("shift"); @@ -552,8 +553,6 @@ get_preceding_char (MInputContext *ic, int pos) len = mtext_nchars (ic_info->preceding_text); if (pos <= len) return mtext_ref_char (ic_info->preceding_text, len - pos); - if (ic->produced && mtext_len (ic->produced) >= pos - len) - return mtext_ref_char (ic->produced, len + mtext_len (ic->produced) - pos); } mt = get_surrounding_text (ic, - pos); if (! mt) @@ -566,6 +565,8 @@ get_preceding_char (MInputContext *ic, int pos) M17N_OBJECT_UNREF (ic_info->preceding_text); ic_info->preceding_text = mt; } + else + M17N_OBJECT_UNREF (mt); } else ic_info->preceding_text = mt; @@ -598,6 +599,8 @@ get_following_char (MInputContext *ic, int pos) M17N_OBJECT_UNREF (ic_info->following_text); ic_info->following_text = mt; } + else + M17N_OBJECT_UNREF (mt); } else ic_info->following_text = mt; @@ -656,7 +659,12 @@ integer_value (MInputContext *ic, MPlist *arg, MPlist **value, int surrounding) return get_preceding_char (ic, 0); pos = ic->cursor_pos + pos; if (pos < 0) - return get_preceding_char (ic, - pos); + { + if (ic->produced && mtext_len (ic->produced) + pos >= 0) + return mtext_ref_char (ic->produced, + mtext_len (ic->produced) + pos); + return get_preceding_char (ic, - pos); + } if (pos >= len) return get_following_char (ic, pos - len + 1); } @@ -816,7 +824,7 @@ parse_action_list (MPlist *plist, MPlist *macros) } else if (MPLIST_PLIST_P (pl)) { - MPLIST_DO (pl, pl) + MPLIST_DO (pl, MPLIST_PLIST (pl)) { if (MPLIST_PLIST_P (pl)) { @@ -908,7 +916,8 @@ parse_action_list (MPlist *plist, MPlist *macros) MERROR (MERROR_IM, -1); } else if (action_name == Mshow || action_name == Mhide - || action_name == Mcommit || action_name == Munhandle) + || action_name == Mcommit || action_name == Munhandle + || action_name == Mpop) ; else if (action_name == Mcond) { @@ -1061,34 +1070,48 @@ load_branch (MInputMethodInfo *im_info, MPlist *plist, MIMMap *map) if (branch_actions) M17N_OBJECT_REF (branch_actions); } - else if (im_info->maps - && (plist = (MPlist *) mplist_get (im_info->maps, map_name))) + else if (im_info->maps) { - MPLIST_DO (plist, plist) + plist = (MPlist *) mplist_get (im_info->maps, map_name); + if (! plist && im_info->configured_vars) { - MPlist *keylist, *map_actions; + MPlist *p = mplist__assq (im_info->configured_vars, map_name); - if (! MPLIST_PLIST_P (plist)) - MERROR (MERROR_IM, -1); - keylist = MPLIST_PLIST (plist); - map_actions = MPLIST_NEXT (keylist); - if (MPLIST_SYMBOL_P (keylist)) + if (p && MPLIST_PLIST_P (p)) + { + p = MPLIST_NEXT (MPLIST_NEXT (MPLIST_NEXT (MPLIST_PLIST (p)))); + if (MPLIST_SYMBOL_P (p)) + plist = mplist_get (im_info->maps, MPLIST_SYMBOL (p)); + } + } + if (plist) + { + MPLIST_DO (plist, plist) { - MSymbol command = MPLIST_SYMBOL (keylist); - MPlist *pl; + MPlist *keylist, *map_actions; - if (MFAILP (command != Mat_reload)) - continue; - pl = resolve_command (im_info->configured_cmds, command); - if (MFAILP (pl)) - continue; - MPLIST_DO (pl, pl) - load_translation (map, pl, map_actions, branch_actions, + if (! MPLIST_PLIST_P (plist)) + MERROR (MERROR_IM, -1); + keylist = MPLIST_PLIST (plist); + map_actions = MPLIST_NEXT (keylist); + if (MPLIST_SYMBOL_P (keylist)) + { + MSymbol command = MPLIST_SYMBOL (keylist); + MPlist *pl; + + if (MFAILP (command != Mat_reload)) + continue; + pl = resolve_command (im_info->configured_cmds, command); + if (MFAILP (pl)) + continue; + MPLIST_DO (pl, pl) + load_translation (map, pl, map_actions, branch_actions, + im_info->macros); + } + else + load_translation (map, keylist, map_actions, branch_actions, im_info->macros); } - else - load_translation (map, keylist, map_actions, branch_actions, - im_info->macros); } } @@ -1439,14 +1462,12 @@ update_custom_info (void) if (! MPLIST_SYMBOL_P (p)) continue; name = MPLIST_SYMBOL (p); - if (language == Mnil || name == Mnil) - continue; p = MPLIST_NEXT (p); if (MPLIST_TAIL_P (p)) extra = Mnil; else if (MPLIST_SYMBOL_P (p)) extra = MPLIST_SYMBOL (p); - else + if (language == Mnil || (name == Mnil && extra == Mnil)) continue; im_info = new_im_info (NULL, language, name, extra, im_custom_list); load_im_info (im_data, im_info); @@ -1472,6 +1493,8 @@ update_global_info (void) { MDatabase *mdb = mdatabase_find (Minput_method, Mt, Mnil, Mglobal); + if (! mdb) + return -1; global_info = new_im_info (mdb, Mt, Mnil, Mglobal, im_info_list); } if (! global_info->mdb @@ -1572,6 +1595,19 @@ reload_im_info (MInputMethodInfo *im_info) fini_im_info (im_info); load_im_info (plist, im_info); M17N_OBJECT_UNREF (plist); + if (! im_info->cmds) + im_info->cmds = mplist (); + if (! im_info->vars) + im_info->vars = mplist (); + if (! im_info->title) + { + MSymbol name = im_info->name; + + im_info->title = (name == Mnil ? mtext () + : mtext_from_data (MSYMBOL_NAME (name), + MSYMBOL_NAMELEN (name), + MTEXT_FORMAT_US_ASCII)); + } return 1; } @@ -1620,7 +1656,7 @@ check_description (MPlist *plist) { M17N_OBJECT_UNREF (mt); mt = mtext__from_data (translated, strlen (translated), - MTEXT_FORMAT_UTF_8, 0); + MTEXT_FORMAT_UTF_8, 1); } } #endif @@ -1722,54 +1758,53 @@ config_command (MPlist *plist, MPlist *global_cmds, MPlist *custom_cmds, MPlist *config_cmds) { MPlist *global = NULL, *custom = NULL, *config = NULL; - MSymbol name; + MSymbol name = MPLIST_SYMBOL (plist); MSymbol status; - MPlist *description = NULL, *keyseq; + MPlist *description, *keyseq; + + if (global_cmds && (global = mplist__assq (global_cmds, name))) + global = MPLIST_NEXT (MPLIST_PLIST (global)); - name = MPLIST_SYMBOL (plist); plist = MPLIST_NEXT (plist); if (MPLIST_MTEXT_P (plist) || MPLIST_PLIST_P (plist)) - description = plist; - else if (global_cmds && ((global = mplist__assq (global_cmds, name)))) - description = global = MPLIST_NEXT (MPLIST_PLIST (global)); - if (MPLIST_TAIL_P (plist)) { - if (! global - && global_cmds && ((global = mplist__assq (global_cmds, name)))) - global = MPLIST_NEXT (MPLIST_PLIST (global)); - if (global) - { - keyseq = MPLIST_NEXT (global); - status = Minherited; - } - else - { - keyseq = plist; - status = Mnil; - } + description = plist; + plist = MPLIST_NEXT (plist); } else { - keyseq = MPLIST_NEXT (plist); + description = global; + if (! MPLIST_TAIL_P (plist)) + plist = MPLIST_NEXT (plist); + } + if (MPLIST_TAIL_P (plist) && global) + { + keyseq = MPLIST_NEXT (global); + status = Minherited; + } + else + { + keyseq = plist; status = Mnil; } if (config_cmds && (config = mplist__assq (config_cmds, name))) { + status = Mconfigured; config = MPLIST_NEXT (MPLIST_PLIST (config)); if (! MPLIST_TAIL_P (config)) - { - keyseq = MPLIST_NEXT (config); - status = Mconfigured; - } + keyseq = config; } else if (custom_cmds && (custom = mplist__assq (custom_cmds, name))) { - custom = MPLIST_NEXT (MPLIST_PLIST (custom)); - if (! MPLIST_TAIL_P (custom)) + MPlist *this_keyseq = MPLIST_NEXT (MPLIST_NEXT (MPLIST_PLIST (custom))); + + if (MPLIST_TAIL_P (this_keyseq)) + mplist__pop_unref (custom); + else { - keyseq = MPLIST_NEXT (custom); status = Mcustomized; + keyseq = this_keyseq; } } @@ -1889,7 +1924,7 @@ check_variable_value (MPlist *val, MPlist *global) } } - return (MPLIST_TAIL_P (valids)); + return (! MPLIST_TAIL_P (valids)); } /* Load variable defitions from PLIST into IM_INFO->vars. @@ -2047,21 +2082,24 @@ config_variable (MPlist *plist, MPlist *global_vars, MPlist *custom_vars, if (config_vars && (config = mplist__assq (config_vars, name))) { + status = Mconfigured; config = MPLIST_NEXT (MPLIST_PLIST (config)); if (! MPLIST_TAIL_P (config)) { - value = MPLIST_NEXT (config); + value = config; if (MFAILP (check_variable_value (value, global ? global : plist))) value = NULL; - status = Mconfigured; } } else if (custom_vars && (custom = mplist__assq (custom_vars, name))) { - custom = MPLIST_NEXT (MPLIST_PLIST (custom)); - if (! MPLIST_TAIL_P (custom)) + MPlist *this_value = MPLIST_NEXT (MPLIST_NEXT (MPLIST_PLIST (custom))); + + if (MPLIST_TAIL_P (this_value)) + mplist__pop_unref (custom); + else { - value = MPLIST_NEXT (custom); + value = this_value; if (MFAILP (check_variable_value (value, global ? global : plist))) value = NULL; status = Mcustomized; @@ -2288,7 +2326,7 @@ load_im_info (MPlist *plist, MInputMethodInfo *im_info) static int take_action_list (MInputContext *ic, MPlist *action_list); -static void preedit_commit (MInputContext *ic); +static void preedit_commit (MInputContext *ic, int need_prefix); static void shift_state (MInputContext *ic, MSymbol state_name) @@ -2316,7 +2354,15 @@ shift_state (MInputContext *ic, MSymbol state_name) state = (MIMState *) MPLIST_VAL (im_info->states); } - MDEBUG_PRINT1 ("\n [IM] (shift %s)", MSYMBOL_NAME (state->name)); + if (MDEBUG_FLAG ()) + { + if (orig_state) + MDEBUG_PRINT2 ("\n [IM] [%s] (shift %s)\n", + MSYMBOL_NAME (orig_state->name), + MSYMBOL_NAME (state->name)); + else + MDEBUG_PRINT1 (" (shift %s)\n", MSYMBOL_NAME (state->name)); + } /* Enter the new state. */ ic_info->state = state; @@ -2325,7 +2371,7 @@ shift_state (MInputContext *ic, MSymbol state_name) if (state == (MIMState *) MPLIST_VAL (im_info->states) && orig_state) /* We have shifted to the initial state. */ - preedit_commit (ic); + preedit_commit (ic, 0); mtext_cpy (ic_info->preedit_saved, ic->preedit); ic_info->state_pos = ic->cursor_pos; if (state != orig_state) @@ -2348,7 +2394,8 @@ shift_state (MInputContext *ic, MSymbol state_name) if (ic_info->map == ic_info->state->map && ic_info->map->map_actions) { - MDEBUG_PRINT (" init-actions:"); + MDEBUG_PRINT1 (" [IM] [%s] init-actions:", + MSYMBOL_NAME (state->name)); take_action_list (ic, ic_info->map->map_actions); } } @@ -2432,9 +2479,15 @@ preedit_insert (MInputContext *ic, int pos, MText *mt, int c) int nchars = mt ? mtext_nchars (mt) : 1; if (mt) - mtext_ins (ic->preedit, pos, mt); + { + mtext_ins (ic->preedit, pos, mt); + MDEBUG_PRINT1 ("(\"%s\")", MTEXT_DATA (mt)); + } else - mtext_ins_char (ic->preedit, pos, c, 1); + { + mtext_ins_char (ic->preedit, pos, c, 1); + MDEBUG_PRINT1 ("('%c')", c); + } adjust_markers (ic, pos, pos, nchars); ic->preedit_changed = 1; } @@ -2470,7 +2523,7 @@ preedit_replace (MInputContext *ic, int from, int to, MText *mt, int c) static void -preedit_commit (MInputContext *ic) +preedit_commit (MInputContext *ic, int need_prefix) { MInputContextInfo *ic_info = (MInputContextInfo *) ic->info; int preedit_len = mtext_nchars (ic->preedit); @@ -2484,6 +2537,19 @@ preedit_commit (MInputContext *ic) mtext_put_prop_values (ic->preedit, 0, mtext_nchars (ic->preedit), Mcandidate_index, NULL, 0); mtext_cat (ic->produced, ic->preedit); + if (MDEBUG_FLAG ()) + { + int i; + + if (need_prefix) + MDEBUG_PRINT1 ("\n [IM] [%s]", + MSYMBOL_NAME (ic_info->state->name)); + MDEBUG_PRINT (" (commit"); + for (i = 0; i < mtext_nchars (ic->preedit); i++) + MDEBUG_PRINT1 (" U+%04X", mtext_ref_char (ic->preedit, i)); + MDEBUG_PRINT (")"); + } + mtext_reset (ic->preedit); mtext_reset (ic_info->preedit_saved); MPLIST_DO (p, ic_info->markers) @@ -2554,6 +2620,7 @@ update_candidate (MInputContext *ic, MTextProperty *prop, int idx) int ingroup_index = idx - start; MText *mt; + candidate_list = mplist_copy (candidate_list); if (MPLIST_MTEXT_P (group)) { mt = MPLIST_MTEXT (group); @@ -2572,6 +2639,7 @@ update_candidate (MInputContext *ic, MTextProperty *prop, int idx) to = from + mtext_nchars (mt); } mtext_put_prop (ic->preedit, from, to, Mcandidate_list, candidate_list); + M17N_OBJECT_UNREF (candidate_list); mtext_put_prop (ic->preedit, from, to, Mcandidate_index, (void *) idx); ic->cursor_pos = to; } @@ -2725,7 +2793,8 @@ get_candidate_list (MInputContextInfo *ic_info, MPlist *args) next = MPLIST_NEXT (next); } } - M17N_OBJECT_UNREF (plist); + if (charset) + M17N_OBJECT_UNREF (plist); plist = mplist (); len = mtext_nchars (mt); if (len <= column) @@ -2743,47 +2812,42 @@ get_candidate_list (MInputContextInfo *ic_info, MPlist *args) } M17N_OBJECT_UNREF (mt); } - else /* MPLIST_PLIST_P (plist) */ + else if (! MPLIST_TAIL_P (plist)) { - MPlist *pl = MPLIST_PLIST (plist), *p; - MPlist *next = MPLIST_NEXT (plist); - int j; + MPlist *tail = plist; + MPlist *new = mplist (); + MPlist *this = mplist (); + int count = 0; - if (MPLIST_TAIL_P (next)) - M17N_OBJECT_REF (pl); - else + MPLIST_DO (tail, tail) { - pl = mplist_copy (pl); - while (! MPLIST_TAIL_P (next)) - { - p = mplist_copy (MPLIST_PLIST (next)); - pl = mplist__conc (pl, p); - M17N_OBJECT_UNREF (p); - next = MPLIST_NEXT (next); - } - } - M17N_OBJECT_UNREF (plist); - plist = mplist (); - len = mplist_length (pl); - if (len <= column) - mplist_add (plist, Mplist, pl); - else - { - MPlist *p0 = pl; + MPlist *p = MPLIST_PLIST (tail); - for (i = 0; i < len; i += column) + MPLIST_DO (p, p) { - p = mplist (); - mplist_add (plist, Mplist, p); - M17N_OBJECT_UNREF (p); - for (j = 0; j < column && i + j < len; j++) + MText *mt = MPLIST_MTEXT (p); + + if (count == column) { - p = mplist_add (p, Mtext, MPLIST_VAL (p0)); - p0 = MPLIST_NEXT (p0); + mplist_add (new, Mplist, this); + M17N_OBJECT_UNREF (this); + this = mplist (); + count = 0; } + mplist_add (this, Mtext, mt); + count++; } } - M17N_OBJECT_UNREF (pl); + mplist_add (new, Mplist, this); + M17N_OBJECT_UNREF (this); + mplist_set (plist, Mnil, NULL); + MPLIST_DO (tail, new) + { + MPlist *elt = MPLIST_PLIST (tail); + + mplist_add (plist, Mplist, elt); + } + M17N_OBJECT_UNREF (new); } } @@ -2886,7 +2950,7 @@ take_action_list (MInputContext *ic, MPlist *action_list) MPlist *plist = get_candidate_list (ic_info, args); int len; - if (! plist) + if (! plist || (MPLIST_PLIST_P (plist) && MPLIST_TAIL_P (plist))) continue; if (MPLIST_MTEXT_P (plist)) { @@ -2894,6 +2958,8 @@ take_action_list (MInputContext *ic, MPlist *action_list) mtext_ref_char (MPLIST_MTEXT (plist), 0)); len = 1; } + else if (MPLIST_TAIL_P (MPLIST_PLIST (plist))) + continue; else { MText * mt = MPLIST_MTEXT (MPLIST_PLIST (plist)); @@ -2901,9 +2967,11 @@ take_action_list (MInputContext *ic, MPlist *action_list) preedit_insert (ic, ic->cursor_pos, mt, 0); len = mtext_nchars (mt); } + plist = mplist_copy (plist); mtext_put_prop (ic->preedit, ic->cursor_pos - len, ic->cursor_pos, Mcandidate_list, plist); + M17N_OBJECT_UNREF (plist); mtext_put_prop (ic->preedit, ic->cursor_pos - len, ic->cursor_pos, Mcandidate_index, (void *) 0); @@ -3126,6 +3194,11 @@ take_action_list (MInputContext *ic, MPlist *action_list) } } } + else if (name == Mpop) + { + if (ic_info->key_head < ic_info->used) + MLIST_DELETE1 (ic_info, keys, ic_info->key_head, 1); + } else if (name == Mcall) { MInputMethodInfo *im_info = (MInputMethodInfo *) ic->im->info; @@ -3144,8 +3217,8 @@ take_action_list (MInputContext *ic, MPlist *action_list) = (MIMExternalModule *) mplist_get (im_info->externals, module); if (external) - func = (MIMExternalFunc) mplist_get (external->func_list, - func_name); + func = ((MIMExternalFunc) + mplist_get_func (external->func_list, func_name)); } if (! func) continue; @@ -3293,11 +3366,11 @@ take_action_list (MInputContext *ic, MPlist *action_list) } else if (name == Mcommit) { - preedit_commit (ic); + preedit_commit (ic, 0); } else if (name == Munhandle) { - preedit_commit (ic); + preedit_commit (ic, 0); return -1; } else @@ -3357,8 +3430,8 @@ handle_key (MInputContext *ic) MSymbol alias = Mnil; int i; - MDEBUG_PRINT2 (" [IM] handle `%s' in state %s", - msymbol_name (key), MSYMBOL_NAME (ic_info->state->name)); + MDEBUG_PRINT2 (" [IM] [%s] handle `%s'", + MSYMBOL_NAME (ic_info->state->name), msymbol_name (key)); if (map->submaps) { @@ -3440,9 +3513,11 @@ handle_key (MInputContext *ic) { /* The above branch actions didn't change the state. */ - /* If MAP is the root map of the initial state, it means - that the current input method can not handle KEY. */ - if (map == ((MIMState *) MPLIST_VAL (im_info->states))->map) + /* If MAP is the root map of the initial state, and there + still exist an unhandled key, it means that the current + input method can not handle it. */ + if (map == ((MIMState *) MPLIST_VAL (im_info->states))->map + && ic_info->key_head < ic_info->used) { MDEBUG_PRINT (" unhandled\n"); return -1; @@ -3454,9 +3529,10 @@ handle_key (MInputContext *ic) current state. */ shift_state (ic, ic_info->state->name); } - else + else if (! map->branch_actions) { - /* MAP is the root map. Shift to the initial state. */ + /* MAP is the root map without any default branch + actions. Shift to the initial state. */ shift_state (ic, Mnil); } } @@ -3507,7 +3583,7 @@ init_ic_info (MInputContext *ic) { MIMExternalModule *external = MPLIST_VAL (plist); MIMExternalFunc func - = (MIMExternalFunc) mplist_get (external->func_list, Minit); + = (MIMExternalFunc) mplist_get_func (external->func_list, Minit); if (func) (func) (func_args); @@ -3536,7 +3612,7 @@ fini_ic_info (MInputContext *ic) { MIMExternalModule *external = MPLIST_VAL (plist); MIMExternalFunc func - = (MIMExternalFunc) mplist_get (external->func_list, Mfini); + = (MIMExternalFunc) mplist_get_func (external->func_list, Mfini); if (func) (func) (func_args); @@ -3594,8 +3670,20 @@ re_init_ic (MInputContext *ic, int reload) fini_ic_info (ic); if (reload) reload_im_info (im_info); + if (! im_info->states) + { + struct MIMState *state; + + M17N_OBJECT (state, free_state, MERROR_IM); + state->name = msymbol ("init"); + state->title = mtext__from_data ("ERROR!", 6, MTEXT_FORMAT_US_ASCII, 0); + MSTRUCT_CALLOC (state->map, MERROR_IM); + im_info->states = mplist (); + mplist_add (im_info->states, state->name, state); + } init_ic_info (ic); shift_state (ic, Mnil); + ic->status_changed = status_changed; ic->preedit_changed = preedit_changed; ic->cursor_pos_changed = cursor_pos_changed; @@ -3614,7 +3702,7 @@ open_im (MInputMethod *im) { MInputMethodInfo *im_info = get_im_info (im->language, im->name, Mnil, Mnil); - if (! im_info) + if (! im_info || ! im_info->states) MERROR (MERROR_IM, -1); im->info = im_info; @@ -3753,23 +3841,21 @@ filter (MInputContext *ic, MSymbol key, void *arg) /* If the current map is the root of the initial state, we should produce any preedit text in ic->produced. */ if (ic_info->map == ((MIMState *) MPLIST_VAL (im_info->states))->map) - preedit_commit (ic); + preedit_commit (ic, 1); if (mtext_nchars (ic->produced) > 0) { - MSymbol lang = msymbol_get (ic->im->language, Mlanguage); - - if (mdebug__flag & mdebug_mask) + if (MDEBUG_FLAG ()) { - MDEBUG_PRINT (" (produced"); + MDEBUG_PRINT1 ("\n [IM] [%s] (produced", + MSYMBOL_NAME (ic_info->state->name)); for (i = 0; i < mtext_nchars (ic->produced); i++) MDEBUG_PRINT1 (" U+%04X", mtext_ref_char (ic->produced, i)); MDEBUG_PRINT (")"); } - if (lang != Mnil) - mtext_put_prop (ic->produced, 0, mtext_nchars (ic->produced), - Mlanguage, ic->im->language); + mtext_put_prop (ic->produced, 0, mtext_nchars (ic->produced), + Mlanguage, ic->im->language); } if (ic_info->commit_key_head > 0) { @@ -3910,8 +3996,8 @@ minput__init () minput_default_driver.filter = filter; minput_default_driver.lookup = lookup; minput_default_driver.callback_list = mplist (); - mplist_put (minput_default_driver.callback_list, Minput_reset, - (void *) reset_ic); + mplist_put_func (minput_default_driver.callback_list, Minput_reset, + M17N_FUNC (reset_ic)); minput_driver = &minput_default_driver; fully_initialized = 0; @@ -4736,7 +4822,7 @@ minput_get_description (MSymbol language, MSymbol name) If $COMMAND is #Mnil, information about all commands is returned. - The return value is a @e well-formed plist (#m17nPlist) of this + The return value is a @e well-formed plist (@ref m17nPlist) of this format: @verbatim ((NAME DESCRIPTION STATUS [KEYSEQ ...]) ...) @@ -4748,7 +4834,7 @@ minput_get_description (MSymbol language, MSymbol name) @c STATUS is a symbol representing how the key assignment is decided. The value is #Mnil (the default key assignment), #Mcustomized (the - key assignment is customized by per-user configuration file), or + key assignment is customized by per-user customization file), or #Mconfigured (the key assignment is set by the call of minput_config_command ()). For a local command only, it may also be #Minherited (the key assignment is inherited from the @@ -4790,7 +4876,7 @@ minput_get_description (MSymbol language, MSymbol name) $COMMAND ¤¬ #Mnil ¤Î¾ì¹ç¤Ï¡¢¤¹¤Ù¤Æ¤Î¥³¥Þ¥ó¥É¤Ë´Ø¤¹¤ë¾ðÊó¤òÊÖ¤¹¡£ - Ìá¤êÃͤϰʲ¼¤Î·Á¼°¤Î @e well-formed plist (#m17nPlist) ¤Ç¤¢¤ë¡£ + Ìá¤êÃͤϰʲ¼¤Î·Á¼°¤Î @e well-formed plist (@ref m17nPlist) ¤Ç¤¢¤ë¡£ @verbatim ((NAME DESCRIPTION STATUS [KEYSEQ ...]) ...) @@ -4800,12 +4886,13 @@ minput_get_description (MSymbol language, MSymbol name) @c DESCRIPTION ¤Ï¥³¥Þ¥ó¥É¤òÀâÌÀ¤¹¤ë M-text ¤Ç¤¢¤ë¤«¡¢ÀâÌÀ¤¬Ìµ¤¤¾ì¹ç¤Ë ¤Ï #Mnil ¤Ç¤¢¤ë¡£ - @c STATUS ¤Ï¥­¡¼³ä¤êÅö¤Æ¤¬¤É¤Î¤è¤¦¤ËÄê¤á¤é¤ì¤ë¤«¤ò¤¢¤é¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢ - ¤ê¡¢¤½¤ÎÃÍ¤Ï #Mnil ¡Ê¥Ç¥Õ¥©¥ë¥È¤Î³ä¤êÅö¤Æ¡Ë, #Mcustomized ¡Ê¥æ¡¼¥¶ - Ëè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤Ë¤è¤Ã¤Æ¥«¥¹¥¿¥Þ¥¤¥º¤µ¤ì¤¿³ä¤êÅö¤Æ¡Ë, #Mconfigured - ¡Êminput_config_command ()¤ò¸Æ¤Ö¤³¤È¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤ë³ä¤êÅö¤Æ¡Ë¤Î - ¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£¥í¡¼¥«¥ë¥³¥Þ¥ó¥É¤Î¾ì¹ç¤Ë¤Ï¡¢#Minherited ¡ÊÂбþ¤¹¤ë - ¥°¥í¡¼¥Ð¥ë¥³¥Þ¥ó¥É¤«¤é¤Î·Ñ¾µ¤Ë¤è¤ë³ä¤êÅö¤Æ¡Ë¤Ç¤â¤è¤¤¡£ + @c STATUS ¤Ï¥­¡¼³ä¤êÅö¤Æ¤¬¤É¤Î¤è¤¦¤ËÄê¤á¤é¤ì¤ë¤«¤ò¤¢¤é¤ï¤¹¥·¥ó¥Ü¥ë + ¤Ç¤¢¤ê¡¢¤½¤ÎÃÍ¤Ï #Mnil ¡Ê¥Ç¥Õ¥©¥ë¥È¤Î³ä¤êÅö¤Æ¡Ë, #Mcustomized ¡Ê¥æ¡¼ + ¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Ë¤è¤Ã¤Æ¥«¥¹¥¿¥Þ¥¤¥º¤µ¤ì¤¿³ä¤êÅö¤Æ¡Ë, + #Mconfigured ¡Êminput_config_command ()¤ò¸Æ¤Ö¤³¤È¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤ë + ³ä¤êÅö¤Æ¡Ë¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£¥í¡¼¥«¥ë¥³¥Þ¥ó¥É¤Î¾ì¹ç¤Ë¤Ï¡¢ + #Minherited ¡ÊÂбþ¤¹¤ë¥°¥í¡¼¥Ð¥ë¥³¥Þ¥ó¥É¤«¤é¤Î·Ñ¾µ¤Ë¤è¤ë³ä¤êÅö¤Æ¡Ë + ¤Ç¤â¤è¤¤¡£ @c KEYSEQ ¤Ï£±¤Ä°Ê¾å¤Î¥·¥ó¥Ü¥ë¤«¤é¤Ê¤ë plist ¤Ç¤¢¤ê¡¢³Æ¥·¥ó¥Ü¥ë¤Ï¥³¥Þ ¥ó¥É¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¥­¡¼¥·¡¼¥¯¥¨¥ó¥¹¤òɽ¤¹¡£KEYSEQ ¤¬Ìµ¤¤¾ì¹ç¤Ï¡¢ @@ -4835,8 +4922,8 @@ get_im_command_description (MSymbol language, MSymbol name, MSymbol command) if (! cmds) return NULL; - plist = mplist_value (cmds); /* (NAME DESCRIPTION KEY-SEQ ...) */ - plist = mplist_next (plist); /* (DESCRIPTION KEY-SEQ ...) */ + plist = mplist_value (cmds); /* (NAME DESCRIPTION STATUS KEY-SEQ ...) */ + plist = mplist_next (plist); /* (DESCRIPTION STATUS KEY-SEQ ...) */ return (mplist_key (plist) == Mtext ? (MText *) mplist_value (plist) : NULL); @@ -4872,12 +4959,16 @@ minput_get_command (MSymbol language, MSymbol name, MSymbol command) If $KEYSEQLIST is a non-empty plist, it must be a list of key sequences, and each key sequence must be a plist of symbols. - If $KEYSEQLIST is an empty plist, the command becomes unusable. + If $KEYSEQLIST is an empty plist, any configuration and + customization of the command are cancelled, and default key + sequences become effective. + + If $KEYSEQLIST is NULL, the configuration of the command is + canceled, and the original key sequences (what saved in per-user + customization file, or the default one) become effective. - If $KEYSEQLIST is NULL, the configuration of the command for the - input method is canceled, and the default key sequences become - effective. In such case, if $COMMAND is #Mnil, configurations for - all commands of the input method are canceled. + In the latter two cases, $COMMAND can be #Mnil to make all the + commands of the input method the target of the operation. If $NAME is #Mnil, this function configures the key assignment of a global command, not that of a specific input method. @@ -4885,11 +4976,10 @@ minput_get_command (MSymbol language, MSymbol name, MSymbol command) The configuration takes effect for input methods opened or re-opened later in the current session. In order to make the configuration take effect for the future session, it must be saved - in a per-user configuration file by the function + in a per-user customization file by the function minput_save_config (). @return - If the operation was successful, this function returns 0, otherwise returns -1. The operation fails in these cases: