Exemple #1
0
static uim_lisp
get_nr_predictions(uim_lisp ac_)
{
#ifdef HAS_ANTHY_PREDICTION
  anthy_context_t ac;
  struct anthy_prediction_stat ps;
  int err;

  ac = get_anthy_context(ac_);

  err = anthy_get_prediction_stat(ac, &ps);
  if (err)
    uim_fatal_error("anthy_get_prediction_stat() failed");
  return MAKE_INT(ps.nr_prediction);
#else
  return uim_scm_f();
#endif
}
Exemple #2
0
void
Conversion::predict (void)
{
    clear ();

#ifdef HAS_ANTHY_PREDICTION
    std::string str;

    str = m_reading.get_by_char ();
    anthy_set_prediction_string (m_anthy_context, str.c_str ());

    struct anthy_prediction_stat ps;
    anthy_get_prediction_stat (m_anthy_context, &ps);
    if (ps.nr_prediction > 0)
        m_predicting = true;
    else
        anthy_reset_context (m_anthy_context);
#endif /* HAS_ANTHY_PREDICTION */
}
Exemple #3
0
//
// candidates for a segment or prediction
//
void
Conversion::get_candidates (FcitxCandidateWordList *table, int segment_id)
{
    FcitxCandidateWordReset(table);
    int selected = get_selected_candidate();

    if (is_predicting ()) {
#ifdef HAS_ANTHY_PREDICTION
        std::string str;
        struct anthy_prediction_stat ps;

        anthy_get_prediction_stat (m_anthy_context, &ps);

        for (int i = 0; i < ps.nr_prediction; i++) {
            int len = anthy_get_prediction (m_anthy_context, i, NULL, 0);
            if (len <= 0)
                continue;

            char buf[len + 1];
            anthy_get_prediction (m_anthy_context, i, buf, len + 1);
            buf[len] = '\0';

            FcitxCandidateWord candWord;
            int *p = fcitx_utils_new(int);
            *p = i;
            candWord.callback = get_candidate;
            candWord.extraType = MSG_OTHER;
            candWord.owner = (void*) &m_anthy;
            candWord.priv = (void*) p;
            candWord.strExtra = NULL;
            candWord.strWord = strdup(buf);
            if (i == selected)
                candWord.wordType = MSG_CANDIATE_CURSOR;
            else
                candWord.wordType = MSG_OTHER;

            FcitxCandidateWordAppend(table, &candWord);
        }
#endif /* HAS_ANTHY_PREDICTION */
    } else if (is_converting ()) {