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
static uim_lisp
get_nth_candidate(uim_lisp ac_, uim_lisp seg_, uim_lisp nth_)
{
  anthy_context_t ac;
  int seg, nth, buflen;
  char *buf;
  uim_lisp buf_;
  
  ac = get_anthy_context(ac_);
  seg = C_INT(seg_);
  nth  = C_INT(nth_);

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

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

  return buf_;
}
Exemple #3
0
static uim_lisp
get_left_of_candidate(uim_lisp id_)
{
  int id, i;
  uim_lisp buf_;
  char *buf, *p;
  MInputContext *ic;

  id = C_INT(id_);
  ic = ic_array[id].mic;

  if (!ic)
    return MAKE_STR("");

  if (ic->candidate_from == 0)
    return MAKE_STR("");

  buf = convert_mtext2str(ic->preedit);
  p = buf;

  for (i = 0; i < ic->candidate_from ;i++)
    p = m17nlib_utf8_find_next_char(p);
  *p = '\0';

  buf_ = MAKE_STR_DIRECTLY(buf);

  return buf_;
}
Exemple #4
0
static uim_lisp
uim_ext_iconv_code_conv(uim_lisp ic_, uim_lisp inbuf_)
{
  char *outbuf;

  outbuf = uim_iconv_code_conv(C_PTR(ic_), REFER_C_STR(inbuf_));
  if (!outbuf)
    return uim_scm_f();

  return MAKE_STR_DIRECTLY(outbuf);
}
Exemple #5
0
static uim_lisp
im_acquire_text(uim_lisp uc_, uim_lisp text_id_, uim_lisp origin_,
                uim_lisp former_len_, uim_lisp latter_len_)
{
    uim_context uc;
    int err, former_len, latter_len;
    enum UTextArea text_id;
    enum UTextOrigin origin;
    char *former, *latter, *cv_former, *cv_latter;
    uim_lisp former_, latter_;

    uc = retrieve_uim_context(uc_);

    if (!uc->acquire_text_cb)
        return uim_scm_f();

    text_id = C_INT(text_id_);
    origin = C_INT(origin_);
    former_len = C_INT(former_len_);
    latter_len = C_INT(latter_len_);

    err = uc->acquire_text_cb(uc->ptr, text_id, origin,
                              former_len, latter_len, &former, &latter);
    if (err)
        return uim_scm_f();

    /* FIXME: string->list is not applied here for each text part. This
     * interface should be revised when SigScheme has been introduced to
     * uim. Until then, perform character separation by each input methods if
     * needed.  -- YamaKen 2006-10-07 */
    cv_former = uc->conv_if->convert(uc->inbound_conv, former);
    cv_latter = uc->conv_if->convert(uc->inbound_conv, latter);
    free(former);
    free(latter);
    former_
        = (TEXT_EMPTYP(cv_former)) ? uim_scm_null() : LIST1(MAKE_STR_DIRECTLY(cv_former));
    latter_
        = (TEXT_EMPTYP(cv_latter)) ? uim_scm_null() : LIST1(MAKE_STR_DIRECTLY(cv_latter));

    return uim_scm_callf("ustr-new", "oo", former_, latter_);
}