Esempio n. 1
0
void str_to_all_phokey_chars(char *u8_str, char *out)
{
  out[0]=0;

  while (*u8_str) {
    phokey_t phos[32];

    int n=utf8_pho_keys(u8_str, phos);
#if 0
    utf8_putchar(u8_str);
    dbg("n %d\n", n);
#endif
    int i;
    for(i=0; i < n; i++) {
      char *pstr = phokey_to_str(phos[i]);
      strcat(out, pstr);
      if (i < n -1)
        strcat(out, " ");
    }

    u8_str+=utf8_sz(u8_str);

    if (*u8_str)
      strcat(out, " | ");
  }
}
Esempio n. 2
0
static void cb_button_add(GtkButton *button, gpointer user_data)
{
    bigphoN = 0;
    char *p = current_str;
    while (*p) {
        char_pho *pbigpho = &bigpho[bigphoN++];

        if (ph_key_sz==2) {
            pbigpho->phokeysN = utf8_pho_keys(p, (phokey_t*)pbigpho->phokeys);
        } else {
            pbigpho->phokeysN = lookup_gtab_key(p, pbigpho->phokeys);
        }

        p+=utf8_sz(p);

        if (!pbigpho->phokeysN) {
            dbg(" no mapping to pho\n");
            return;
        }
    }

    GtkWidget *sel =  create_pho_sel_area();
    gtk_box_pack_start (GTK_BOX (hbox_buttons), sel, FALSE, FALSE, 20);

    gtk_widget_show_all(hbox_buttons);

}
Esempio n. 3
0
static void selection_received(GtkClipboard *pclip, const gchar *text, gpointer data)
{
  if (!text)
    return;

  char *outtext = NULL;
  int outlen = 0;

  while (*text) {
    char tt[CH_SZ * 5 * MAX_SAME_PHO + 1];
    int len = u8cpy(tt, (char *)text);
    tt[len]=0;

    phokey_t phokeys[MAX_SAME_PHO];
    int phokeysN = utf8_pho_keys((char *)text, phokeys);

    int i;
    for(i=0; i <phokeysN ;i++) {
      char *phostr;

      if (b_pinyin)
        phostr = phokey2pinyin(phokeys[i]);
      else
        phostr = phokey_to_str(phokeys[i]);

      strcat(tt, phostr);
    }

    int ttlen = strlen(tt);
    outtext = (char *)realloc(outtext, outlen + ttlen + 1);

    memcpy(outtext + outlen, tt, ttlen);
    outlen+=ttlen;

    text += len;
  }

  outtext[outlen]=0;

  gtk_text_buffer_set_text (buffer, outtext, -1);
  free(outtext);

  all_wrap();
}
Esempio n. 4
0
static void cb_button_add(GtkButton *button, gpointer user_data)
{
  GtkTextIter start, end;

  if (!gtk_text_buffer_get_selection_bounds(buffer, &start, &end))
    return;

  char *utf8 = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
  strcpy(current_str, utf8);

  g_free(utf8);

  bigphoN = 0;
  char *p = current_str;
  while (*p) {
    char_pho *pbigpho = &bigpho[bigphoN++];

    if (ph_key_sz==2) {
      pbigpho->phokeysN = utf8_pho_keys(p, (phokey_t*)pbigpho->phokeys);
    } else {
      pbigpho->phokeysN = lookup_gtab_key(p, pbigpho->phokeys);
    }

    p+=utf8_sz(p);

    if (!pbigpho->phokeysN) {
      dbg(" no mapping to pho\n");
      return;
    }
  }

  GtkWidget *sel =  create_pho_sel_area();
  gtk_box_pack_start (GTK_BOX (hbox_buttons), sel, FALSE, FALSE, 20);

  gtk_widget_show_all(hbox_buttons);

}