Exemplo n.º 1
0
// FIXME: the pos of g_pSeg[].label is not correct
static gboolean
gcin_label_cand_show (char *pszWord, int nIdx)
{
    int nX, nY;
    int nFontWidth, nFontHeight;

    g_gcinModMainFuncs.mf_set_sele_text (nIdx,
                                         pszWord,
                                         -1);

    // find the position of the cand win
    g_gcinModMainFuncs.mf_get_widget_xy (g_pWinChewing,
                                         g_pSeg[g_nCurrentCursorPos].label,
                                         &nX, &nY);

    gtk_pango_font_pixel_size_get (&nFontWidth, &nFontHeight);
    nX += g_nCurrentCursorPos * nFontWidth;

    nY = g_gcinModMainFuncs.mf_gcin_edit_display_ap_only () ?
         *g_gcinModMainFuncs.mf_win_y :
         *g_gcinModMainFuncs.mf_win_y + *g_gcinModMainFuncs.mf_win_yl;

    g_gcinModMainFuncs.mf_disp_selections (nX, nY);

    return TRUE;
}
Exemplo n.º 2
0
static void disp_select()
{
//  puts("disp_select");
  gmf.mf_clear_sele();
  int endn = pageidx + gmf.mf_phkbm->selkeyN;
  if (endn >  seg[cursor].selN)
    endn = seg[cursor].selN;
  int i;
  for(i=pageidx; i<endn; i++) {
    char buf[256];
    anthy_get_segment(ac, cursor, i, buf, sizeof(buf));
//    printf("%d %s\n", i, buf);
    gmf.mf_set_sele_text(seg[cursor].selN, i - pageidx, buf, -1);
  }

  if (pageidx)
    gmf.mf_disp_arrow_up();
  if (i < seg[cursor].selN)
    gmf.mf_disp_arrow_down();

  int x,y;
  gmf.mf_get_widget_xy(win_anthy, seg[cursor].label, &x, &y);
//  printf("%x cusor %d %d\n", win_anthy, cursor, x);
  y = gmf.mf_gcin_edit_display_ap_only()?
    *gmf.mf_win_y:*gmf.mf_win_y+*gmf.mf_win_yl;
  gmf.mf_disp_selections(x, y);
}
Exemplo n.º 3
0
static void disp_input()
{
  int i;

  if (gmf.mf_gcin_edit_display_ap_only())
    return;

  clear_seg_label();

  int idx;
  for(idx=i=0; i < jpN; i++) {
    if (i==cursor) {
      disp_keys(idx);
      idx+=keysN;
      cursor_markup(idx++, idx_hira_kata(jp[i], FALSE));
    }
    else
      gtk_label_set_text(GTK_LABEL(seg[idx++].label), idx_hira_kata(jp[i], FALSE));
  }

  if (cursor==jpN) {
    disp_keys(idx);
    idx+=keysN;
    cursor_markup(idx, " ");
  }

  minimize_win_anthy();
}
Exemplo n.º 4
0
void module_show_win()
{
  if (gmf.mf_gcin_edit_display_ap_only())
    return;
  if (!*gmf.mf_gcin_pop_up_win || !is_empty() || *gmf.mf_force_show ) {
    if (!module_win_visible())
      gtk_widget_show(win_anthy);
    gmf.mf_show_win_sym();
  }
}
Exemplo n.º 5
0
void
module_show_win (void)
{
    if (g_gcinModMainFuncs.mf_gcin_edit_display_ap_only ())
        return;

    if (is_empty ())
        return;

    gtk_window_resize (GTK_WINDOW (g_pWinChewing),
                       32 * (chewing_buffer_Check (g_pChewingCtx) + 1),
                       12);
    gtk_widget_show (g_pWinChewing);

    g_gcinModMainFuncs.mf_show_win_sym ();
}
Exemplo n.º 6
0
int module_get_preedit(char *str, GCIN_PREEDIT_ATTR attr[], int *pcursor, int *comp_flag)
{
  int i;

//  dbg("anthy_get_preedit %d\n", cursor);
  str[0]=0;
  *pcursor=0;

  attr[0].flag=GCIN_PREEDIT_ATTR_FLAG_UNDERLINE;
  attr[0].ofs0=0;
  int attrN=0;
  int ch_N=0;

  if (state==STATE_CONVERT) {
    if (segN)
      attrN=1;

    for(i=0; i < segN; i++) {
      char *s = (char *)gtk_label_get_text(GTK_LABEL(seg[i].label));
      int N = gmf.mf_utf8_str_N(s);
      ch_N+=N;
      if (i < cursor)
        *pcursor+=N;
      if (gmf.mf_gcin_edit_display_ap_only() && i==cursor) {
        attr[1].ofs0=*pcursor;
        attr[1].ofs1=*pcursor+N;
        attr[1].flag=GCIN_PREEDIT_ATTR_FLAG_REVERSE;
        attrN++;
      }
      strcat(str, s);
    }

    attr[0].ofs1 = ch_N;
  } else {
    if (jpN)
      attrN=1;

    keys[keysN]=0;

    for(i=0;i < jpN; i++) {
      char *s=idx_hira_kata(jp[i], FALSE);

      int N = gmf.mf_utf8_str_N(s);
//      dbg("%d]%s N:%d\n", i, s, N);
      if (gmf.mf_gcin_edit_display_ap_only() && i==cursor) {
        strcat(str, keys);
        ch_N+=keysN;
        *pcursor = ch_N;
        attr[1].ofs0=ch_N;
        attr[1].ofs1=ch_N+N;
        attr[1].flag=GCIN_PREEDIT_ATTR_FLAG_REVERSE;
        attrN++;
      }
      strcat(str, s);
      ch_N+=N;
    }

    if (cursor==jpN) {
      *pcursor = ch_N;
      strcat(str, keys);
      ch_N+=keysN;
    }

    attr[0].ofs1 = ch_N;
//    dbg("cursor %d  ch_N:%d  '%s'\n", *pcursor, ch_N, str);
  }

  *comp_flag = keysN>0;
  if (win_anthy && GTK_WIDGET_VISIBLE(win_anthy))
    *comp_flag|=2;
  if (segN || jpN)
    *comp_flag|=4;

  return attrN;
}