Exemple #1
0
static uim_lisp
get_nth_prediction(uim_lisp ac_, uim_lisp nth_)
{
#ifdef HAS_ANTHY_PREDICTION
  anthy_context_t ac;
  int nth, buflen;
  char *buf;
  uim_lisp buf_;

  ac = get_anthy_context(ac_);
  nth = C_INT(nth_); 

  buflen = anthy_get_prediction(ac, nth, NULL, 0);
  if (buflen == -1)
    uim_fatal_error("anthy_get_prediction() failed");

  buf = uim_malloc(buflen + 1);
  buflen = anthy_get_prediction(ac, nth, buf, buflen + 1);
  if (buflen == -1) {
    free(buf);
    uim_fatal_error("anthy_get_prediction() failed");
  }
  buf_ = MAKE_STR_DIRECTLY(buf);

  return buf_;
#else
  return uim_scm_f();
#endif
}
Exemple #2
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 ()) {