Exemplo n.º 1
0
const char *
get_imlist(const char *args)
{
    int i, nr;
    uim_context uc;

    if (!vp_iobuf_get_args(iobuf, args, ""))
        return vp_iobuf_return(iobuf);

    uc = uim_create_context(NULL, "UTF-8", NULL, NULL, NULL, NULL);
    if (uc == NULL)
        return "uim_create_context error";

    /* [method, langs, desc, is_default] */
    nr = uim_get_nr_im(uc);
    for (i = 0; i < nr; ++i) {
        vp_iobuf_put_str(iobuf, uim_get_im_name(uc, i));
        vp_iobuf_put_str(iobuf, uim_get_im_language(uc, i));
        vp_iobuf_put_str(iobuf, uim_get_im_short_desc(uc, i));
        vp_iobuf_put_num(iobuf, (strcmp(uim_get_im_name(uc, i),
                                        uim_get_default_im_name("")) == 0));
    }

    uim_release_context(uc);

    return vp_iobuf_return(iobuf);
}
Exemplo n.º 2
0
QStringList UimInputContextPlugin::createLanguageList( const QString &key ) const
{
    if ( key == "uim" )
        return QStringList() << "ja" << "ko" << "zh" << "*";

#if UIM_QT_LIST_SUBIM_AS_QTIM
    uim_context tmp_uc = uim_create_context( 0, "UTF-8",
                         0, 0, uim_iconv, 0 );
    int nr = uim_get_nr_im( tmp_uc );
    if ( uimReady )
    {
        for ( int i = 0; i < nr; i++ )
        {
            const char *name = uim_get_im_name( tmp_uc, i );
            const char *lang = uim_get_im_language( tmp_uc, i );

            if ( key == QString( "uim-" ) + name )
            {
                // ":" separated languages for future extension
                QStringList langs = QString( lang ).split( ':' );
                return langs;
            }
        }
    }
    uim_release_context( tmp_uc );
#endif

    return QStringList( "" );
}
Exemplo n.º 3
0
QStringList UimInputContextPlugin::createImList() const
{
    QStringList lst;

    // default
    lst.append( "uim" );
#ifdef ENABLE_DEBUG
    qDebug( "name = uim" );
#endif

#if UIM_QT_LIST_SUBIM_AS_QTIM
    uim_context tmp_uc = uim_create_context( 0, "UTF-8",
                         0, 0, uim_iconv, 0 );
    int nr = uim_get_nr_im( tmp_uc );
    if ( uimReady )
    {
        for ( int i = 0; i < nr; i++ )
        {
            const char *name = uim_get_im_name( tmp_uc, i );
            QString qs( name );
            qs = "uim-" + qs;
            lst << qs;

#ifdef ENABLE_DEBUG
            qDebug( "name = %s", qs.toUtf8().data() );
#endif
        }
    }
    uim_release_context( tmp_uc );
#endif

    return lst;
}
Exemplo n.º 4
0
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);
}
Exemplo n.º 5
0
void
QUimInfoManager::initUimInfo()
{
    info.clear();

    uim_context tmp_uc = uim_create_context( 0, "UTF-8", 0, 0, 0, 0 );
    struct uimInfo ui;
    int nr = uim_get_nr_im( tmp_uc );
    for ( int i = 0; i < nr; i++ )
    {
        ui.name = uim_get_im_name( tmp_uc, i );
        ui.lang = uim_get_im_language (tmp_uc, i );
        ui.short_desc = uim_get_im_short_desc( tmp_uc, i );

        info.append( ui );
    }
    uim_release_context( tmp_uc );
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
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;

}
Exemplo n.º 9
0
Arquivo: main.cpp Projeto: dai-vdr/uim
static void
get_uim_info()
{
    int res;

    res = uim_init();
    if (res) {
	printf("Failed to init uim\n");
	exit(1);
    }
    uim_context uc = uim_create_context(NULL, "UTF-8", NULL,
					NULL, uim_iconv, NULL);

    struct UIMInfo ui;

    int nr = uim_get_nr_im(uc);
    for (int i = 0; i < nr; i++) {
	ui.name = strdup(uim_get_im_name(uc, i));
	ui.lang = strdup(uim_get_im_language(uc, i));
	ui.desc = strdup(uim_get_im_short_desc(uc, i));
	uim_info.push_back(ui);
    }
    uim_release_context(uc);
}
Exemplo n.º 10
0
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;
}