void StandardIMInstance::focus_in () { if (!m_ok) return; SCIM_DEBUG_IMENGINE(2) << "focus_in.\n"; hide_preedit_string (); hide_aux_string (); hide_lookup_table (); __global->focus_in (m_factory->get_module_id (), &m_input_context); }
void CannaInstance::reset () { SCIM_DEBUG_IMENGINE(2) << "reset.\n"; m_canna_jrkanji.reset (); update_preedit_caret (0); update_preedit_string (utf8_mbstowcs ("")); update_aux_string (utf8_mbstowcs ("")); m_lookup_table.clear (); hide_preedit_string (); hide_lookup_table (); hide_aux_string (); }
void HangulInstance::hangul_update_preedit_string () { WideString wstr = get_preedit_string (); if (wstr.length ()) { AttributeList attrs; attrs.push_back(Attribute(0, m_preedit.length(), SCIM_ATTR_DECORATE, SCIM_ATTR_DECORATE_UNDERLINE)); attrs.push_back(Attribute(m_preedit.length(), wstr.length() - m_preedit.length(), SCIM_ATTR_DECORATE, SCIM_ATTR_DECORATE_REVERSE)); show_preedit_string (); update_preedit_string (wstr, attrs); update_preedit_caret (wstr.length()); } else { hide_preedit_string (); } }
void WaitZarInstance::updateGuesses() { //Update aux_string if (wcslen(model->getParenString())==0) wcscpy(aux_string, typed_string); else swprintf(aux_string, 500, L"%ls(%ls)", typed_string, model->getParenString()); update_aux_string(aux_string); if (wcslen(aux_string)>0) { show_aux_string(); show_lookup_table(); } else { hide_aux_string(); hide_lookup_table(); } //Update the current guess wcscpy(guess_string, L""); if (model->getPossibleWords().size()>0) copyStringFromKeyStrokes(guess_string, model->getWordKeyStrokes(model->getPossibleWords()[model->getCurrSelectedID()])); swprintf(preedit_string, 500, L"%ls%ls%ls", prefix_string, guess_string, postfix_string); update_preedit_string(preedit_string); if (wcslen(preedit_string)>0) show_preedit_string(); else hide_preedit_string(); /* fprintf(logFile, "now on: %ls\n", typed_string); fprintf(logFile, " prefix_string: %ls\n", prefix_string); fprintf(logFile, " guess_string: %ls\n", guess_string); fprintf(logFile, " postfix_string: %ls\n", postfix_string); fflush(logFile);*/ //Update the candidate table & cursor lookup.setCandidates(model); lookup.show_cursor(model->getPossibleWords().size()>0); lookup.set_cursor_pos(model->getCurrSelectedID()); //I think... update_lookup_table(lookup); //Update the caret update_preedit_caret(wcslen(prefix_string)); //TEMP: Bugfix on behalf of SCIM if (lookup.number_of_candidates()==0) { update_lookup_table(blank_lookup); } }
void HangulInstance::flush() { SCIM_DEBUG_IMENGINE(2) << "flush.\n"; hide_preedit_string(); WideString wstr = m_preedit; const ucschar *str = hangul_ic_flush(m_hic); while (*str != 0) wstr.push_back (*str++); if (wstr.length()) commit_string(wstr); delete_candidates (); m_preedit.clear(); }
bool SocketInstance::do_transaction (Transaction &trans, bool &ret) { int cmd = -1; bool cont = false; ret = false; SCIM_DEBUG_IMENGINE(2) << " Do transaction:\n"; if (trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY) { while (trans.get_command (cmd)) { switch (cmd) { case SCIM_TRANS_CMD_SHOW_PREEDIT_STRING: { SCIM_DEBUG_IMENGINE(3) << " show_preedit_string ()\n"; show_preedit_string (); break; } case SCIM_TRANS_CMD_SHOW_AUX_STRING: { SCIM_DEBUG_IMENGINE(3) << " show_aux_string ()\n"; show_aux_string (); break; } case SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE: { SCIM_DEBUG_IMENGINE(3) << " show_lookup_table ()\n"; show_lookup_table (); break; } case SCIM_TRANS_CMD_HIDE_PREEDIT_STRING: { SCIM_DEBUG_IMENGINE(3) << " hide_preedit_string ()\n"; hide_preedit_string (); break; } case SCIM_TRANS_CMD_HIDE_AUX_STRING: { SCIM_DEBUG_IMENGINE(3) << " hide_aux_string ()\n"; hide_aux_string (); break; } case SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE: { SCIM_DEBUG_IMENGINE(3) << " hide_lookup_table ()\n"; hide_lookup_table (); break; } case SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET: { uint32 caret; if (trans.get_data (caret)) { SCIM_DEBUG_IMENGINE(3) << " update_preedit_caret (" << caret << ")\n"; update_preedit_caret (caret); } break; } case SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING: { WideString str; AttributeList attrs; if (trans.get_data (str) && trans.get_data (attrs)) { SCIM_DEBUG_IMENGINE(3) << " update_preedit_string ()\n"; update_preedit_string (str, attrs); } break; } case SCIM_TRANS_CMD_UPDATE_AUX_STRING: { WideString str; AttributeList attrs; if (trans.get_data (str) && trans.get_data (attrs)) { SCIM_DEBUG_IMENGINE(3) << " update_aux_string ()\n"; update_aux_string (str, attrs); } break; } case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE: { CommonLookupTable table; if (trans.get_data (table)) { SCIM_DEBUG_IMENGINE(3) << " update_lookup_table ()\n"; update_lookup_table (table); } break; } case SCIM_TRANS_CMD_COMMIT_STRING: { WideString str; if (trans.get_data (str)) { SCIM_DEBUG_IMENGINE(3) << " commit_string ()\n"; commit_string (str); } break; } case SCIM_TRANS_CMD_FORWARD_KEY_EVENT: { KeyEvent key; if (trans.get_data (key)) { SCIM_DEBUG_IMENGINE(3) << " forward_key_event ()\n"; forward_key_event (key); } break; } case SCIM_TRANS_CMD_REGISTER_PROPERTIES: { PropertyList proplist; if (trans.get_data (proplist)) { SCIM_DEBUG_IMENGINE(3) << " register_properties ()\n"; // Load icon files of these properties from remote SocketFrontEnd. for (PropertyList::iterator it = proplist.begin (); it != proplist.end (); ++it) it->set_icon (global->load_icon (it->get_icon ())); register_properties (proplist); } break; } case SCIM_TRANS_CMD_UPDATE_PROPERTY: { Property prop; if (trans.get_data (prop)) { SCIM_DEBUG_IMENGINE(3) << " update_property ()\n"; // Load the icon file of this property from remote SocketFrontEnd. prop.set_icon (global->load_icon (prop.get_icon ())); update_property (prop); } break; } case SCIM_TRANS_CMD_BEEP: { SCIM_DEBUG_IMENGINE(3) << " beep ()\n"; beep (); break; } case SCIM_TRANS_CMD_START_HELPER: { String helper_uuid; if (trans.get_data (helper_uuid)) { SCIM_DEBUG_IMENGINE(3) << " start_helper (" << helper_uuid << ")\n"; start_helper (helper_uuid); } break; } case SCIM_TRANS_CMD_STOP_HELPER: { String helper_uuid; if (trans.get_data (helper_uuid)) { SCIM_DEBUG_IMENGINE(3) << " stop_helper (" << helper_uuid << ")\n"; stop_helper (helper_uuid); } break; } case SCIM_TRANS_CMD_SEND_HELPER_EVENT: { String helper_uuid; Transaction temp_trans; if (trans.get_data (helper_uuid) && trans.get_data (temp_trans)) { SCIM_DEBUG_IMENGINE(3) << " send_helper_event (" << helper_uuid << ")\n"; send_helper_event (helper_uuid, temp_trans); } break; } case SCIM_TRANS_CMD_OK: { SCIM_DEBUG_IMENGINE(3) << " ret = true\n"; ret = true; break; } case SCIM_TRANS_CMD_GET_SURROUNDING_TEXT: { WideString text; int cursor; uint32 maxlen_before; uint32 maxlen_after; Transaction temp_trans; if (trans.get_data (maxlen_before) && trans.get_data (maxlen_after)) { global->init_transaction (temp_trans); if (get_surrounding_text (text, cursor, (int) maxlen_before, (int) maxlen_after)) { temp_trans.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT); temp_trans.put_data (text); temp_trans.put_data ((uint32) cursor); } else { temp_trans.put_command (SCIM_TRANS_CMD_FAIL); } global->send_transaction (temp_trans); } cont = true; break; } case SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT: { uint32 offset; uint32 len; Transaction temp_trans; if (trans.get_data (offset) && trans.get_data (len)) { global->init_transaction (temp_trans); if (delete_surrounding_text ((int) offset, (int) len)) { temp_trans.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT); temp_trans.put_command (SCIM_TRANS_CMD_OK); } else { temp_trans.put_command (SCIM_TRANS_CMD_FAIL); } global->send_transaction (temp_trans); } cont = true; break; } default: SCIM_DEBUG_IMENGINE(3) << " Strange cmd: " << cmd << "\n";; } } } else { SCIM_DEBUG_IMENGINE(3) << " Failed to get cmd: " << cmd << "\n"; } SCIM_DEBUG_IMENGINE(2) << " End of Do transaction\n"; return cont; }
bool HangulInstance::process_key_event (const KeyEvent& rawkey) { SCIM_DEBUG_IMENGINE(1) << "process_key_event.\n"; KeyEvent key = rawkey.map_to_layout(SCIM_KEYBOARD_Default); m_prev_key = key; if (use_ascii_mode() && !is_hangul_mode()) { if (is_hangul_key(key)) { toggle_hangul_mode(); return true; } return false; } /* ignore key release. */ if (key.is_key_release ()) return false; /* mode change */ if (use_ascii_mode() && is_hangul_key(key)) { toggle_hangul_mode(); return true; } /* hanja mode */ if (is_hanja_mode_key (key)) { toggle_hanja_mode(); } /* toggle candidate table */ if (is_hanja_key (key)) { if (is_hanja_mode()) { update_candidates (); } else { if (m_lookup_table.number_of_candidates ()) delete_candidates (); else update_candidates (); } return true; } /* ignore shift keys */ if (key.code == SCIM_KEY_Shift_L || key.code == SCIM_KEY_Shift_R) return false; /* flush on modifier-on keys */ if (key.is_control_down() || key.is_alt_down()) { flush (); return false; } /* candidate keys */ if (m_lookup_table.number_of_candidates ()) { if (candidate_key_event(key)) return true; } /* change to ascii mode on ESCAPE key, for vi users. * We should process this key after processing candidate keys, * or input mode will be changed to non-hangul mode when the user presses * escape key to close candidate window. */ if (use_ascii_mode() && !is_hanja_mode()) { if (key.code == SCIM_KEY_Escape) { toggle_hangul_mode(); } } /* backspace */ if (is_backspace_key(key)) { bool ret = hangul_ic_backspace(m_hic); if (ret) { hangul_update_preedit_string (); } else if (m_preedit.length() > 0) { ret = true; m_preedit.erase(m_preedit.length() - 1, 1); hangul_update_preedit_string(); } else { if (m_surrounding_text.length() > 0) { m_surrounding_text.erase(m_surrounding_text.length() - 1, 1); if (m_surrounding_text.empty()) { delete_candidates(); return ret; } } } if (is_hanja_mode() && m_lookup_table.number_of_candidates()) { update_candidates(); } return ret; } if (key.code >= SCIM_KEY_exclam && key.code <= SCIM_KEY_asciitilde) { /* main hangul composing process */ int ascii = key.get_ascii_code(); if (key.is_caps_lock_down()) { if (isupper(ascii)) ascii = tolower(ascii); else if (islower(ascii)) ascii = toupper(ascii); } bool ret = hangul_ic_process(m_hic, ascii); WideString wstr; wstr = get_commit_string (); if (wstr.length ()) { /* Before commit, we set preedit string to null to work arround * some buggy IM implementation, ex) Qt, Evolution */ hide_preedit_string (); if (is_hanja_mode() || m_factory->m_commit_by_word) { m_preedit += wstr; } else { commit_string(wstr); } } if (is_hanja_mode() || m_factory->m_commit_by_word) { if (hangul_ic_is_empty(m_hic)) { flush(); } } hangul_update_preedit_string (); if (is_hanja_mode()) { update_candidates(); } return ret; } flush(); return false; }
void FilterInstanceBase::filter_hide_preedit_string () { hide_preedit_string (); }