From: ntakahas Date: Wed, 30 Aug 2006 10:55:20 +0000 (+0000) Subject: Return -2 when surrounding text is unavailable. X-Git-Tag: REL-1-3-4~87 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cf567bbabda619fe4d2bf084dc3dd3175005094;p=m17n%2Fm17n-lib.git Return -2 when surrounding text is unavailable. --- diff --git a/src/input.c b/src/input.c index ea21047..ad4e5c2 100644 --- a/src/input.c +++ b/src/input.c @@ -479,8 +479,8 @@ get_surrounding_text (MInputContext *ic, int len) MText *mt = NULL; mplist_push (ic->plist, Minteger, (void *) len); - minput__callback (ic, Minput_get_surrounding_text); - if (MPLIST_MTEXT_P (ic->plist)) + if (minput__callback (ic, Minput_get_surrounding_text) >= 0 + && MPLIST_MTEXT_P (ic->plist)) mt = MPLIST_MTEXT (ic->plist); mplist_pop (ic->plist); return mt; @@ -515,7 +515,7 @@ get_preceding_char (MInputContext *ic, int pos) } mt = get_surrounding_text (ic, - pos); if (! mt) - return -1; + return -2; len = mtext_nchars (mt); if (ic_info->preceding_text) { @@ -547,7 +547,7 @@ get_following_char (MInputContext *ic, int pos) } mt = get_surrounding_text (ic, pos); if (! mt) - return -1; + return -2; len = mtext_nchars (mt); if (ic_info->following_text) { @@ -3183,18 +3183,19 @@ minput__fini () M17N_OBJECT_UNREF (load_im_info_keys); } -void +int minput__callback (MInputContext *ic, MSymbol command) { - if (ic->im->driver.callback_list) - { - MInputCallbackFunc func - = (MInputCallbackFunc) mplist_get (ic->im->driver.callback_list, - command); + MInputCallbackFunc func; - if (func) - (func) (ic, command); - } + 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 diff --git a/src/input.h b/src/input.h index 6533627..48b0a02 100644 --- a/src/input.h +++ b/src/input.h @@ -85,7 +85,7 @@ typedef struct #define MINPUT_KEY_SUPER_MODIFIER (1 << 4) #define MINPUT_KEY_HYPER_MODIFIER (1 << 5) -extern void minput__callback (MInputContext *ic, MSymbol command); +extern int minput__callback (MInputContext *ic, MSymbol command); extern MSymbol minput__char_to_key (int c); #endif /* not _M17N_INPUT_H_ */