void flush_edit_buffer() { // dbg("flush_edit_buffer\n"); if (!current_CS) return; // dbg("hime_reset\n"); switch(current_method_type()) { #if USE_TSIN case method_type_TSIN: flush_tsin_buffer(); break; #endif case method_type_MODULE: if (inmd[current_CS->in_method].mod_cb_funcs) module_cb()->module_flush_input(); break; default: output_gbuf(); // dbg("metho %d\n", current_CS->in_method); } #if 0 dbg("output_bufferN:%d\n", output_bufferN); if (output_bufferN) { output_buffer_call_back(); } #endif }
void flush_edit_buffer() { // dbg("flush_edit_buffer\n"); if (!current_CS) return; // dbg("gcin_reset\n"); switch(current_method_type()) { #if USE_TSIN case method_type_TSIN: flush_tsin_buffer(); break; #endif #if USE_ANTHY case method_type_ANTHY: flush_anthy_input(); break; #endif default: output_gbuf(); // dbg("metho %d\n", current_CS->in_method); } #if 0 dbg("output_bufferN:%d\n", output_bufferN); if (output_bufferN) { output_buffer_call_back(); } #endif }
void toggle_im_enabled() { // dbg("toggle_im_enabled\n"); check_CS(); if (current_CS->in_method < 0 || current_CS->in_method > MAX_GTAB_NUM_KEY) p_err("err found"); if (current_CS->im_state != GCIN_STATE_DISABLED) { if (current_CS->im_state == GCIN_STATE_ENG_FULL) { current_CS->im_state = GCIN_STATE_CHINESE; disp_im_half_full(); return; } if (current_method_type() == method_type_TSIN) { #if USE_TSIN flush_tsin_buffer(); #endif } else { output_gbuf(); reset_gtab_all(); } hide_in_win(current_CS); #if 0 hide_win_status(); #endif current_CS->im_state = GCIN_STATE_DISABLED; update_win_kbm(); #if TRAY_ENABLED disp_tray_icon(); #endif } else { if (!current_method_type()) init_gtab(current_CS->in_method); init_state_chinese(current_CS); reset_current_in_win_xy(); #if 1 show_in_win(current_CS); update_in_win_pos(); #else update_in_win_pos(); show_in_win(current_CS); #endif update_win_kbm(); #if TRAY_ENABLED disp_tray_icon(); #endif } }
static void cb_button_sym(GtkButton *button, GtkWidget *label) { // dbg("cb_button_sym\n"); char *str = (char *) gtk_label_get_text(GTK_LABEL(label)); #if USE_TSIN if (current_method_type() == method_type_TSIN && current_CS->im_state == GCIN_STATE_CHINESE) { add_to_tsin_buf_str(str); if (tsin_cursor_end()) { flush_tsin_buffer(); output_buffer_call_back(); } else { force_preedit_shift(); } } else #endif if (gtab_phrase_on()) { insert_gbuf_nokey(str); if (gtab_cursor_end()) { output_gbuf(); output_buffer_call_back(); } else force_preedit_shift(); } else { send_text_call_back(str); } switch (current_method_type()) { case method_type_PHO: clr_in_area_pho(); break; #if USE_TSIN case method_type_TSIN: tsin_reset_in_pho(); break; #endif #if USE_ANTHY case method_type_ANTHY: break; #endif default: reset_gtab_all(); break; } if (gcin_win_sym_click_close) { win_sym_enabled=0; hide_win_sym(); } }
gboolean feed_phrase(KeySym ksym, int state) { int i; // dbg("ksym:%x %c\n", ksym, ksym); load_phrase("phrase.table", &file_modify_time, tran, tranN); load_phrase("phrase-ctrl.table", &ctrl_file_modify_time, tran_ctrl, tran_ctrlN); if (ksym < 0x7f && isupper(ksym)) ksym = tolower(ksym); struct keystruc *tr; int trN; if (state & ControlMask) { tr = tran_ctrl; trN = tran_ctrlN; } else { tr = tran; trN = tranN; } char tt[2], *str; for(i=0; i < trN; i++) { if (tr[i].ksym!= ksym) continue; str = ((state & LockMask) && tr[i].str_caps) ? tr[i].str_caps : tr[i].str; if (str) { send_it: #if USE_TSIN if (current_method_type() == method_type_TSIN && current_CS->im_state == GCIN_STATE_CHINESE) { add_to_tsin_buf_str(str); if (tsin_cursor_end()) flush_tsin_buffer(); } else #endif if (gtab_phrase_on()) { insert_gbuf_nokey(str); if (gtab_cursor_end()) output_gbuf(); } else send_text(str); return TRUE; } } #if 0 if ((state&(ControlMask|ShiftMask|Mod1Mask|Mod4Mask|Mod5Mask))==ShiftMask && ksym>=' ' && ksym < 0x7e) { str = tt; tt[0]=ksym; tt[1]=0; goto send_it; } #endif return FALSE; }
gboolean init_in_method(int in_no) { gboolean init_im = !(cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)); if (in_no < 0) return FALSE; check_CS(); if (current_CS->in_method != in_no) { if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) { if (current_method_type() == method_type_TSIN) { flush_tsin_buffer(); } else output_gbuf(); hide_in_win(current_CS); } if (cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)) hide_win_kbm(); } reset_current_in_win_xy(); // dbg("switch init_in_method %x %d\n", current_CS, in_no); set_tsin_pho_mode0(current_CS); tsin_set_win1_cb(); switch (inmd[in_no].method_type) { case method_type_PHO: current_CS->in_method = in_no; init_tab_pho(); break; case method_type_TSIN: set_wselkey(pho_selkey); current_CS->in_method = in_no; init_tab_pp(init_im); break; case method_type_MODULE: { HIME_module_main_functions gmf; init_HIME_module_main_functions(&gmf); if (!inmd[in_no].mod_cb_funcs) { char ttt[256]; strcpy(ttt, inmd[in_no].filename); dbg("module %s\n", ttt); if (!(inmd[in_no].mod_cb_funcs = init_HIME_module_callback_functions(ttt))) { dbg("module not found\n"); return FALSE; } } if (inmd[in_no].mod_cb_funcs->module_init_win(&gmf)) { current_CS->in_method = in_no; module_cb()->module_show_win(); set_wselkey(pho_selkey); } else { return FALSE; } break; } default: init_gtab(in_no); if (!inmd[in_no].DefChars) return FALSE; current_CS->in_method = in_no; if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) show_win_gtab(); else { win_kbm_inited = 1; show_win_kbm(); } set_gtab_input_method_name(inmd[in_no].cname); break; } #if WIN32 if (current_CS && current_CS->in_method != last_input_method) last_input_method = current_CS->in_method; #endif #if TRAY_ENABLED disp_tray_icon(); #endif if (inmd[current_CS->in_method].selkey) { set_wselkey(inmd[current_CS->in_method].selkey); gtab_set_win1_cb(); // dbg("aa selkey %s\n", inmd[current_CS->in_method].selkey); } update_in_win_pos(); update_win_kbm_inited(); return TRUE; }
void toggle_im_enabled() { // dbg("toggle_im_enabled\n"); check_CS(); if (current_CS->in_method < 0) p_err("err found"); if (current_CS->im_state != HIME_STATE_DISABLED) { if (current_CS->im_state == HIME_STATE_ENG_FULL) { current_CS->im_state = HIME_STATE_CHINESE; disp_im_half_full(); save_CS_current_to_temp(); return; } if (current_method_type() == method_type_TSIN) { #if USE_TSIN flush_tsin_buffer(); #endif } else if (current_method_type () == method_type_MODULE) { module_cb ()->module_flush_input (); } else { output_gbuf(); reset_gtab_all(); } hide_in_win(current_CS); #if 0 hide_win_status(); #endif current_CS->im_state = HIME_STATE_DISABLED; update_win_kbm(); #if TRAY_ENABLED disp_tray_icon(); #endif } else { if (!current_method_type()) init_gtab(current_CS->in_method); init_state_chinese(current_CS); reset_current_in_win_xy(); #if 1 show_in_win(current_CS); update_in_win_pos(); #else update_in_win_pos(); show_in_win(current_CS); #endif update_win_kbm(); #if TRAY_ENABLED disp_tray_icon(); #endif } save_CS_current_to_temp(); }
gboolean feedkey_gtab(KeySym key, int kbstate) { int i,j=0; int inkey=0; char *pselkey= NULL; gboolean phrase_selected = FALSE; char seltab_phrase[MAX_SELKEY]; gboolean is_keypad = FALSE; gboolean shift_m = (kbstate & ShiftMask) > 0; // gboolean ctrl_m = (kbstate & ControlMask) > 0; gboolean capslock_on = (kbstate & LockMask); bzero(seltab_phrase, sizeof(seltab_phrase)); // dbg("uuuuu %x %x shift,ctrl:%d,%d\n", key, kbstate, shift_m, ctrl_m); if (!cur_inmd) return 0; gboolean is_dayi = !strncmp(cur_inmd->filename, "dayi", 4); if ((tsin_chinese_english_toggle_key == TSIN_CHINESE_ENGLISH_TOGGLE_KEY_CapsLock) && (key == XK_Caps_Lock)){ // The CapLock status may be incorrect when XK_Caps_Lock is pressed. gboolean new_tsin_pho_mode = ! gdk_keymap_get_caps_lock_state(gdk_keymap_get_default()); if (current_CS->tsin_pho_mode != new_tsin_pho_mode) { current_CS->tsin_pho_mode = new_tsin_pho_mode; save_CS_current_to_temp(); tsin_set_eng_ch(new_tsin_pho_mode); } } if ((kbstate & (Mod1Mask|Mod4Mask|Mod5Mask|ControlMask))==ControlMask && key>='1' && key<='9' && ggg.gbufN) { save_gtab_buf_phrase(key); return 1; } if (ggg.gbufN && key==XK_Tab) return 1; if ((key==XK_Shift_L||key==XK_Shift_R) && !key_press_time) { key_press_time = current_time(); key_press_time_ctrl = 0; } else if ((key==XK_Control_L||key==XK_Control_R) && !key_press_time_ctrl && tss.pre_selN) { key_press_time_ctrl = current_time(); return TRUE; } else { key_press_time_ctrl = 0; key_press_time = 0; } if (kbstate & (Mod1Mask|Mod4Mask|Mod5Mask|ControlMask)) { return 0; } if (poo.same_pho_query_state == SAME_PHO_QUERY_pho_select) return feedkey_pho(key, 0); if (poo.same_pho_query_state == SAME_PHO_QUERY_none && gwin_pho && GTK_WIDGET_VISIBLE(gwin_pho)) hide_win_pho(); if (!tsin_pho_mode()) { if (key < 0x20 || key>=0x7f) goto shift_proc; if (capslock_on && hime_capslock_lower) case_inverse((KeySym *)&key, shift_m); if (ggg.gbufN) insert_gbuf_cursor_char(key); else send_ascii(key); return 1; } int lcase; lcase = tolower(key); int ucase; ucase = toupper(key); if (key < 127 && cur_inmd->keymap[key]) { if (key < 'A' || key > 'z' || (key > 'Z' && key < 'a') ) goto shift_proc; if (cur_inmd->keymap[lcase] != cur_inmd->keymap[ucase]) goto next; } shift_proc: if (shift_m && !strchr(cur_inmd->selkey, key) && !ggg.more_pg && key>=' ' && key < 0x7e && key!='*' && (key!='?' || (gtab_shift_phrase_key && !ggg.ci))) { if (gtab_shift_phrase_key) { if (tss.pre_selN && shift_char_proc(key, kbstate)) return TRUE; if (feed_phrase(key, kbstate)) return TRUE; } else { if (!cur_inmd->keymap[key] || (lcase != ucase && cur_inmd->keymap[lcase]==cur_inmd->keymap[ucase])) return shift_char_proc(key, kbstate); } } gboolean has_wild; has_wild = FALSE; switch (key) { case XK_BackSpace: ggg.last_idx=0; ggg.spc_pressed=0; ggg.sel1st_i=MAX_SELKEY-1; clear_gtab_input_error_color(); hide_gtab_pre_sel(); if (ggg.ci==0) { if (AUTO_SELECT_BY_PHRASE) return gtab_buf_backspace(); else return 0; } if (ggg.ci>0) ggg.inch[--ggg.ci]=0; if (has_wild_card()) { proc_wild_disp(); return 1; } ggg.wild_mode=0; ggg.invalid_spc = FALSE; if (ggg.ci==1 && cur_inmd->use_quick) { int i; clr_seltab(); for(i=0;i<cur_inmd->M_DUP_SEL;i++) utf8cpy(seltab[i], (char *)cur_inmd->qkeys->quick1[ggg.inch[0]-1][i]); ggg.defselN=cur_inmd->M_DUP_SEL; DispInArea(); goto Disp_opt; } else if (ggg.ci==2 && cur_inmd->use_quick) { int i; clr_seltab(); for(i=0;i<cur_inmd->M_DUP_SEL;i++) utf8cpy(seltab[i], (char *)cur_inmd->qkeys->quick2[ggg.inch[0]-1][ggg.inch[1]-1][i]); ggg.defselN=cur_inmd->M_DUP_SEL; DispInArea(); goto Disp_opt; } break; case XK_KP_Enter: case XK_Return: if (AUTO_SELECT_BY_PHRASE) { hide_gtab_pre_sel(); if (shift_m) { return save_gtab_buf_shift_enter(); } else return output_gbuf(); } else return 0; case XK_Up: if (gtab_has_input()) return TRUE; return FALSE; case XK_Down: case XK_KP_Down: if (AUTO_SELECT_BY_PHRASE) return show_buf_select(); else return 0; case XK_Escape: hide_gtab_pre_sel(); if (ggg.gtab_buf_select) { ggg.gtab_buf_select = 0; reset_gtab_all(); ClrSelArea(); if (hime_pop_up_win && !gtab_has_input()) hide_win_gtab(); return 1; } ClrSelArea(); close_gtab_pho_win(); if (ggg.ci) { reset_gtab_all(); return 1; } else { if (ggg.gbufN) { set_gtab_user_head(); return 1; } ClrIn(); return 0; } case XK_Prior: case XK_KP_Prior: case XK_KP_Subtract: if (ggg.wild_mode) { if (ggg.wild_page >= cur_inmd->M_DUP_SEL) ggg.wild_page-=cur_inmd->M_DUP_SEL; wildcard(); return 1; } else if (ggg.more_pg) { if (ggg.gtab_buf_select) { gbuf_prev_pg(); return 1; } ggg.pg_idx -= page_len(); if (ggg.pg_idx < ggg.S1) ggg.pg_idx = ggg.S1; goto next_pg; } if (key==XK_KP_Subtract) goto keypad_proc; return win_sym_page_up(); case XK_Next: case XK_KP_Next: case XK_KP_Add: if (ggg.more_pg) { if (ggg.gtab_buf_select) { gbuf_next_pg(); return 1; } next_page: // dbg("more...\n"); ggg.pg_idx += page_len(); if (ggg.pg_idx >=ggg.E1) ggg.pg_idx = ggg.S1; goto next_pg; } else { if (key==XK_KP_Add) goto keypad_proc; if (win_sym_page_down()) return TRUE; if (!ggg.gtab_buf_select && ggg.gbufN && AUTO_SELECT_BY_PHRASE) return show_buf_select(); return FALSE; } case ' ': hide_gtab_pre_sel(); if (ggg.invalid_spc && gtab_invalid_key_in) ClrIn(); if (!gtab_invalid_key_in && ggg.spc_pressed && ggg.invalid_spc) { ClrIn(); return 1; } has_wild = has_wild_card(); // dbg("ggg.wild_mode:%d ggg.more_pg:%d ggg.ci:%d has_wild:%d\n", ggg.wild_mode, ggg.more_pg, ggg.ci, has_wild); if (ggg.wild_mode) { // request from tetralet if (!ggg.wild_page && ggg.total_matchN < cur_inmd->M_DUP_SEL) { ggg.sel1st_i = 0; goto direct_select; } ggg.wild_page += cur_inmd->M_DUP_SEL; if (ggg.wild_page >= ggg.total_matchN) ggg.wild_page=0; wildcard(); ggg.spc_pressed = TRUE; return 1; } else if (ggg.more_pg && !(_gtab_space_auto_first & GTAB_space_auto_first_any)) { if (ggg.gtab_buf_select) { gbuf_next_pg(); return 1; } else goto next_page; } else if (ggg.ci==0) { if (current_CS->b_half_full_char) return full_char_proc(key); if (ggg.gbufN) { output_gbuf(); } else return 0; } else if (!has_wild) { // dbg("iii %d ggg.defselN:%d %d\n", ggg.sel1st_i, ggg.defselN, cur_inmd->M_DUP_SEL); if (_gtab_space_auto_first == GTAB_space_auto_first_any && seltab[0][0] && ggg.sel1st_i==MAX_SELKEY-1) { ggg.sel1st_i = 0; } if (_gtab_space_auto_first == GTAB_space_auto_first_nofull && ggg.exa_match > 1 && !AUTO_SELECT_BY_PHRASE && gtab_dup_select_bell) bell(); if (seltab[ggg.sel1st_i][0]) { // dbg("ggg.last_full %d %d\n", ggg.last_full,ggg.spc_pressed); if (gtab_full_space_auto_first || ggg.spc_pressed) { direct_select: if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) { // dbg("ins ggg.kval %x\n", ggg.kval); insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match); } else putstr_inp(seltab[ggg.sel1st_i]); /* select 1st */ return 1; } } } ggg.last_full=0; ggg.spc_pressed=1; // dbg("spc_pressed=1\n"); if (has_wild) { ggg.wild_page=0; ggg.wild_mode=1; wildcard(); return 1; } break; case '?': case '*': if ((!gtab_que_wild_card && key == '?') || (!gtab_que_wild_card_asterisk && key == '*')) { inkey=cur_inmd->keymap[key]; if ((inkey && (inkey!=cur_inmd->WILD_QUES && inkey!=cur_inmd->WILD_STAR)) || ptr_selkey(key)) goto next; if (AUTO_SELECT_BY_PHRASE && ggg.gbufN) { insert_gbuf_cursor_char(key); return 1; } else { if (current_CS->b_half_full_char) return full_char_proc(key); else return 0; } } if (tss.pre_selN && shift_char_proc(key, kbstate)) return TRUE; if (current_CS->b_half_full_char) return full_char_proc(key); inkey=cur_inmd->keymap[key]; if ((inkey && (inkey!=cur_inmd->WILD_STAR && inkey!=cur_inmd->WILD_QUES)) || ptr_selkey(key)) { // dbg("%d %d\n", inkey, cur_inmd->WILD_STAR); goto next; } if (ggg.ci< cur_inmd->MaxPress) { ggg.inch[ggg.ci++]=inkey; DispInArea(); if (hime_pop_up_win) show_win_gtab(); ggg.total_matchN = 0; ggg.wild_page=0; ggg.wild_mode=1; wildcard(); return 1; } return 0; case XK_Left: case XK_KP_Left: return gbuf_cursor_left(); case XK_Right: case XK_KP_Right: return gbuf_cursor_right(); case XK_Home: case XK_KP_Home: return gbuf_cursor_home(); case XK_End: case XK_KP_End: return gbuf_cursor_end(); case XK_Delete: case XK_KP_Delete: return gtab_buf_delete(); case XK_Shift_L: case XK_Shift_R: case XK_Control_R: case XK_Control_L: case XK_Alt_L: case XK_Alt_R: case XK_Caps_Lock: return 0; case '`': if (gtab_pho_query && !cur_inmd->keymap[key]) { poo.same_pho_query_state = SAME_PHO_QUERY_gtab_input; reset_gtab_all(); disp_gtab_sel(_("輸入要查的同音字,接著在注音視窗選字")); if (hime_pop_up_win) show_win_gtab(); disp_pho_sel(""); init_gtab_pho_query_win(); return 1; } default: next: if (key < 0x7f) inkey= cur_inmd->keymap[key]; else inkey = 0; if (shift_m && !inkey && !tss.ctrl_pre_sel && tss.pre_selN && shift_char_proc(key, kbstate)) return TRUE; clear_gtab_input_error_color(); if (ggg.invalid_spc && gtab_invalid_key_in) { ClrIn(); } if (key>=XK_KP_0 && key<=XK_KP_9) { if (!ggg.ci) { if (ggg.gbufN) { insert_gbuf_cursor_char(key - XK_KP_0 + '0'); return 1; } else return 0; } if (is_dayi) { key = key - XK_KP_0 + '0'; is_keypad = TRUE; } } int keypad; keypad_proc: keypad = keypad_proc(key); if (keypad) { if (!ggg.ci) { if (ggg.gbufN) { insert_gbuf_cursor_char(keypad); return 1; } else return 0; } } char *pendkey = strchr(cur_inmd->endkey, key); pselkey=ptr_selkey(key); if (!pselkey && (key < 32 || key > 0x7e) && (gtab_full_space_auto_first || ggg.spc_pressed)) { // dbg("%x %x ggg.sel1st_i:%d '%c'\n", pselkey, key, ggg.sel1st_i, seltab[ggg.sel1st_i][0]); if (seltab[ggg.sel1st_i][0]) { if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match); else putstr_inp(seltab[ggg.sel1st_i]); /* select 1st */ } return 0; } // dbg("ggg.spc_pressed %d %d %d is_keypad:%d\n", ggg.spc_pressed, ggg.last_full, cur_inmd->MaxPress, is_keypad); #if 1 // for dayi, testcase : 6 space keypad6 int vv = pselkey - cur_inmd->selkey; if (pselkey && tss.pre_selN && !ggg.gtab_buf_select && (tss.ctrl_pre_sel|| ((!inkey||ggg.spc_pressed||is_keypad)&&! gtab_disp_partial_match_on() && !gtab_pre_select_on()))) { if (gtab_pre_select_idx(vv)) return TRUE; } else if (( (ggg.spc_pressed||ggg.last_full||is_keypad) ||(ggg.wild_mode && (!inkey ||pendkey)) || ggg.gtab_buf_select) && pselkey) { if ((_gtab_space_auto_first & GTAB_space_auto_first_any) && !ggg.wild_mode) vv++; if (vv<0) vv=9; if (seltab[vv][0]) { if (AUTO_SELECT_BY_PHRASE && !same_query_show_pho_win()) { if (ggg.gtab_buf_select && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) set_gbuf_c_sel(vv); else insert_gbuf_cursor1_cond(seltab[vv], ggg.kval, ggg.exa_match); } else { putstr_inp(seltab[vv]); } if (hime_pop_up_win && !gtab_has_input()) hide_win_gtab(); return 1; } } #endif // dbg("iii %x sel1st_i:%d auto:%d\n", pselkey, ggg.sel1st_i, AUTO_SELECT_BY_PHRASE); if (seltab[ggg.sel1st_i][0] && !ggg.wild_mode && (gtab_full_space_auto_first||ggg.spc_pressed||ggg.last_full) ) { if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match); else putstr_inp(seltab[ggg.sel1st_i]); /* select 1st */ } #if 0 if (key > 0x7f) { return 0; } #endif ggg.spc_pressed=0; // for cj & boshiamy to input digits if (!ggg.ci && !inkey) { if (current_CS->b_half_full_char) return full_char_proc(key); else { if (ggg.gbufN && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) { insert_gbuf_cursor_char(key); return 1; } else return 0; } } if (ggg.wild_mode && inkey>=1 && ggg.ci< cur_inmd->MaxPress) { ggg.inch[ggg.ci++]=inkey; if (hime_pop_up_win) show_win_gtab(); proc_wild_disp(); return 1; } if (inkey>=1 && ggg.ci< cur_inmd->MaxPress) { ggg.inch[ggg.ci++]=inkey; hide_gtab_pre_sel(); if (hime_pop_up_win) show_win_gtab(); ggg.last_full=0; if (cur_inmd->use_quick && !pendkey) { if (ggg.ci==1) { int i; for(i=0;i < cur_inmd->M_DUP_SEL; i++) { utf8cpy(seltab[i], (char *)&cur_inmd->qkeys->quick1[inkey-1][i]); } ggg.defselN=cur_inmd->M_DUP_SEL; DispInArea(); goto Disp_opt; } else if (ggg.ci==2 && !pselkey) { int i; for(i=0;i < cur_inmd->M_DUP_SEL; i++) { utf8cpy(seltab[i], (char *)&cur_inmd->qkeys->quick2[ggg.inch[0]-1][inkey-1][i]); } ggg.defselN=cur_inmd->M_DUP_SEL; DispInArea(); goto Disp_opt; } } } else if (ggg.ci == cur_inmd->MaxPress && !pselkey) { bell(); return 1; } if (inkey) { for(i=0; i < MAX_TAB_KEY_NUM64_6; i++) if (ggg.inch[i]>=cur_inmd->WILD_QUES) { DispInArea(); if (ggg.ci==cur_inmd->MaxPress) { ggg.wild_mode=1; ggg.wild_page=0; wildcard(); } return 1; } } else { if (!pselkey) { if (current_CS->b_half_full_char) return full_char_proc(key); else { if (key>=' ' && key<0x7f && AUTO_SELECT_BY_PHRASE && ggg.gbufN) insert_gbuf_cursor_char(key); else return 0; } } if (ggg.defselN) { goto YYYY; } } } /* switch */ if (ggg.ci==0) { ClrSelArea(); ClrIn(); return 1; } ggg.invalid_spc = FALSE; char *pendkey = NULL; pendkey = strchr(cur_inmd->endkey, key); DispInArea(); ggg.kval=0; for(i=0; i < Max_tab_key_num; i++) { ggg.kval|= (u_int64_t)ggg.inch[i] << (KeyBits * (Max_tab_key_num - 1 - i)); } #if 1 if (ggg.last_idx) ggg.S1=ggg.last_idx; else #endif ggg.S1=cur_inmd->idx1[ggg.inch[0]]; // dbg("--------- ch:%d %d val %llx ggg.S1:%d\n", ggg.inch[0], Max_tab_key_num, ggg.kval, ggg.S1); int oE1; oE1=cur_inmd->idx1[ggg.inch[0]+1]; if (cur_inmd->keybits==6) vmaskci = cur_inmd->key64 ? vmask64[ggg.ci]:vmask[ggg.ci]; else vmaskci = cur_inmd->key64 ? vmask64_7[ggg.ci]:vmask_7[ggg.ci]; gtab_scan_pre_select(TRUE); while ((CONVT2(cur_inmd, ggg.S1) & vmaskci) != ggg.kval && CONVT2(cur_inmd, ggg.S1) < ggg.kval && ggg.S1<oE1) ggg.S1++; ggg.pg_idx=ggg.last_idx=ggg.S1; #if 0 dbg("MaxPress:%d vmaskci:%llx kval:%llx ggg.ci:%d !=%d S1:%d kval:%x\n", cur_inmd->MaxPress, vmaskci, ggg.kval, ggg.ci, ((CONVT2(cur_inmd, ggg.S1) & vmaskci)!=ggg.kval), ggg.S1); #endif if ((CONVT2(cur_inmd, ggg.S1) & vmaskci)!=ggg.kval || (ggg.wild_mode && ggg.defselN) || ((/* ggg.ci==cur_inmd->MaxPress|| */ ggg.spc_pressed) && ggg.defselN && (pselkey && ( pendkey || ggg.spc_pressed)) ) ) { YYYY: if ((pselkey || ggg.wild_mode) && ggg.defselN) { int vv = pselkey - cur_inmd->selkey; if ((_gtab_space_auto_first & GTAB_space_auto_first_any) && !ggg.wild_mode && ggg.exa_match && (!cur_inmd->use_quick || ggg.ci!=2)) vv++; if (vv<0) vv=9; if (seltab[vv][0]) { if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) insert_gbuf_cursor1_cond(seltab[vv], ggg.kval, ggg.exa_match); else putstr_inp(seltab[vv]); return 1; } } if (pselkey && !ggg.defselN) return 0; if (gtab_invalid_key_in) { if (ggg.spc_pressed) { bell_err(); ggg.invalid_spc = TRUE; // dbg("ggg.invalid_spc\n"); } else { seltab[0][0]=0; ClrSelArea(); } } else { if (gtab_dup_select_bell) bell(); if (ggg.ci>0) ggg.inch[--ggg.ci]=0; } ggg.last_idx=0; DispInArea(); return 1; } //refill: j=ggg.S1; while(CONVT2(cur_inmd, j)==ggg.kval && j<oE1) j++; ggg.E1 = j; ggg.total_matchN = ggg.E1 - ggg.S1; ggg.pg_idx = ggg.S1; ggg.more_pg = 0; if (ggg.total_matchN > page_len()) { if ((_gtab_space_auto_first & GTAB_space_auto_first_any) || ggg.spc_pressed || pendkey || (ggg.ci==cur_inmd->MaxPress && (_gtab_space_auto_first & GTAB_space_auto_first_full))) ggg.more_pg = 1; } if (ggg.ci < cur_inmd->MaxPress && !ggg.spc_pressed && !pendkey && !ggg.more_pg) { j = ggg.S1; ggg.exa_match=0; clr_seltab(); int match_cnt=0; while (CONVT2(cur_inmd, j)==ggg.kval && ggg.exa_match <= page_len()) { seltab_phrase[ggg.exa_match] = load_seltab(j, ggg.exa_match); match_cnt++; ggg.exa_match++; j++; } ggg.defselN=ggg.exa_match; // dbg("--- ggg.exa_match %d\n", ggg.exa_match); if (ggg.defselN > page_len()) ggg.defselN--; int shiftb=(KEY_N - 1 -ggg.ci) * KeyBits; // if (gtab_disp_partial_match_on) while((CONVT2(cur_inmd, j) & vmaskci)==ggg.kval && j<oE1) { int fff=cur_inmd->keycol[(CONVT2(cur_inmd, j)>>shiftb) & cur_inmd->kmask]; u_char *tbl_ch = tblch(j); if (gtab_disp_partial_match_on() && (!seltab[fff][0] || seltab_phrase[fff] || (bchcmp(seltab[fff], tbl_ch)>0 && fff > ggg.exa_match))) { seltab_phrase[fff] = load_seltab(j, fff); ggg.defselN++; } match_cnt++; #if 0 dbg("jj %d", fff); utf8_putchar(seltab[fff]); dbg("\n"); #endif j++; } if (gtab_unique_auto_send_on()) { char *first_str=NULL; for(i=0; i < page_len(); i++) { if (!seltab[i][0]) continue; if (!first_str) first_str = seltab[i]; } if (match_cnt==1 && first_str) { if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) insert_gbuf_nokey(first_str); else putstr_inp(first_str); return 1; } } } else {
gboolean init_in_method(int in_no) { gboolean init_im = !(cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)); if (in_no < 0 || in_no > MAX_GTAB_NUM_KEY) return FALSE; check_CS(); if (current_CS->in_method != in_no) { if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) { if (current_method_type() == method_type_TSIN) { #if USE_TSIN flush_tsin_buffer(); #endif } else output_gbuf(); hide_in_win(current_CS); } if (cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)) hide_win_kbm(); } reset_current_in_win_xy(); // dbg("switch init_in_method %x %d\n", current_CS, in_no); switch (inmd[in_no].method_type) { case method_type_PHO: current_CS->in_method = in_no; init_tab_pho(); break; #if USE_TSIN case method_type_TSIN: current_CS->in_method = in_no; set_tsin_pho_mode0(current_CS); init_tab_pp(init_im); break; #endif case method_type_INT_CODE: current_CS->in_method = in_no; init_inter_code(); break; #if USE_ANTHY case method_type_ANTHY: if (init_win_anthy()) { current_CS->in_method = in_no; show_win_anthy(); } else { return FALSE; } break; #endif default: init_gtab(in_no); if (!inmd[in_no].DefChars) return FALSE; current_CS->in_method = in_no; if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) show_win_gtab(); else { win_kbm_inited = 1; show_win_kbm(); } set_gtab_input_method_name(inmd[in_no].cname); break; } #if WIN32 if (current_CS && current_CS->in_method != last_input_method) last_input_method = current_CS->in_method; #endif #if TRAY_ENABLED disp_tray_icon(); #endif update_in_win_pos(); update_win_kbm_inited(); return TRUE; }