/* input.c -- input method module.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H15PRO112
msymbol_put (alias[j], M_key_alias, alias[j + 1]);
}
- buf3[0] = 255;
+ buf3[0] = (char) 255;
alias[0] = alias[3] = msymbol (buf3);
alias[1] = one_char_symbol[255] = msymbol ("M-Delete");
alias[2] = msymbol ("A-Delete");
}
static int
-surrounding_pos (MSymbol sym)
+surrounding_pos (MSymbol sym, int *pos)
{
char *name;
return 0;
name = MSYMBOL_NAME (sym);
if (name[0] == '@'
- && (name[1] == '-' || name[1] == '+')
- && name[2] >= '1' && name[2] <= '9')
- return (name[1] == '-' ? - atoi (name + 2) : atoi (name + 2));
+ && (name[1] == '-' ? (name[2] >= '1' && name[2] <= '9')
+ : name[1] == '+' ? (name[2] >= '0' && name[2] <= '9')
+ : 0))
+ {
+ *pos = name[1] == '-' ? - atoi (name + 2) : atoi (name + 2);
+ return 1;
+ }
return 0;
}
if (name[2])
{
pos = atoi (name + 1);
- if (pos == 0)
+ if (pos == 0 && code == '-')
return get_preceding_char (ic, 0);
- if (pos < 0)
- pos = ic->cursor_pos + pos;
- else
- pos = ic->cursor_pos + pos - 1;
+ pos = ic->cursor_pos + pos;
if (pos < 0)
{
if (ic->produced && mtext_len (ic->produced) + pos >= 0)
module = msymbol ((char *) MTEXT_DATA (MPLIST_MTEXT (plist)));
else if (MPLIST_SYMBOL_P (plist))
module = MPLIST_SYMBOL (plist);
- module_file = alloca (strlen (MSYMBOL_NAME (module))
+ module_file = alloca (strlen (M17N_MODULE_DIR) + 1
+ + strlen (MSYMBOL_NAME (module))
+ strlen (DLOPEN_SHLIB_EXT) + 1);
- sprintf (module_file, "%s%s", MSYMBOL_NAME (module), DLOPEN_SHLIB_EXT);
+ sprintf (module_file, "%s/%s%s",
+ M17N_MODULE_DIR, MSYMBOL_NAME (module), DLOPEN_SHLIB_EXT);
handle = dlopen (module_file, RTLD_NOW);
if (MFAILP (handle))
static int take_action_list (MInputContext *ic, MPlist *action_list);
static void preedit_commit (MInputContext *ic, int need_prefix);
+/* Shift to the state of name STATE_NAME. If STATE_NAME is `t', shift
+ to the previous state (if any). If STATE_NAME is `nil', shift to
+ the initial state. */
+
static void
shift_state (MInputContext *ic, MSymbol state_name)
{
preedit_commit (ic, 0);
mtext_cpy (ic_info->preedit_saved, ic->preedit);
ic_info->state_pos = ic->cursor_pos;
- if (state != orig_state)
+ if (state != orig_state || state_name == Mnil)
{
if (state == (MIMState *) MPLIST_VAL (im_info->states))
{
else
ic->status = im_info->title;
ic->status_changed = 1;
- if (ic_info->map == ic_info->state->map
- && ic_info->map->map_actions)
- {
- MDEBUG_PRINT1 (" [IM] [%s] init-actions:",
- MSYMBOL_NAME (state->name));
- take_action_list (ic, ic_info->map->map_actions);
- }
+ ic_info->state_hook = ic_info->map->map_actions;
}
}
int to;
if (MPLIST_SYMBOL_P (args)
- && (pos = surrounding_pos (MPLIST_SYMBOL (args))) != 0)
+ && surrounding_pos (MPLIST_SYMBOL (args), &pos))
{
to = ic->cursor_pos + pos;
if (to < 0)
MSymbol alias = Mnil;
int i;
+ if (ic_info->state_hook)
+ {
+ MDEBUG_PRINT1 (" [IM] [%s] init-actions:",
+ MSYMBOL_NAME (ic_info->state->name));
+ take_action_list (ic, ic_info->state_hook);
+ ic_info->state_hook = NULL;
+ }
+
MDEBUG_PRINT2 (" [IM] [%s] handle `%s'",
MSYMBOL_NAME (ic_info->state->name), msymbol_name (key));
&& ic_info->key_head < ic_info->used)
{
MDEBUG_PRINT (" unhandled\n");
+ ic_info->state_hook = map->map_actions;
return -1;
}