From afbd27bfeeed66d366f51f71c56085ab62670430 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 8 May 2013 11:37:19 +0900 Subject: [PATCH] check reverse question mark and exclamation mark to check autoperiod Change-Id: Iee59319a7e9cdd8453c4d76c3c32c6377ca9ae6c --- ism/extras/efl_immodule/isf_imf_context.cpp | 37 +++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ism/extras/efl_immodule/isf_imf_context.cpp b/ism/extras/efl_immodule/isf_imf_context.cpp index cd2d787..19d1fce 100644 --- a/ism/extras/efl_immodule/isf_imf_context.cpp +++ b/ism/extras/efl_immodule/isf_imf_context.cpp @@ -553,6 +553,18 @@ set_prediction_allow (Ecore_IMF_Context *ctx, bool prediction) } } +static Eina_Bool +check_symbol (Eina_Unicode ucode, Eina_Unicode symbols[], int symbol_num) +{ + for (int i = 0; i < symbol_num; i++) { + // Check symbol + if (ucode == symbols[i]) + return EINA_TRUE; + } + + return EINA_FALSE; +} + static void autoperiod_insert (Ecore_IMF_Context *ctx) { @@ -561,6 +573,11 @@ autoperiod_insert (Ecore_IMF_Context *ctx) int cursor_pos = 0; Eina_Unicode *ustr = NULL; Ecore_IMF_Event_Delete_Surrounding ev; + Eina_Unicode symbols[] = {':', ';', '.', '!', '?', 0x00BF /* ¿ */, 0x00A1 /* ¡ */}; + const int symbol_num = sizeof (symbols) / sizeof (symbols[0]); + + if (autoperiod_allow == EINA_FALSE) + return; if (!ctx) return; @@ -568,9 +585,6 @@ autoperiod_insert (Ecore_IMF_Context *ctx) if (layout != ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL) return; - if (autoperiod_allow == EINA_FALSE) - return; - if ((ecore_time_get () - space_key_time) > DOUBLE_SPACE_INTERVAL) goto done; @@ -587,10 +601,8 @@ autoperiod_insert (Ecore_IMF_Context *ctx) if (cursor_pos < 2) goto done; - if (((ustr[cursor_pos-2] != ':') && (ustr[cursor_pos-2] != ';') && - (ustr[cursor_pos-2] != '.') && (ustr[cursor_pos-2] != ',') && - (ustr[cursor_pos-2] != '?') && (ustr[cursor_pos-2] != '!') && - (ustr[cursor_pos-2] != ' ')) && ((ustr[cursor_pos-1] == ' ') || (ustr[cursor_pos-1] == '\240'))) { + if (((ustr[cursor_pos-1] == ' ') || (ustr[cursor_pos-1] == 0x00A0)) && + (!check_symbol (ustr[cursor_pos-2], symbols, symbol_num))) { ev.ctx = ctx; ev.n_chars = 1; ev.offset = -1; @@ -599,7 +611,7 @@ autoperiod_insert (Ecore_IMF_Context *ctx) ecore_imf_context_commit_event_add (ctx, "."); ecore_imf_context_event_callback_call (ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)"."); - } + } done: if (markup_str) free (markup_str); @@ -618,7 +630,7 @@ analyze_surrounding_text (Ecore_IMF_Context *ctx) Eina_Bool ret = EINA_FALSE; Eina_Bool detect_space = EINA_FALSE; int cursor_pos = 0; - int i = 0, j = 0; + int i = 0; const int punc_num = sizeof (puncs) / sizeof (puncs[0]); EcoreIMFContextISF *context_scim; @@ -678,15 +690,14 @@ analyze_surrounding_text (Ecore_IMF_Context *ctx) continue; } - for (j = 0; j < punc_num; j++) { + if (check_symbol (ustr[i-1], puncs, punc_num)) { // Check punctuation and following the continuous space(s) - if ((ustr[i-1] == puncs[j]) && (detect_space == EINA_TRUE)) { + if ((detect_space == EINA_TRUE)) { ret = EINA_TRUE; goto done; } } - - if (j == punc_num) { + else { // other character break; } -- 2.7.4