const char * create_context(const char *args) { char *method; char *lang; ic_t *ic; if (!vp_iobuf_get_args(iobuf, args, "ss", &method, &lang)) return vp_iobuf_return(iobuf); ic = malloc(sizeof(ic_t)); if (ic == NULL) return "malloc error"; ic->cand_index = 0; ic->cand_nr = 0; ic->cand_limit = 0; ic->cx = uim_create_context(ic, "UTF-8", lang, method, NULL, commit_cb); if (ic->cx == NULL) { free(ic); return "uim_create_context error"; } /* Install callback functions */ uim_set_preedit_cb(ic->cx, preedit_clear_cb, preedit_pushback_cb, preedit_update_cb); uim_set_candidate_selector_cb(ic->cx, candidate_activate_cb, candidate_select_cb, candidate_shift_page_cb, candidate_deactivate_cb); uim_set_prop_list_update_cb(ic->cx, property_list_update_cb); /* * Turn on Input Mode. * TODO: Use proper method. "action" can be used? */ uim_scm_call_with_gc_ready_stack( (uim_gc_gate_func_ptr)uim_scm_eval_c_string, (void*) "(if (and (symbol-bound? 'generic-on-key) generic-on-key)" " (let* ((id (context-id (car context-list)))" " (parsed (parse-key-str (car generic-on-key) () -1 0))" " (key (list-ref parsed 2))" " (mod (list-ref parsed 3)))" " (key-press-handler id key mod)" " (key-release-handler id key mod)" " ))" ); vp_iobuf_put_str(iobuf, "create_context"); vp_iobuf_put_ptr(iobuf, ic); return vp_iobuf_return(iobuf); }
static void init_agent() { uim_context uc; int i, nr; if (uim_init() == -1) { printf("failed to init\n"); exit(EXIT_FAILURE); } /**/ uc =uim_create_context(&default_context, "EUC-JP", NULL, NULL, uim_iconv, commit_cb); nr = uim_get_nr_im(uc); for (i = 0; i < nr; i++) { printf("%s\n", uim_get_im_name(uc, i)); } uim_set_preedit_cb(uc, clear_cb, pushback_cb, update_cb); default_context.uc = uc; default_context.next = NULL; }
uim_context QUimInputContext::createUimContext( const char *imname ) { m_imname = imname; uim_context uc = uim_create_context( this, "UTF-8", NULL, ( char * ) imname, NULL, QUimInputContext::commit_cb ); m_HelperManager->checkHelperConnection(); /**/ uim_set_preedit_cb( uc, QUimInputContext::clear_cb, QUimInputContext::pushback_cb, QUimInputContext::update_cb ); uim_set_candidate_selector_cb( uc, QUimInputContext::cand_activate_cb, QUimInputContext::cand_select_cb, QUimInputContext::cand_shift_page_cb, QUimInputContext::cand_deactivate_cb ); uim_set_prop_list_update_cb( uc, QUimHelperManager::update_prop_list_cb ); uim_set_prop_label_update_cb( uc, QUimHelperManager::update_prop_label_cb ); uim_set_im_switch_request_cb( uc, QUimInputContext::switch_app_global_im_cb, QUimInputContext::switch_system_global_im_cb); uim_set_text_acquisition_cb( uc, QUimTextUtil::acquire_text_cb, QUimTextUtil::delete_text_cb); uim_prop_list_update( uc ); return uc; }
uim_context create_context(const char *encoding, uim_agent_context *ptr) { uim_context context; context = uim_create_context(ptr, encoding, NULL, NULL, /*default_engine_name,*/ uim_iconv, commit_cb); uim_set_preedit_cb(context, preedit_clear_cb, preedit_pushback_cb, preedit_update_cb); uim_set_candidate_selector_cb(context, candidate_activate_cb, candidate_select_cb, candidate_shift_page_cb, candidate_deactivate_cb); uim_set_prop_list_update_cb(context, prop_list_update_cb); uim_set_configuration_changed_cb(context, configuration_changed_cb); uim_set_im_switch_request_cb(context, switch_app_global_im_cb, switch_system_global_im_cb); return context; }
void InputContext::createUimContext(const char *engine) { char *locale; const char *client_locale, *engine_locales; const char *encoding; const char *real_im; encoding = mXic->get_encoding(); client_locale = mXic->get_lang_region(); engine_locales = compose_localenames_from_im_lang(get_im_lang_from_engine(engine)); if (!strcmp(encoding, "UTF-8")) { real_im = engine; if (is_locale_included(engine_locales, client_locale)) locale = strdup(client_locale); else { locale = get_prefered_locale(engine_locales); } } else { // Use default engine for corresponding encoding of the client // unless encoding matches with selected engine. if (!is_locale_included(engine_locales, client_locale)) { const char *test_im = uim_get_default_im_name(client_locale); const char *test_im_lang = get_im_lang_from_engine(test_im); const char *test_im_locales = compose_localenames_from_im_lang(test_im_lang); if (is_locale_included(test_im_locales, client_locale)) real_im = test_im; else real_im = uim_get_im_name_for_locale(client_locale); } else real_im = engine; locale = strdup(client_locale); } locale = (char *)realloc(locale, strlen(locale) + strlen(encoding) + 2); strcat(locale, "."); strcat(locale, encoding); setlocale(LC_CTYPE, locale); free(mLocaleName); mLocaleName = locale; if (mEngineName != real_im) { free(mEngineName); mEngineName = strdup(real_im); } uim_context uc = uim_create_context((void *) this, "UTF-8", NULL, real_im, NULL, InputContext::commit_cb); if (uc) { uim_set_preedit_cb(uc, InputContext::clear_cb, InputContext::pushback_cb, InputContext::update_cb); uim_set_candidate_selector_cb(uc, InputContext::candidate_activate_cb, InputContext::candidate_select_cb, InputContext::candidate_shift_page_cb, InputContext::candidate_deactivate_cb); uim_set_prop_list_update_cb(uc, InputContext::update_prop_list_cb); #if 0 uim_set_prop_label_update_cb(uc, InputContext::update_prop_label_cb); #endif uim_set_configuration_changed_cb(uc, InputContext::configuration_changed_cb); uim_set_im_switch_request_cb(uc, InputContext::switch_app_global_im_cb, InputContext::switch_system_global_im_cb); #if UIM_XIM_USE_DELAY uim_set_delay_candidate_selector_cb(uc, InputContext::candidate_activate_with_delay_cb); #endif if (mFocusedContext == this) uim_prop_list_update(uc); } mUc = uc; }