void get_key_str(void *key, int idx, char *out_str) { char t[128]; char *phostr; if (is_gtab) { int tlen; u_int64_t key64; if (ph_key_sz == 4) { u_int32_t key32; cp_ph_key(key, idx, &key32); key64 = key32; } else cp_ph_key(key, idx, &key64); gtab_key2name(pinmd, key64, t, &tlen); phostr = t; } else { phokey_t k; cp_ph_key(key, idx, &k); phostr = b_pinyin? phokey2pinyin(k):phokey_to_str(k); } strcpy(out_str, phostr); }
GtkWidget *create_pho_sel_area() { hbox_pho_sel = gtk_hbox_new (FALSE, 0); int i; for(i=0; i < bigphoN; i++) { bigpho[i].opt_menu = gtk_combo_box_new_text (); gtk_box_pack_start (GTK_BOX (hbox_pho_sel), bigpho[i].opt_menu, FALSE, FALSE, 0); int j; for(j=0; j < bigpho[i].phokeysN; j++) { char t[128]; char *phostr; if (is_gtab) { int tlen; u_int64_t key64; if (ph_key_sz == 4) { u_int32_t key32; cp_ph_key(bigpho[i].phokeys,j, &key32); key64 = key32; } else cp_ph_key(bigpho[i].phokeys,j, &key64); gtab_key2name(pinmd, key64, t, &tlen); // dbg("%d,%d] %s\n", i,j, t); phostr = t; } else { phokey_t k; cp_ph_key(bigpho[i].phokeys, j, &k); phostr = b_pinyin? phokey2pinyin(k):phokey_to_str(k); } gtk_combo_box_append_text (GTK_COMBO_BOX_TEXT (bigpho[i].opt_menu), phostr); } gtk_combo_box_set_active (GTK_COMBO_BOX(bigpho[i].opt_menu), 0); } GtkWidget *button_ok = gtk_button_new_with_label("OK to add"); gtk_box_pack_start (GTK_BOX (hbox_pho_sel), button_ok, FALSE, FALSE, 20); g_signal_connect (G_OBJECT (button_ok), "clicked", G_CALLBACK (cb_button_ok), NULL); GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_box_pack_start (GTK_BOX (hbox_pho_sel), button_cancel, FALSE, FALSE, 20); g_signal_connect (G_OBJECT (button_cancel), "clicked", G_CALLBACK (cb_button_cancel), NULL); return hbox_pho_sel; }
void lookup_gtabn(char *ch, char *out) { char outbuf[512]; char *tbuf[128]; int tbufN=0; INMD *tinmd = &inmd[default_input_method]; if (!tinmd->DefChars) tinmd = cur_inmd; if (!tinmd) return; gboolean need_disp = FALSE; if (!out) { out = outbuf; need_disp = TRUE; } out[0]=0; int min_klen = 100; u_int64_t keys[64]; int keysN = ch_to_gtab_keys(tinmd, ch, keys); int i; for(i=0; i < keysN; i++) { int tlen, klen; char t[CH_SZ * 10 + 1]; klen = gtab_key2name(tinmd, keys[i], t, &tlen); if (klen < min_klen) min_klen = klen; t[tlen]=0; tbuf[tbufN] = strdup(t); tbufN++; } qsort(tbuf, tbufN, sizeof(char *), qcmp_strlen); out[0]=0; for(i=0; i < tbufN; i++) { #define MAX_DISP_MATCH 40 if (strlen(out) < MAX_DISP_MATCH) { strcat(out, tbuf[i]); if (i < tbufN-1) strcat(out, " |"); } free(tbuf[i]); } if (!out[0] || !need_disp) return; set_key_codes_label(out, ggg.ci > min_klen); void set_key_codes_label_pho(char *s); set_key_codes_label_pho(out); }