int ch_to_gtab_keys(INMD *tinmd, char *ch, u_int64_t keys[]) { int n = utf8_str_N(ch); gboolean phrase = n > 1 || !(ch[0] & 0x80); int i, keysN=0; for(i=0; i < tinmd->DefChars; i++) { char *chi = (char *)tblch2(tinmd, i); if (phrase) { if ((chi[0] & 0x80)) continue; char tstr[512]; load_phr_ch(tinmd, (u_char *)chi, tstr); if (strcmp(tstr, ch)) continue; } else { if (!(chi[0] & 0x80)) continue; if (!utf8_eq(chi, ch)) continue; } u_int64_t key = CONVT2(tinmd, i); keys[keysN++] = key; } return keysN; }
static void putstr_inp(char *p) { clear_page_label(); // dbg("gtab_hide_row2 %d\n", gtab_hide_row2); hide_row2_if_necessary(); char_play(p); int to_tsin = (cur_inmd->flag & FLAG_GTAB_SYM_KBM) && inmd[default_input_method].method_type==method_type_TSIN && tss.c_len; if (utf8_str_N(p) > 1 || !(p[0]&128)) { if ((gtab_disp_key_codes && !gtab_hide_row2) || ggg.wild_mode) lookup_gtabn(p, NULL); if (to_tsin) { add_to_tsin_buf_str(p); } else send_text(p); } else { if (poo.same_pho_query_state == SAME_PHO_QUERY_gtab_input) { poo.same_pho_query_state = SAME_PHO_QUERY_pho_select; start_gtab_pho_query(p); ClrIn(); ClrSelArea(); return; } if ((gtab_disp_key_codes && !gtab_hide_row2) || ggg.wild_mode) lookup_gtab(p); if (to_tsin) add_to_tsin_buf_str(p); else send_utf8_ch(p); } clear_after_put(); if ((cur_inmd->flag & FLAG_GTAB_SYM_KBM)) { extern int win_kbm_inited, b_show_win_kbm; init_in_method(default_input_method); if (win_kbm_inited && !b_show_win_kbm) hide_win_kbm(); } }
int main() { FILE *fp; if ((fp=fopen("tsin.src", "r"))==NULL) p_err("cannot open"); while (!feof(fp)) { char aa[128]; char bb[128]; int usecount; char line[256]; fgets(line, sizeof(line), fp); sscanf(line, "%s %s %d", aa, bb, &usecount); if (utf8_str_N(aa)==1) printf("%s", line); } return 0; }
void create_win_sym() { if (!current_CS) { dbg("create_win_sym, null CS\n"); return; } if (current_CS->in_method < 0 || current_CS->in_method >= MAX_GTAB_NUM_KEY) { p_err("bad current_CS %d\n", current_CS->in_method); } if (current_method_type() != method_type_PHO && current_method_type() != method_type_TSIN && current_method_type() != method_type_ANTHY && !cur_inmd) return; if (read_syms() || cur_in_method != current_CS->in_method) { destory_win(); } else { if (!syms) return; } if (gwin_sym) { if (win_sym_enabled) show_win_sym(); else hide_win_sym(); return; } gwin_sym = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_has_resize_grip(GTK_WINDOW(gwin_sym), FALSE); #if WIN32 set_no_focus(gwin_sym); #endif cur_in_method = current_CS->in_method; GtkWidget *hbox_top = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (gwin_sym), hbox_top); GtkWidget *vbox_top = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox_top), vbox_top, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox_top), 0); int i; for(i=0; i < symsN; i++) { SYM_ROW *psym = &syms[i]; GtkWidget *hbox_row = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox_top), hbox_row, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox_row), 0); int j; for(j=0; j < psym->symN; j++) { char *str = psym->sym[j]; if (!str[0]) continue; GtkWidget *button = gtk_button_new(); GtkWidget *label = gtk_label_new(str); gtk_container_add(GTK_CONTAINER(button), label); set_label_font_size(label, gcin_font_size_symbol); gtk_container_set_border_width (GTK_CONTAINER (button), 0); gtk_box_pack_start (GTK_BOX (hbox_row), button, FALSE, FALSE, 0); if (utf8_str_N(str) > 0) { char phos[512]; sym_lookup_key(str, phos); int phos_len = strlen(phos); if (phos_len) { #if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text (button, phos); #else GtkTooltips *button_pho_tips = gtk_tooltips_new (); gtk_tooltips_set_tip (GTK_TOOLTIPS (button_pho_tips), button, phos, NULL); #endif } } g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (cb_button_sym), label); } } gtk_box_pack_start (GTK_BOX (hbox_top), gtk_vseparator_new(), FALSE, FALSE, 0); GtkWidget *vbox_arrow = gtk_vbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox_top), vbox_arrow, TRUE, TRUE, 0); GtkWidget *eve_up=gtk_event_box_new(), *eve_down=gtk_event_box_new(); gtk_box_pack_start (GTK_BOX (vbox_arrow), eve_up, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(eve_up), gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_IN)); gtk_box_pack_start (GTK_BOX (vbox_arrow), eve_down, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(eve_down), gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN)); g_signal_connect(G_OBJECT(eve_up),"button-press-event", G_CALLBACK(mouse_button_callback_up_down), (gpointer)1); g_signal_connect(G_OBJECT(eve_down),"button-press-event", G_CALLBACK(mouse_button_callback_up_down), NULL); gtk_widget_realize (gwin_sym); #if UNIX GdkWindow *gdkwin_sym = gtk_widget_get_window(gwin_sym); set_no_focus(gwin_sym); #else win32_init_win(gwin_sym); #endif if (win_sym_enabled) gtk_widget_show_all(gwin_sym); g_signal_connect (G_OBJECT (gwin_sym), "scroll-event", G_CALLBACK (button_scroll_event), NULL); move_win_sym(); #if 0 dbg("in_method:%d\n", current_CS->in_method); #endif return; }