/** 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;
Mmove = msymbol ("move");
Mmark = msymbol ("mark");
Mpushback = msymbol ("pushback");
+ Mpop = msymbol ("pop");
Mundo = msymbol ("undo");
Mcall = msymbol ("call");
Mshift = msymbol ("shift");
MText *mt = NULL;
mplist_push (ic->plist, Minteger, (void *) len);
- if (minput__callback (ic, Minput_get_surrounding_text) >= 0
+ if (minput_callback (ic, Minput_get_surrounding_text) >= 0
&& MPLIST_MTEXT_P (ic->plist))
mt = MPLIST_MTEXT (ic->plist);
mplist_pop (ic->plist);
MInputContextInfo *ic_info = (MInputContextInfo *) ic->info;
mplist_push (ic->plist, Minteger, (void *) pos);
- minput__callback (ic, Minput_delete_surrounding_text);
+ minput_callback (ic, Minput_delete_surrounding_text);
mplist_pop (ic->plist);
if (pos < 0)
{
M17N_OBJECT_UNREF (ic_info->preceding_text);
ic_info->preceding_text = mt;
}
+ else
+ M17N_OBJECT_UNREF (mt);
}
else
ic_info->preceding_text = mt;
M17N_OBJECT_UNREF (ic_info->following_text);
ic_info->following_text = mt;
}
+ else
+ M17N_OBJECT_UNREF (mt);
}
else
ic_info->following_text = mt;
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);
}
}
else if (MPLIST_PLIST_P (pl))
{
- MPLIST_DO (pl, pl)
+ MPLIST_DO (pl, MPLIST_PLIST (pl))
{
if (MPLIST_PLIST_P (pl))
{
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)
{
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);
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;
}
{
M17N_OBJECT_UNREF (mt);
mt = mtext__from_data (translated, strlen (translated),
- MTEXT_FORMAT_UTF_8, 0);
+ MTEXT_FORMAT_UTF_8, 1);
}
}
#endif
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;
}
}
}
}
- return (MPLIST_TAIL_P (valids));
+ return (! MPLIST_TAIL_P (valids));
}
/* Load variable defitions from PLIST into IM_INFO->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;
mtext_put_prop_values (ic->preedit, 0, mtext_nchars (ic->preedit),
Mcandidate_index, NULL, 0);
mtext_cat (ic->produced, ic->preedit);
+ if (mdebug__flag & mdebug_mask)
+ {
+ int i;
+
+ 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)
{
M17N_OBJECT_UNREF (ic->candidate_list);
ic->candidate_list = NULL;
+ ic->candidate_index = 0;
+ ic->candidate_from = ic->candidate_to = 0;
ic->candidates_changed = MINPUT_CANDIDATES_LIST_CHANGED;
if (ic->candidate_show)
{
next = MPLIST_NEXT (next);
}
}
- M17N_OBJECT_UNREF (plist);
+ if (charset)
+ M17N_OBJECT_UNREF (plist);
plist = mplist ();
len = mtext_nchars (mt);
if (len <= column)
}
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);
}
}
}
/* Perform list of actions in ACTION_LIST for the current input
- context IC. If all actions are performed without error, return 0.
+ context IC. If unhandle action was not performed, return 0.
Otherwise, return -1. */
static int
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))
{
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));
}
}
}
+ 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;
= (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;
{
/* MAP can not handle KEY. */
- /* 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)
+ /* Perform branch actions if any. */
+ if (map->branch_actions)
{
- MDEBUG_PRINT (" unhandled\n");
- return -1;
+ MDEBUG_PRINT (" branch-actions:");
+ if (take_action_list (ic, map->branch_actions) < 0)
+ {
+ MDEBUG_PRINT ("\n");
+ return -1;
+ }
}
- if (map != ic_info->state->map)
+ if (map == ic_info->map)
{
- /* If MAP is not the root map... */
- /* If MAP has branch actions, perform them. */
- if (map->branch_actions)
+ /* The above branch actions didn't change the state. */
+
+ /* 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 (" branch-actions:");
- if (take_action_list (ic, map->branch_actions) < 0)
- {
- MDEBUG_PRINT ("\n");
- return -1;
- }
+ MDEBUG_PRINT (" unhandled\n");
+ return -1;
}
- /* If MAP is still not the root map, shift to the current
- state. */
- if (ic_info->map != ic_info->state->map)
- shift_state (ic, ic_info->state->name);
- }
- else
- {
- /* MAP is the root map, perform branch actions (if any) or
- shift to the initial state. */
- if (map->branch_actions)
+
+ if (map != ic_info->state->map)
{
- MDEBUG_PRINT (" branch-actions:");
- if (take_action_list (ic, map->branch_actions) < 0)
- {
- MDEBUG_PRINT ("\n");
- return -1;
- }
+ /* MAP is not the root map. Shift to the root map of the
+ current state. */
+ shift_state (ic, ic_info->state->name);
+ }
+ else if (! map->branch_actions)
+ {
+ /* MAP is the root map without any default branch
+ actions. Shift to the initial state. */
+ shift_state (ic, Mnil);
}
- else
- shift_state (ic, Mnil);
}
}
MDEBUG_PRINT ("\n");
{
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);
{
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);
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;
}
-int
-minput__callback (MInputContext *ic, MSymbol command)
-{
- MInputCallbackFunc func;
-
- if (! ic->im->driver.callback_list)
- return -1;
- func = (MInputCallbackFunc) mplist_get (ic->im->driver.callback_list,
- command);
- if (! func)
- return -1;
- (func) (ic, command);
- return 0;
-}
-
MSymbol
minput__char_to_key (int c)
{
it specifies the number of characters following the current cursor
position. If the value is negative, the absolute value specifies
the number of characters preceding the current cursor position.
+ If the value is zero, it means that the caller just wants to know
+ if the surrounding text is currently supported or not.
If the surrounding text is currently supported, the callback
function must set the key of this element to #Mtext and the value
¤Æ#Minteger ¤ò¤È¤ê¡¢¤½¤ÎÃͤϥµ¥é¥¦¥ó¥Ç¥£¥ó¥°¥Æ¥¥¹¥È¤Î¤¦¤Á¤É¤ÎÉôʬ
¤ò¼è¤Ã¤ÆÍè¤ë¤«¤ò»ØÄꤹ¤ë¡£Ãͤ¬Àµ¤Ç¤¢¤ì¤Ð¡¢¸½ºß¤Î¥«¡¼¥½¥ë°ÌÃ֤˳¤¯
ÃͤθĿôʬ¤Îʸ»ú¤ò¼è¤ë¡£Éé¤Ç¤¢¤ì¤Ð¡¢¥«¡¼¥½¥ë°ÌÃÖ¤ËÀè¹Ô¤¹¤ëÃͤÎÀäÂÐ
- ÃÍʬ¤Îʸ»ú¤ò¼è¤ë¡£
+ ÃÍʬ¤Îʸ»ú¤ò¼è¤ë¡£¸½ºß¥µ¥é¥¦¥ó¥É¥Æ¥¥¹¥È¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦
+ ¤«¤òÃΤꤿ¤¤¤À¤±¤Ç¤¢¤ì¤Ð¡¢¤³¤ÎÃͤϥ¼¥í¤Ç¤âÎɤ¤¡£
¥µ¥é¥¦¥ó¥Ç¥£¥ó¥°¥Æ¥¥¹¥È¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤Ï
¤³¤ÎÍ×ÁǤΥ¡¼¤ò #Mtext ¤Ë¡¢Ãͤò¼è¤ê¹þ¤ó¤ÀM-text ¤ËÀßÄꤷ¤Ê¤¯¤Æ¤Ï¤Ê
¥·¥ç¥ó¦¤ÇɬÍפǸúΨŪ¤À¤È»×¤¨¤ÐŤ¯¤Æ¤âÎɤ¤¡£
¥µ¥é¥¦¥ó¥Ç¥£¥ó¥°¥Æ¥¥¹¥È¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¥³¡¼¥ë¥Ð¥Ã¥¯´Ø
- ¿ô¤Ï #MInputContext::plist ¤ÎÂè°ìÍ×ÁǤòÊѲ½¤µ¤»¤ë¤³¤È¤Ê¤¯ÊÖ¤µ¤Ê¤¯¤Æ
- ¤Ï¤Ê¤é¤Ê¤¤¡£
+ ¿ô¤Ï #MInputContext::plist ¤ÎÂè°ìÍ×ÁǤòÊѹ¹¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
Minput_delete_surrounding_text: ¤³¤Î¥³¥Þ¥ó¥É¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿¥³¡¼¥ë
¥Ð¥Ã¥¯´Ø¿ô¤¬¸Æ¤Ð¤ì¤¿ºÝ¤Ë¤Ï¡¢#MInputContext::plist ¤ÎÂè°ìÍ×ÁǤϡ¢¥¡¼
if (im->driver.callback_list)
{
- minput__callback (ic, Minput_preedit_start);
- minput__callback (ic, Minput_status_start);
- minput__callback (ic, Minput_status_draw);
+ minput_callback (ic, Minput_preedit_start);
+ minput_callback (ic, Minput_status_start);
+ minput_callback (ic, Minput_status_draw);
}
MDEBUG_PRINT (" ok\n");
msymbol_name (ic->im->name), msymbol_name (ic->im->language));
if (ic->im->driver.callback_list)
{
- minput__callback (ic, Minput_preedit_done);
- minput__callback (ic, Minput_status_done);
- minput__callback (ic, Minput_candidates_done);
+ minput_callback (ic, Minput_preedit_done);
+ minput_callback (ic, Minput_status_done);
+ minput_callback (ic, Minput_candidates_done);
}
(*ic->im->driver.destroy_ic) (ic);
M17N_OBJECT_UNREF (ic->preedit);
if (! ic
|| ! ic->active)
return 0;
+ if (ic->im->driver.callback_list
+ && mtext_nchars (ic->preedit) > 0)
+ minput_callback (ic, Minput_preedit_draw);
+
ret = (*ic->im->driver.filter) (ic, key, arg);
if (ic->im->driver.callback_list)
{
if (ic->preedit_changed)
- minput__callback (ic, Minput_preedit_draw);
+ minput_callback (ic, Minput_preedit_draw);
if (ic->status_changed)
- minput__callback (ic, Minput_status_draw);
+ minput_callback (ic, Minput_status_draw);
if (ic->candidates_changed)
- minput__callback (ic, Minput_candidates_draw);
+ minput_callback (ic, Minput_candidates_draw);
}
return ret;
ic->spot.mt = mt;
ic->spot.pos = pos;
if (ic->im->driver.callback_list)
- minput__callback (ic, Minput_set_spot);
+ minput_callback (ic, Minput_set_spot);
}
/*=*/
minput_toggle (MInputContext *ic)
{
if (ic->im->driver.callback_list)
- minput__callback (ic, Minput_toggle);
+ minput_callback (ic, Minput_toggle);
ic->active = ! ic->active;
}
minput_reset_ic (MInputContext *ic)
{
if (ic->im->driver.callback_list)
- minput__callback (ic, Minput_reset);
+ minput_callback (ic, Minput_reset);
}
/*=*/
@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
@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 ¤¬Ìµ¤¤¾ì¹ç¤Ï¡¢
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);
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.
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:
<ul>
$KEYSEQLIST ¤¬¶õ¥ê¥¹¥È¤Ç¤Ê¤±¤ì¤Ð¡¢¥¡¼¥·¡¼¥¯¥¨¥ó¥¹¤Î¥ê¥¹¥È¤Ç¤¢¤ê¡¢
³Æ¥¡¼¥·¡¼¥¯¥¨¥ó¥¹¤Ï¥·¥ó¥Ü¥ë¤Î plist ¤Ç¤¢¤ë¡£
- $KEYSEQLIST ¤¬¶õ¤Î plist ¤Ê¤é¤Ð¡¢¥³¥Þ¥ó¥É¤Ï»ÈÍѤǤ¤Ê¤¯¤Ê¤ë¡£
+ $KEYSEQLIST ¤¬¶õ¤Î plist ¤Ê¤é¤Ð¡¢¤½¤Î¥³¥Þ¥ó¥É¤ÎÀßÄê¤ä¥«¥¹¥¿¥Þ¥¤¥º¤Ï
+ ¤¹¤Ù¤Æ¥¥ã¥ó¥»¥ë¤µ¤ì¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥¡¼¥·¡¼¥¯¥¨¥ó¥¹¤¬Í¸ú¤Ë¤Ê¤ë¡£
+
+ $KEYSEQLIST ¤¬ NULL ¤Ç¤¢¤ì¤Ð¡¢¤½¤Î¥³¥Þ¥ó¥É¤ÎÀßÄê¤Ï¥¥ã¥ó¥»¥ë¤µ¤ì¡¢
+ ¸µ¤Î¥¡¼¥·¡¼¥¯¥¨¥ó¥¹¡Ê¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤ËÊݸ¤µ¤ì¤Æ¤¤
+ ¤ë¤â¤Î¡¢¤¢¤ë¤¤¤Ï¥Ç¥Õ¥©¥ë¥È¤Î¤â¤Î¡Ë¤¬Í¸ú¤Ë¤Ê¤ë¡£
- $KEYSEQLIST ¤¬ NULL ¤Ç¤¢¤ì¤Ð¡¢»ØÄê¤ÎÆþÎϥ᥽¥Ã¥É¤Î¥³¥Þ¥ó¥É¤ÎÀßÄê¤Ï
- ¥¥ã¥ó¥»¥ë¤µ¤ì¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥¡¼¥·¡¼¥¯¥¨¥ó¥¹¤¬Í¸ú¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¡¢
- $COMMAND ¤¬ #Mnil ¤Ê¤é¤Ð»ØÄê¤ÎÆþÎϥ᥽¥Ã¥É¤ÎÁ´¤Æ¤Î¥³¥Þ¥ó¥É¤ÎÀßÄ꤬
- ¥¥ã¥ó¥»¥ë¤µ¤ì¤ë¡£
+ ¸å¤Î¤Õ¤¿¤Ä¤Î¾ì¹ç¤Ë¤Ï¡¢$COMMAND ¤Ï #Mnil ¤ò¤È¤ë¤³¤È¤¬¤Ç¤¡¢»ØÄê¤ÎÆþ
+ Îϥ᥽¥Ã¥É¤ÎÁ´¤Æ¤Î¥³¥Þ¥ó¥ÉÀßÄê¤Î¥¥ã¥ó¥»¥ë¤ò°ÕÌ£¤¹¤ë¡£
$NAME ¤¬ #Mnil ¤Ê¤é¤Ð¡¢¤³¤Î´Ø¿ô¤Ï¸Ä¡¹¤ÎÆþÎϥ᥽¥Ã¥É¤Ç¤Ï¤Ê¤¯¥°¥í¡¼¥Ð
¥ë¤Ê¥³¥Þ¥ó¥É¤Î¥¡¼³ä¤êÅö¤Æ¤òÀßÄꤹ¤ë¡£
¤³¤ì¤é¤ÎÀßÄê¤Ï¡¢¸½¹Ô¤Î¥»¥Ã¥·¥ç¥óÃæ¤ÇÆþÎϥ᥽¥Ã¥É¤¬¥ª¡¼¥×¥ó¡Ê¤Þ¤¿¤Ï
ºÆ¥ª¡¼¥×¥ó¡Ë¤µ¤ì¤¿»þÅÀ¤Ç͸ú¤Ë¤Ê¤ë¡£¾Íè¤Î¥»¥Ã¥·¥ç¥óÃæ¤Ç¤â͸ú¤Ë¤¹
- ¤ë¤¿¤á¤Ë¤Ï¡¢´Ø¿ô minput_save_config () ¤òÍѤ¤¤Æ¥æ¡¼¥¶Ëè¤ÎÀßÄê¥Õ¥¡¥¤
- ¥ë¤ËÊݸ¤·¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+ ¤ë¤¿¤á¤Ë¤Ï¡¢´Ø¿ô minput_save_config () ¤òÍѤ¤¤Æ¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤
+ ¥º¥Õ¥¡¥¤¥ë¤ËÊݸ¤·¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
@return
MPlist *cmd, *plist, *key_seq_list, *key_seq;
/* At first get the current key-sequence assignment. */
- cmd = mplist_get_command (Mt, unicode, start_command);
+ cmd = minput_get_command (Mt, unicode, start_command);
if (! cmd)
{
/* The input method does not have the command "start". Here
should come some error handling code. */
}
- /* Now CMD == ((start DESCRIPTION KEY-SEQUENCE ...) ...). Extract
- the part (KEY-SEQUENCE ...). */
- plist = mplist_next (mplist_next (mplist_value (cmd)));
+ /* Now CMD == ((start DESCRIPTION STATUS KEY-SEQUENCE ...) ...).
+ Extract the part (KEY-SEQUENCE ...). */
+ plist = mplist_next (mplist_next (mplist_next (mplist_value (cmd))));
/* Copy it because we should not modify it directly. */
key_seq_list = mplist_copy (plist);
- m17n_object_unref (cmds);
key_seq = mplist ();
mplist_add (key_seq, Msymbol, msymbol ("C-x"));
MINPUT__INIT ();
- if (keyseqlist)
- {
- if (command == Mnil)
- MERROR (MERROR_IM, -1);
- MPLIST_DO (plist, keyseqlist)
- if (! MPLIST_PLIST_P (plist)
- || ! check_command_keyseq (plist))
- MERROR (MERROR_IM, -1);
- }
-
im_info = get_im_info (language, name, Mnil, Mcommand);
if (! im_info)
MERROR (MERROR_IM, -1);
- if (command != Mnil
- && (! im_info->cmds
- || ! mplist__assq (im_info->cmds, command)))
+ if (command == Mnil ? (keyseqlist && ! MPLIST_TAIL_P (keyseqlist))
+ : (! im_info->cmds
+ || ! mplist__assq (im_info->configured_cmds, command)))
MERROR (MERROR_IM, -1);
+ if (keyseqlist && ! MPLIST_TAIL_P (keyseqlist))
+ {
+ MPLIST_DO (plist, keyseqlist)
+ if (! check_command_keyseq (plist))
+ MERROR (MERROR_IM, -1);
+ }
config = get_config_info (im_info);
if (! config)
config->vars = mplist ();
}
+ if (! keyseqlist && MPLIST_TAIL_P (config->cmds))
+ /* Nothing to do. */
+ return 0;
+
if (command == Mnil)
{
- MInputMethodInfo *custom = get_custom_info (im_info);
-
- mplist_set (config->cmds, Mnil, NULL);
- if (custom && custom->cmds)
+ if (! keyseqlist)
{
+ /* Cancal the configuration. */
+ if (MPLIST_TAIL_P (config->cmds))
+ return 0;
+ mplist_set (config->cmds, Mnil, NULL);
+ }
+ else
+ {
+ /* Cancal the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+
+ if (MPLIST_TAIL_P (config->cmds)
+ && (! custom || ! custom->cmds || MPLIST_TAIL_P (custom->cmds)))
+ /* Nothing to do. */
+ return 0;
+ mplist_set (config->cmds, Mnil, NULL);
MPLIST_DO (plist, custom->cmds)
{
command = MPLIST_SYMBOL (MPLIST_PLIST (plist));
else
{
plist = mplist__assq (config->cmds, command);
- if (plist)
+ if (! keyseqlist)
{
- plist = MPLIST_PLIST (plist); /* (NAME [nil KEY-SEQUENCE ...]) */
- plist = MPLIST_NEXT (plist); /* ([nil ...]) */
- if (! MPLIST_TAIL_P (plist))
- mplist_set (plist, Mnil, NULL); /* () */
+ /* Cancel the configuration. */
+ if (! plist)
+ return 0;
+ mplist__pop_unref (plist);
}
- else
+ else if (MPLIST_TAIL_P (keyseqlist))
{
- plist = mplist ();
- mplist_add (config->cmds, Mplist, plist);
- M17N_OBJECT_UNREF (plist);
- plist = mplist_add (plist, Msymbol, command);
- plist = MPLIST_NEXT (plist);
+ /* Cancel the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+ int no_custom = (! custom || ! custom->cmds
+ || ! mplist__assq (custom->cmds, command));
+ if (! plist)
+ {
+ if (no_custom)
+ return 0;
+ plist = mplist ();
+ mplist_add (config->cmds, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, command);
+ }
+ else
+ {
+ if (no_custom)
+ mplist__pop_unref (plist);
+ else
+ {
+ plist = MPLIST_PLIST (plist); /* (NAME nil KEYSEQ ...) */
+ plist = MPLIST_NEXT (plist);
+ mplist_set (plist, Mnil, NULL);
+ }
+ }
}
- if (keyseqlist)
+ else
{
MPlist *pl;
- plist = mplist_add (plist, Msymbol, Mnil);
+ if (plist)
+ {
+ plist = MPLIST_NEXT (MPLIST_PLIST (plist));
+ if (! MPLIST_TAIL_P (plist))
+ mplist_set (plist, Mnil, NULL);
+ }
+ else
+ {
+ plist = mplist ();
+ mplist_add (config->cmds, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, command);
+ plist = MPLIST_NEXT (plist);
+ }
MPLIST_DO (keyseqlist, keyseqlist)
{
pl = mplist_copy (MPLIST_VAL (keyseqlist));
@brief Get information about input method variable(s).
The minput_get_variable () function returns information about
- the variable $VARIABLE of the input method specified by $LANGUAGE and $NAME.
+ variable $VARIABLE of the input method specified by $LANGUAGE and $NAME.
An input method variable controls behavior of an input method.
There are two kinds of variables, global and local. A global
@c STATUS is a symbol representing how the value is decided. The
value is #Mnil (the default value), #Mcustomized (the value is
- customized by per-user configuration file), or #Mconfigured (the
+ customized by per-user customization file), or #Mconfigured (the
value is set by the call of minput_config_variable ()). For a
local variable only, it may also be #Minherited (the value is
inherited from the corresponding global variable).
#Mnil ¤Ç¤¢¤ë¡£
@c STATUS ¤ÏÃͤ¬¤É¤Î¤è¤¦¤ËÄê¤á¤é¤ì¤ë¤«¤ò¤¢¤é¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢
- @c STATUS ¤ÎÃÍ¤Ï #Mnil ¡Ê¥Ç¥Õ¥©¥ë¥È¤ÎÃÍ¡Ë, #Mcustomized ¡Ê¥æ¡¼¥¶Ëè¤ÎÀß
- Äê¥Õ¥¡¥¤¥ë¤Ë¤è¤Ã¤Æ¥«¥¹¥¿¥Þ¥¤¥º¤µ¤ì¤¿ÃÍ¡Ë, #Mconfigured
+ @c STATUS ¤ÎÃÍ¤Ï #Mnil ¡Ê¥Ç¥Õ¥©¥ë¥È¤ÎÃÍ¡Ë, #Mcustomized ¡Ê¥æ¡¼¥¶Ëè¤Î
+ ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Ë¤è¤Ã¤Æ¥«¥¹¥¿¥Þ¥¤¥º¤µ¤ì¤¿ÃÍ¡Ë, #Mconfigured
¡Êminput_config_variable ()¤ò¸Æ¤Ö¤³¤È¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤ëÃ͡ˤΤ¤¤º¤ì
¤«¤Ç¤¢¤ë¡£¥í¡¼¥«¥ëÊÑ¿ô¤Î¾ì¹ç¤Ë¤Ï¡¢#Minherited ¡ÊÂбþ¤¹¤ë¥°¥í¡¼¥Ð¥ë
ÊÑ¿ô¤«¤é·Ñ¾µ¤·¤¿Ã͡ˤǤâ¤è¤¤¡£
variable $VARIABLE of the input method specified by $LANGUAGE and
$NAME.
- If $VALUE is not NULL, it must be a plist of one element whose key
- is #Minteger, #Msymbol, or #Mtext, and the value is of the
- corresponding type.
+ If $VALUE is a non-empty plist, it must be a plist of one element
+ whose key is #Minteger, #Msymbol, or #Mtext, and the value is of
+ the corresponding type. That value is assigned to the variable.
+
+ If $VALUE is an empty plist, any configuration and customization
+ of the variable are canceled, and the default value is assigned to
+ the variable.
+
+ If $VALUE is NULL, the configuration of the variable is canceled,
+ and the original value (what saved in per-user customization file,
+ or the default value) is assigned to the variable.
- If $VALUE is NULL, a configuration for the variable for the input
- method is canceled, and the variable is initialized to the default
- value. In that case, if $VARIABLE is #Mnil, configurations for
- all variables of the input method are canceled.
+ In the latter two cases, $VARIABLE can be #Mnil to make all the
+ variables of the input method the target of the operation.
- If $NAME is #Mnil, this function configure the value of global
+ If $NAME is #Mnil, this function configures the value of global
variable, not that of a specific input method.
The configuration takes effect for input methods opened or
re-opened later in the current session. To make the configuration
take effect for the future session, it must be saved in a per-user
- configuration file by the function minput_save_config ().
+ customization file by the function minput_save_config ().
@return
´Ø¿ô minput_config_variable () ¤ÏÃÍ $VALUE ¤ò¡¢$LANGUAGE ¤È $NAME
¤Ë¤è¤Ã¤Æ»ØÄꤵ¤ì¤ëÆþÎϥ᥽¥Ã¥É¤ÎÊÑ¿ô $VARIABLE ¤Ë³ä¤êÅö¤Æ¤ë¡£
- $VALUE ¤¬ NULL¤Ç¤Ê¤±¤ì¤Ð¡¢£±Í×ÁǤΠplist ¤Ç¤¢¤ê¡¢¤½¤Î¥¡¼¤Ï
+ $VALUE ¤¬ ¶õ¥ê¥¹¥È¤Ç¤Ê¤±¤ì¤Ð¡¢£±Í×ÁǤΠplist ¤Ç¤¢¤ê¡¢¤½¤Î¥¡¼¤Ï
#Minteger, #Msymbol, #Mtext ¤Î¤¤¤º¤ì¤«¡¢ÃͤÏÂбþ¤¹¤ë·¿¤Î¤â¤Î¤Ç¤¢¤ë¡£
+ ¤³¤ÎÃͤ¬ÊÑ¿ô $VARIABLE ¤Ë³ä¤êÅö¤Æ¤é¤ì¤ë¡£
- $VALUE ¤¬ NULL ¤Ç¤¢¤ì¤Ð¡¢»ØÄê¤ÎÆþÎϥ᥽¥Ã¥É¤ÎÊÑ¿ô¤ÎÀßÄê¤Ï¥¥ã¥ó¥»¥ë
- ¤µ¤ì¡¢ÊÑ¿ô¤Ï¥Ç¥Õ¥©¥ë¥ÈÃͤ˽é´ü²½¤µ¤ì¤ë¡£¤³¤Î¾ì¹ç¡¢$VARIABLE ¤¬
- #Mnil ¤Ê¤é¤Ð»ØÄê¤ÎÆþÎϥ᥽¥Ã¥É¤ÎÁ´¤Æ¤ÎÊÑ¿ô¤ÎÀßÄ꤬¥¥ã¥ó¥»¥ë¤µ¤ì¤ë¡£
+ $VALUE ¤¬ ¶õ¥ê¥¹¥È¤Ç¤¢¤ì¤Ð¡¢ÊÑ¿ô¤ÎÀßÄê¤È¥«¥¹¥¿¥Þ¥¤¥º¤¬¥¥ã¥ó¥»¥ë¤µ
+ ¤ì¡¢¥Ç¥Õ¥©¥ë¥ÈÃͤ¬ÊÑ¿ô $VARIABLE ¤Ë³ä¤êÅö¤Æ¤é¤ì¤ë¡£
+
+ $VALUE ¤¬ NULL ¤Ç¤¢¤ì¤Ð¡¢ÊÑ¿ô¤ÎÀßÄê¤Ï¥¥ã¥ó¥»¥ë¤µ¤ì¡¢¸µ¤ÎÃ͡ʥ桼¥¶
+ Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ëÃæ¤ÎÃÍ¡¢¤Þ¤¿¤Ï¥Ç¥Õ¥©¥ë¥È¤ÎÃ͡ˤ¬³ä¤êÅö¤Æ¤é¤ì¤ë¡£
+
+ ¸å¤Î¤Õ¤¿¤Ä¤Î¾ì¹ç¤Ë¤Ï¡¢$VARIABLE ¤Ï #Mnil ¤ò¤È¤ë¤³¤È¤¬¤Ç¤¡¢»ØÄꤵ¤ì
+ ¤¿ÆþÎϥ᥽¥Ã¥É¤ÎÁ´¤Æ¤ÎÊÑ¿ôÀßÄê¤Î¥¥ã¥ó¥»¥ë¤ò°ÕÌ£¤¹¤ë¡£
$NAME ¤¬ #Mnil ¤Ê¤é¤Ð¡¢¤³¤Î´Ø¿ô¤Ï¸Ä¡¹¤ÎÆþÎϥ᥽¥Ã¥É¤Ç¤Ï¤Ê¤¯¥°¥í¡¼¥Ð
¥ë¤ÊÊÑ¿ô¤ÎÃͤòÀßÄꤹ¤ë¡£
¤³¤ì¤é¤ÎÀßÄê¤Ï¡¢¸½¹Ô¤Î¥»¥Ã¥·¥ç¥óÃæ¤ÇÆþÎϥ᥽¥Ã¥É¤¬¥ª¡¼¥×¥ó¡Ê¤Þ¤¿¤Ï
ºÆ¥ª¡¼¥×¥ó¡Ë¤µ¤ì¤¿»þÅÀ¤Ç͸ú¤Ë¤Ê¤ë¡£¾Íè¤Î¥»¥Ã¥·¥ç¥óÃæ¤Ç¤â͸ú¤Ë¤¹
- ¤ë¤¿¤á¤Ë¤Ï¡¢´Ø¿ô minput_save_config () ¤òÍѤ¤¤Æ¥æ¡¼¥¶Ëè¤ÎÀßÄê¥Õ¥¡¥¤
- ¥ë¤ËÊݸ¤·¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+ ¤ë¤¿¤á¤Ë¤Ï¡¢´Ø¿ô minput_save_config () ¤òÍѤ¤¤Æ¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤
+ ¥º¥Õ¥¡¥¤¥ë¤ËÊݸ¤·¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
@return
im_info = get_im_info (language, name, Mnil, Mvariable);
if (! im_info)
MERROR (MERROR_IM, -1);
- if (variable == Mnil)
- {
- if (value)
- MERROR (MERROR_IM, -1);
- }
- else if (! im_info->vars
- || ! (plist = mplist__assq (im_info->configured_vars, variable)))
+ if (variable == Mnil ? (value && ! MPLIST_TAIL_P (value))
+ : (! im_info->vars
+ || ! (plist = mplist__assq (im_info->configured_vars, variable))))
MERROR (MERROR_IM, -1);
- if (variable != Mnil && value)
+ if (value && ! MPLIST_TAIL_P (value))
{
plist = MPLIST_PLIST (plist);
plist = MPLIST_NEXT (plist); /* (DESC STATUS VALUE VALIDS ...) */
config->vars = mplist ();
}
+ if (! value && MPLIST_TAIL_P (config->vars))
+ /* Nothing to do. */
+ return 0;
+
if (variable == Mnil)
{
- MInputMethodInfo *custom = get_custom_info (im_info);
-
- mplist_set (config->vars, Mnil, NULL);
- if (custom && custom->cmds)
+ if (! value)
+ {
+ /* Cancel the configuration. */
+ if (MPLIST_TAIL_P (config->vars))
+ return 0;
+ mplist_set (config->vars, Mnil, NULL);
+ }
+ else
{
+ /* Cancel the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+
+ if (MPLIST_TAIL_P (config->vars)
+ && (! custom || ! custom->vars || MPLIST_TAIL_P (custom->vars)))
+ /* Nothing to do. */
+ return 0;
+ mplist_set (config->vars, Mnil, NULL);
MPLIST_DO (plist, custom->vars)
{
variable = MPLIST_SYMBOL (MPLIST_PLIST (plist));
else
{
plist = mplist__assq (config->vars, variable);
- if (plist)
+ if (! value)
{
- plist = MPLIST_PLIST (plist); /* (NAME nil VALUE) */
- plist = MPLIST_NEXT (plist); /* ([nil VALUE]) */
- if (! MPLIST_TAIL_P (plist))
- mplist_set (plist, Mnil ,NULL); /* () */
+ /* Cancel the configuration. */
+ if (! plist)
+ return 0;
+ mplist__pop_unref (plist);
}
- else
+ else if (MPLIST_TAIL_P (value))
{
- plist = mplist ();
- mplist_add (config->vars, Mplist, plist);
- M17N_OBJECT_UNREF (plist);
- plist = mplist_add (plist, Msymbol, variable);
- plist = MPLIST_NEXT (plist);
+ /* Cancel the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+ int no_custom = (! custom || ! custom->vars
+ || ! mplist__assq (custom->vars, variable));
+ if (! plist)
+ {
+ if (no_custom)
+ return 0;
+ plist = mplist ();
+ mplist_add (config->vars, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, variable);
+ }
+ else
+ {
+ if (no_custom)
+ mplist__pop_unref (plist);
+ else
+ {
+ plist = MPLIST_PLIST (plist); /* (NAME nil VALUE) */
+ plist = MPLIST_NEXT (plist); /* ([nil VALUE]) */
+ mplist_set (plist, Mnil ,NULL);
+ }
+ }
}
- if (value)
+ else
{
- plist = mplist_add (plist, Msymbol, Mnil);
+ if (plist)
+ {
+ plist = MPLIST_NEXT (MPLIST_PLIST (plist));
+ if (! MPLIST_TAIL_P (plist))
+ mplist_set (plist, Mnil, NULL);
+ }
+ else
+ {
+ plist = mplist ();
+ mplist_add (config->vars, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, variable);
+ plist = MPLIST_NEXT (plist);
+ }
mplist_add (plist, MPLIST_KEY (value), MPLIST_VAL (value));
}
}
/*=*/
/***en
- @brief Get the name of per-user configuration file.
+ @brief Get the name of per-user customization file.
The minput_config_file () function returns the absolute path name
- of per-user configuration file into which minput_save_config ()
+ of per-user customization file into which minput_save_config ()
save configurations. It is usually @c "config.mic" under the
directory @c ".m17n.d" of user's home directory. It is not assured
that the file of the returned name exists nor is
minput_save_config ()
*/
/***ja
- @brief ¥æ¡¼¥¶Ëè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤Î̾Á°¤òÆÀ¤ë.
+ @brief ¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Î̾Á°¤òÆÀ¤ë.
´Ø¿ô minput_config_file () ¤Ï¡¢´Ø¿ô minput_save_config () ¤¬ÀßÄê¤ò
- Êݸ¤¹¤ë¥æ¡¼¥¶Ëè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤Ø¤ÎÀäÂХѥ¹Ì¾¤òÊÖ¤¹¡£Ä̾ï¤Ï¡¢¥æ¡¼¥¶
+ Êݸ¤¹¤ë¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Ø¤ÎÀäÂХѥ¹Ì¾¤òÊÖ¤¹¡£Ä̾ï¤Ï¡¢¥æ¡¼¥¶
¤Î¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê¤Î²¼¤Î¥Ç¥£¥ì¥¯¥È¥ê @c ".m17n.d" ¤Ë¤¢¤ë@c
"config.mic" ¤È¤Ê¤ë¡£ÊÖ¤µ¤ì¤¿Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¤«¡¢Æɤ߽ñ¤¤Ç
¤¤ë¤«¤ÏÊݾڤµ¤ì¤Ê¤¤¡£´Ø¿ôminput_save_config () ¤¬¼ºÇÔ¤·¤Æ -1 ¤òÊÖ
/*=*/
/***en
- @brief Save configurations in per-user configuration file.
+ @brief Save configurations in per-user customization file.
The minput_save_config () function saves the configurations done
- so far in the current session into the per-user configuration
+ so far in the current session into the per-user customization
file.
@return
If the operation was successful, 1 is returned. If the per-user
- configuration file is currently locked, 0 is returned. In that
+ customization file is currently locked, 0 is returned. In that
case, the caller may wait for a while and try again. If the
configuration file is not writable, -1 is returned. In that case,
the caller may check the name of the file by calling
@seealso
minput_config_file () */
/***ja
- @brief ÀßÄê¤ò¥æ¡¼¥¶Ëè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤ËÊݸ¤¹¤ë.
+ @brief ÀßÄê¤ò¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤ËÊݸ¤¹¤ë.
´Ø¿ô minput_save_config () ¤Ï¸½¹Ô¤Î¥»¥Ã¥·¥ç¥ó¤Ç¤³¤ì¤Þ¤Ç¤Ë¹Ô¤Ã¤¿ÀßÄê
- ¤ò¥æ¡¼¥¶Ëè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤ËÊݸ¤¹¤ë¡£
+ ¤ò¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤ËÊݸ¤¹¤ë¡£
@return
- À®¸ù¤¹¤ì¤Ð 1 ¤òÊÖ¤¹¡£¥æ¡¼¥¶Ëè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤¬¥í¥Ã¥¯¤µ¤ì¤Æ¤¤¤ì¤Ð 0
- ¤òÊÖ¤¹¡£¤³¤Î¾ì¹ç¡¢¸Æ½Ð¦¤Ï¤·¤Ð¤é¤¯ÂԤäƺƻî¹Ô¤Ç¤¤ë¡£ÀßÄê¥Õ¥¡¥¤¥ë
- ¤¬½ñ¤¹þ¤ßÉԲĤξì¹ç¡¢-1 ¤òÊÖ¤¹¡£¤³¤Î¾ì¹ç¡¢minput_config_file () ¤ò
- ¸Æ¤ó¤Ç¥Õ¥¡¥¤¥ë̾¤ò¥Á¥§¥Ã¥¯¤·¡¢¤Ç¤¤ì¤Ð½ñ¤¹þ¤ß²Äǽ¤Ë¤·¡¢ºÆ»î¹Ô¤Ç¤
- ¤ë¡£
+ À®¸ù¤¹¤ì¤Ð 1 ¤òÊÖ¤¹¡£¥æ¡¼¥¶Ëè¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤¬¥í¥Ã¥¯¤µ¤ì¤Æ¤¤
+ ¤ì¤Ð 0 ¤òÊÖ¤¹¡£¤³¤Î¾ì¹ç¡¢¸Æ½Ð¦¤Ï¤·¤Ð¤é¤¯ÂԤäƺƻî¹Ô¤Ç¤¤ë¡£ÀßÄê¥Õ¥¡
+ ¥¤¥ë¤¬½ñ¤¹þ¤ßÉԲĤξì¹ç¡¢-1 ¤òÊÖ¤¹¡£¤³¤Î¾ì¹ç¡¢minput_config_file
+ () ¤ò¸Æ¤ó¤Ç¥Õ¥¡¥¤¥ë̾¤ò¥Á¥§¥Ã¥¯¤·¡¢¤Ç¤¤ì¤Ð½ñ¤¹þ¤ß²Äǽ¤Ë¤·¡¢ºÆ»î¹Ô
+ ¤Ç¤¤ë¡£
@seealso
minput_config_file () */
update_custom_info ();
if (! im_custom_list)
im_custom_list = mplist ();
- data = tail = mplist ();
+ /* At first, reflect configuration in customization. */
MPLIST_DO (plist, im_config_list)
{
MPlist *pl = MPLIST_PLIST (plist);
else
custom->cmds = mplist (), p = NULL;
elt = MPLIST_NEXT (elt);
- if (MPLIST_TAIL_P (elt))
+ if (p)
{
- if (p)
- mplist__pop_unref (p);
+ p = MPLIST_NEXT (MPLIST_NEXT (MPLIST_PLIST (p)));
+ mplist_set (p, Mnil, NULL);
}
else
{
- elt = MPLIST_NEXT (elt);
- if (p)
- {
- p = MPLIST_NEXT (MPLIST_NEXT (MPLIST_PLIST (p)));
- mplist_set (p, Mnil, NULL);
- mplist__conc (p, elt);
- }
- else
- {
- p = MPLIST_PLIST (pl);
- mplist_add (custom->cmds, Mplist, p);
- }
+ p = mplist ();
+ mplist_add (custom->cmds, Mplist, p);
+ M17N_OBJECT_UNREF (p);
+ mplist_add (p, Msymbol, command);
+ p = mplist_add (p, Msymbol, Mnil);
+ p = MPLIST_NEXT (p);
}
+ mplist__conc (p, elt);
}
if (config->vars)
MPLIST_DO (pl, config->vars)
else
custom->vars = mplist (), p = NULL;
elt = MPLIST_NEXT (elt);
- if (MPLIST_TAIL_P (elt))
+ if (p)
{
- if (p)
- mplist__pop_unref (p);
+ p = MPLIST_NEXT (MPLIST_NEXT (MPLIST_PLIST (p)));
+ mplist_set (p, Mnil, NULL);
}
else
{
- elt = MPLIST_NEXT (elt);
- if (p)
- {
- p = MPLIST_NEXT (MPLIST_NEXT (MPLIST_PLIST (p)));
- mplist_set (p, Mnil, NULL);
- mplist__conc (p, elt);
- }
- else
- {
- p = MPLIST_PLIST (pl);
- mplist_add (custom->vars, Mplist, p);
- }
+ p = mplist ();
+ mplist_add (custom->vars, Mplist, p);
+ M17N_OBJECT_UNREF (p);
+ mplist_add (p, Msymbol, variable);
+ p = mplist_add (p, Msymbol, Mnil);
+ p = MPLIST_NEXT (p);
}
+ mplist__conc (p, elt);
}
}
- M17N_OBJECT_UNREF (im_config_list);
+ free_im_list (im_config_list);
+ im_config_list = NULL;
+ /* Next, reflect customization to the actual plist to be written. */
+ data = tail = mplist ();
MPLIST_DO (plist, im_custom_list)
{
MPlist *pl = MPLIST_PLIST (plist);
extra = MPLIST_SYMBOL (pl);
pl = MPLIST_NEXT (pl);
custom = MPLIST_VAL (pl);
+ if ((! custom->cmds || MPLIST_TAIL_P (custom->cmds))
+ && (! custom->vars || MPLIST_TAIL_P (custom->vars)))
+ continue;
im_info = lookup_im_info (im_info_list, language, name, extra);
if (im_info)
{
config_all_variables (im_info);
}
- elt = mplist ();
- tail = mplist_add (tail, Mplist, elt);
- M17N_OBJECT_UNREF (elt);
- pl = mplist ();
- elt = mplist_add (elt, Mplist, pl);
- M17N_OBJECT_UNREF (pl);
- pl = mplist_add (pl, Msymbol, Minput_method);
- pl = mplist_add (pl, Msymbol, language);
- pl = mplist_add (pl, Msymbol, name);
- if (extra != Mnil)
- pl = mplist_add (pl, Msymbol, extra);
+ elt = NULL;
if (custom->cmds && ! MPLIST_TAIL_P (custom->cmds))
{
- pl = mplist ();
- elt = mplist_add (elt, Mplist, pl);
- M17N_OBJECT_UNREF (pl);
- pl = mplist_add (pl, Msymbol, Mcommand);
MPLIST_DO (p, custom->cmds)
- pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ break;
+ if (! MPLIST_TAIL_P (p))
+ {
+ elt = mplist ();
+ pl = mplist ();
+ mplist_add (elt, Mplist, pl);
+ M17N_OBJECT_UNREF (pl);
+ pl = mplist_add (pl, Msymbol, Mcommand);
+ MPLIST_DO (p, custom->cmds)
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ }
}
if (custom->vars && ! MPLIST_TAIL_P (custom->vars))
{
+ MPLIST_DO (p, custom->vars)
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ break;
+ if (! MPLIST_TAIL_P (p))
+ {
+ if (! elt)
+ elt = mplist ();
+ pl = mplist ();
+ mplist_add (elt, Mplist, pl);
+ M17N_OBJECT_UNREF (pl);
+ pl = mplist_add (pl, Msymbol, Mvariable);
+ MPLIST_DO (p, custom->vars)
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ }
+ }
+ if (elt)
+ {
pl = mplist ();
- elt = mplist_add (elt, Mplist, pl);
+ mplist_push (elt, Mplist, pl);
M17N_OBJECT_UNREF (pl);
- pl = mplist_add (pl, Msymbol, Mvariable);
- MPLIST_DO (p, custom->vars)
- pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ pl = mplist_add (pl, Msymbol, Minput_method);
+ pl = mplist_add (pl, Msymbol, language);
+ pl = mplist_add (pl, Msymbol, name);
+ if (extra != Mnil)
+ pl = mplist_add (pl, Msymbol, extra);
+ tail = mplist_add (tail, Mplist, elt);
+ M17N_OBJECT_UNREF (elt);
}
}
return ret;
}
+/*=*/
+
+/***en
+ @brief Call a callback function
+
+ The minput_callback () functions calls a callback function
+ $COMMAND assigned for the input context $IC. The caller must set
+ specific elements in $IC->plist if the callback function requires.
+
+ @return
+ If there exists a specified callback function, 0 is returned.
+ Otherwise -1 is returned. By side effects, $IC->plist may be
+ modified. */
+
+int
+minput_callback (MInputContext *ic, MSymbol command)
+{
+ MInputCallbackFunc func;
+
+ if (! ic->im->driver.callback_list)
+ return -1;
+ func = ((MInputCallbackFunc)
+ mplist_get_func (ic->im->driver.callback_list, command));
+ if (! func)
+ return -1;
+ (func) (ic, command);
+ return 0;
+}
+
/*** @} */
/*** @} */
/*=*/