2 Scim-Unikey Input Method
4 Copyright (C) 2008-2009 Ubuntu-VN <http://www.ubuntu-vn.org>
5 Author: Le Quoc Tuan <mr.lequoctuan@gmail.com>
6 Home: http://scim-unikey.googlecode.com
7 License: GNU LESSER GENERAL PUBLIC LICENSE v2.1
10 #define Uses_SCIM_IMENGINE
11 #define Uses_SCIM_ICONV
12 #define Uses_SCIM_CONFIG_BASE
13 #define Uses_SCIM_CONFIG_PATH
20 #define _(String) dgettext(PACKAGE_NAME,String)
23 #include "scim_unikey_const.h"
24 #include "scim_unikey_utils.h"
25 #include "scim_unikey_imengine.h"
31 #define scim_module_init unikey_LTX_scim_module_init
32 #define scim_module_exit unikey_LTX_scim_module_exit
33 #define scim_imengine_module_init unikey_LTX_scim_imengine_module_init
34 #define scim_imengine_module_create_factory unikey_LTX_scim_imengine_module_create_factory
36 static unsigned char WordBreakSyms[] =
38 ',', ';', ':', '.', '\"', '\'', '!', '?', ' ',
39 '<', '>', '=', '+', '-', '*', '/', '\\',
40 '_', '~', '`', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']',
44 static unsigned char WordAutoCommit[] =
46 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
47 'b', 'c', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n',
48 'p', 'q', 'r', 's', 't', 'v', 'x', 'z',
49 'B', 'C', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N',
50 'P', 'Q', 'R', 'S', 'T', 'V', 'X', 'Z'
53 const String Unikey_IMNames[] = {"Telex", "Vni", "STelex", "STelex2"};
54 const UkInputMethod Unikey_IM[] = {UkTelex, UkVni, UkSimpleTelex, UkSimpleTelex2};
55 const unsigned int NUM_INPUTMETHOD = sizeof(Unikey_IM)/sizeof(Unikey_IM[0]);
57 const String Unikey_OCNames[] = {"Unicode",
65 const unsigned int Unikey_OC[] = {CONV_CHARSET_XUTF8,
69 CONV_CHARSET_UNI_CSTRING,
71 CONV_CHARSET_UNIREF_HEX};
72 const unsigned int NUM_OUTPUTCHARSET = sizeof(Unikey_OC)/sizeof(Unikey_OC[0]);
74 ConfigPointer __config;
80 void scim_module_init(void)
85 void scim_module_exit(void)
90 unsigned int scim_imengine_module_init(ConfigPointer &config)
99 IMEngineFactoryPointer scim_imengine_module_create_factory(unsigned int index)
101 return new UnikeyFactory();
105 UnikeyFactory::UnikeyFactory()
107 set_languages("vi_VN");
109 UnikeyFactory::~UnikeyFactory()
112 WideString UnikeyFactory::get_name() const
114 return utf8_mbstowcs("Unikey");
116 String UnikeyFactory::get_uuid() const
118 return String(String("16ef5139-de02-494f-8d98-ddfcd60bbae1"));
120 WideString UnikeyFactory::get_authors() const
122 return utf8_mbstowcs("Le Quoc Tuan <mr.lequoctuan@gmail.com>");
124 WideString UnikeyFactory::get_credits() const
126 return utf8_mbstowcs(String("Scim-Unikey Input Method\n"
127 "Version: " SCIM_UNIKEY_VERSION "\n"
128 "Copyright © 2008-2009 Ubuntu-VN\n"
129 "http://www.ubuntu-vn.org\n\n"
130 "Thanks to Pham Kim Long for ukengine")
133 WideString UnikeyFactory::get_help() const
135 return utf8_mbstowcs(_("This IME work best when environment variable are\n"
136 "- GTK_IM_MODULE=scim-bridge\n"
137 "- QT_IM_MODULE=xim\n"
138 " If you use preedit, you don't not need that\n\n"
140 "Some time, in some application, you \"must\"\n"
141 "enable Preedit to type best\n\n"
143 "In some application, scim can't enable,\n"
144 "this is not a bug of scim-unikey.\n"
145 "You can try this in terminal: app_name | scim\n\n"
147 "This IME come into being not intend to\n"
148 "replace scim-m17n, just a choose, I recommend\n"
149 "use this combine with scim-m17n\n\n"
151 "For other support goto:\n"
152 " http://forum.ubuntu-vn.org/viewforum.php?f=85"));
154 String UnikeyFactory::get_icon_file() const
156 return String(SCIM_ICONDIR SCIM_UNIKEY_ICON_FILENAME);
159 IMEngineInstancePointer UnikeyFactory::create_instance(const String & encoding, int id)
161 return new UnikeyInstance(this, encoding, id);
164 UnikeyInstance::UnikeyInstance(UnikeyFactory *factory, const String &encoding, int id)
165 :IMEngineInstanceBase(factory, encoding, id),
168 static bool t, o; //temp variable
170 m_preeditstring.clear();
172 CreateDefaultUnikeyOptions(&m_ukopt);
175 if can't read config, set it to default value*/
177 t = __config->read(SCIM_IMENGINE_UNIKEY_INPUTMETHOD, &m_im);
180 t = __config->read(SCIM_IMENGINE_UNIKEY_OUTPUTCHARSET, &m_oc);
183 t = __config->read(SCIM_IMENGINE_UNIKEY_PREEDIT, &m_preedit);
184 if (!t) m_preedit = SCIM_IMENGINE_UNIKEY_PREEDIT_DEF;
186 // read preedit switch key
187 m_preeditskey.clear();
190 t = __config->read(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, &s);
191 if (!t) s=SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY_DEF;
198 m_preeditskey.push_back(KeyEvent(s.substr(i, j-i)));
203 m_preeditskey.push_back(KeyEvent(s.substr(i)));
204 } // end read preedit switch key
206 t = __config->read(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, &o);
207 m_process_w_AtBeginWord = t?o:SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
210 t = __config->read(SCIM_IMENGINE_UNIKEY_FREEMARKING, &o);
211 m_ukopt.freeMarking = t?o:SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
213 t = __config->read(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, &o);
214 m_ukopt.modernStyle = t?o:SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
216 t = __config->read(SCIM_IMENGINE_UNIKEY_MACROENABLED, &o);
217 m_ukopt.macroEnabled = t?o:SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
219 t = __config->read(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, &o);
220 m_ukopt.spellCheckEnabled = t?o:SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
222 t = __config->read(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, &o);
223 m_ukopt.autoNonVnRestore = t?o:SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
225 UnikeySetOptions(&m_ukopt);
227 if (m_ukopt.macroEnabled)
229 UnikeyLoadMacroTable(getMacroFile());
235 UnikeyInstance::~UnikeyInstance()
239 void UnikeyInstance::focus_in()
241 register_properties(CreatePropertyList());
243 UnikeySetInputMethod(Unikey_IM[m_im]);
244 UnikeySetOutputCharset(Unikey_OC[m_oc]);
245 UnikeySetOptions(&m_ukopt);
248 void UnikeyInstance::focus_out()
253 void UnikeyInstance::reset()
257 m_lastkey_with_shift = false;
261 if (m_preeditstring.length())
263 commit_string(m_preeditstring);
264 hide_preedit_string();
265 m_preeditstring.clear();
267 m_auto_commit = false;
271 void UnikeyInstance::Unikey_send_backspace(int nBackspace)
273 static WideString ws;
276 // if surrounding text was provided, use it instead of send backspace
277 if (get_surrounding_text(ws, n, nBackspace, 0))
279 // for type in Auto Complete in OpenOffice
280 // Hope this not rise bugs in others application
281 // not use SCIM_KEY_NullKey, because GTK application crash when GTK_IM_MODULE=scim
283 forward_key_event(SCIM_KEY_VoidSymbol);
285 delete_surrounding_text(-ws.length(), ws.length());
289 for (int i=0; i < nBackspace; i++)
290 forward_key_event(SCIM_KEY_BackSpace);
294 void UnikeyInstance::Unikey_update_preedit_string(const WideString s, const bool visible)
296 AttributeList attlist;
299 // underline preedit string
300 att = Attribute(0, s.length(), SCIM_ATTR_DECORATE, SCIM_ATTR_DECORATE_UNDERLINE);
301 attlist.push_back(att);
303 if (m_ukopt.spellCheckEnabled==1 && UnikeyLastWordIsNonVn())
305 // red preedit string
306 att = Attribute(0, s.length(), SCIM_ATTR_FOREGROUND, 0xff0000);
307 attlist.push_back(att);
310 update_preedit_string(s, attlist);
311 update_preedit_caret(s.length());
315 show_preedit_string();
319 hide_preedit_string();
323 bool UnikeyInstance::process_key_event(const KeyEvent& key)
327 for (int i = 0; i<m_preeditskey.size(); i++)
329 if (key==m_preeditskey.at(i))
332 m_preedit=!m_preedit;
333 register_properties(CreatePropertyList());
338 tmp = m_preedit?Unikey_process_key_event_preedit(key)
339 :Unikey_process_key_event_direct(key);
341 if ((key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
342 || (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9))
344 m_lastkey_with_shift = key.is_shift_down();
348 m_lastkey_with_shift = false;
354 /** This method not use preedit string */
355 bool UnikeyInstance::Unikey_process_key_event_direct(const KeyEvent& key)
357 if (key.is_key_release())
362 if (key.is_control_down() || key.mask & SCIM_KEY_AltMask)
368 if (key.code >= SCIM_KEY_Shift_L && key.code <= SCIM_KEY_Hyper_R)
373 if (key.code == SCIM_KEY_BackSpace)
375 UnikeyBackspacePress(); // xu ly phim backspace
376 if (UnikeyBackspaces==0) // neu ukengine bao khong can xoa ky tu nao,
377 return false; // thi tra lai backspace cho chuong trinh khach
380 Unikey_send_backspace(UnikeyBackspaces);
382 // append key that need change tone pos after press backspace
385 if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
386 commit_string(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars)); // send the solved string to client
389 static unsigned char buf[1024];
390 int bufSize=sizeof(buf)/sizeof(buf[0]);
392 latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
393 commit_string(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0]) - bufSize));
401 if (key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
403 UnikeySetCapsState(key.mask & SCIM_KEY_ShiftMask,
404 key.mask & SCIM_KEY_CapsLockMask);
406 // shift + space to restore keystroke
407 if (m_lastkey_with_shift == false
408 && key.mask & SCIM_KEY_ShiftMask
409 && key.code == SCIM_KEY_space
410 && !UnikeyAtWordBeginning())
412 UnikeyRestoreKeyStrokes();
413 if (UnikeyBackspaces == 0)
415 UnikeyPutChar(key.code);
419 else if ((Unikey_IM[m_im] == UkTelex || Unikey_IM[m_im] == UkSimpleTelex2)
420 && m_process_w_AtBeginWord == false
421 && UnikeyAtWordBeginning()
422 && (key.code == SCIM_KEY_w || key.code == SCIM_KEY_W))
424 UnikeyPutChar(key.code);
429 UnikeyFilter(key.code);
432 if (UnikeyBackspaces)
434 Unikey_send_backspace(UnikeyBackspaces);
439 if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
441 commit_string(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars)); // send the solved string to client
445 static unsigned char buf[1024];
446 int bufSize=sizeof(buf)/sizeof(buf[0]);
448 latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
449 commit_string(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0]) - bufSize));
454 forward_key_event(key);
466 /** This method use preedit string */
467 bool UnikeyInstance::Unikey_process_key_event_preedit(const KeyEvent& key)
471 if (key.code == SCIM_KEY_Tab
472 || key.mask & SCIM_KEY_ControlMask
473 || key.mask & SCIM_KEY_AltMask)
475 if (m_preeditstring.length())
477 commit_string(m_preeditstring);
478 hide_preedit_string();
479 m_preeditstring.clear();
485 if (key.is_key_release())
488 if (key.code == SCIM_KEY_Tab
489 || key.code == SCIM_KEY_Return
490 || key.code == SCIM_KEY_Delete
491 || key.code == SCIM_KEY_KP_Enter
492 || (key.code >= SCIM_KEY_Home && key.code <= SCIM_KEY_Insert)
493 || (key.code >= SCIM_KEY_KP_Home && key.code <= SCIM_KEY_KP_Delete))
495 if (m_preeditstring.length())
497 commit_string(m_preeditstring);
498 hide_preedit_string();
499 m_preeditstring.clear();
506 else if (key.code >= SCIM_KEY_Shift_L && key.code <= SCIM_KEY_Hyper_R)
509 else if (key.code == SCIM_KEY_BackSpace)
511 UnikeyBackspacePress(); // process Backspace
513 if (UnikeyBackspaces==0 || m_preeditstring.empty()) // if Unikey tell no Backspace
516 return false; // Return Backspace to client
522 len = m_preeditstring.length();
523 if (len <= UnikeyBackspaces)
525 m_preeditstring.clear();
526 hide_preedit_string();
527 m_auto_commit = true;
531 m_preeditstring.erase(len - UnikeyBackspaces, UnikeyBackspaces);
532 Unikey_update_preedit_string(m_preeditstring, true);
535 // append key that need change tone pos after press backspace
538 if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
539 m_preeditstring.append(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));
542 static unsigned char buf[1024];
543 int bufSize=sizeof(buf)/sizeof(buf[0]);
545 latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
546 m_preeditstring.append(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0])-bufSize));
549 m_auto_commit = false;
550 Unikey_update_preedit_string(m_preeditstring, true);
557 else if (key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
559 UnikeySetCapsState(key.mask & SCIM_KEY_ShiftMask, key.mask & SCIM_KEY_CapsLockMask);
561 // auto commit char: commit char that never change later in preedit string
562 // if macro enabled, then not auto commit. Because macro may change any word
563 if (m_ukopt.macroEnabled==0 && (UnikeyAtWordBeginning() || m_auto_commit))
565 for (i = 0; i < sizeof(WordAutoCommit); i++)
566 if (key.code == WordAutoCommit[i])
568 UnikeyPutChar(key.code);
569 m_auto_commit = true;
570 forward_key_event(key); // forward keyevent instead of return false
573 } // end auto commit char
575 if ((Unikey_IM[m_im] == UkTelex || Unikey_IM[m_im] == UkSimpleTelex2)
576 && m_process_w_AtBeginWord == false
577 && UnikeyAtWordBeginning()
578 && (key.code == SCIM_KEY_w || key.code == SCIM_KEY_W))
580 UnikeyPutChar(key.code);
581 if (m_ukopt.macroEnabled==0)
583 forward_key_event(key);
587 m_preeditstring.push_back(key.code);
588 Unikey_update_preedit_string(m_preeditstring, true);
591 m_auto_commit = true;
596 m_auto_commit = false;
598 if (m_lastkey_with_shift == false
599 && key.mask & SCIM_KEY_ShiftMask
600 && key.code == SCIM_KEY_space
601 && !UnikeyAtWordBeginning())
603 UnikeyRestoreKeyStrokes();
608 UnikeyFilter(key.code);
611 if (UnikeyBackspaces > 0)
615 len = m_preeditstring.length();
617 if (len <= UnikeyBackspaces)
618 m_preeditstring.clear();
620 m_preeditstring.erase(len - UnikeyBackspaces, UnikeyBackspaces);
623 if (UnikeyBufChars > 0)
625 if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
626 m_preeditstring.append(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));
629 static unsigned char buf[1024];
630 int bufSize=sizeof(buf)/sizeof(buf[0]);
632 latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
633 m_preeditstring.append(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0])-bufSize));
638 m_preeditstring.push_back(key.get_unicode_code());
641 if (m_preeditstring.length())
643 for (i=0; i < sizeof(WordBreakSyms); i++)
645 if (WordBreakSyms[i] == m_preeditstring[m_preeditstring.length()-1] && key.code == WordBreakSyms[i])
647 commit_string(m_preeditstring);
648 hide_preedit_string();
649 m_preeditstring.clear();
656 Unikey_update_preedit_string(m_preeditstring, true);
660 // else (key non process)
665 PropertyList UnikeyInstance::CreatePropertyList()
670 Property prop("", "", "", "");
673 prop.set_key("/Unikey/InputMethod");
674 prop.set_label(Unikey_IMNames[m_im]);
676 prop.set_tip(_("Choose input method"));
677 props.push_back(prop);
679 for (i=0; i<NUM_INPUTMETHOD; i++)
681 prop.set_key(String("/Unikey/InputMethod/") + Unikey_IMNames[i] + String(m_im==i?"-Checked":""));
682 prop.set_label(Unikey_IMNames[i]);
683 prop.set_icon(m_im==i?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
685 props.push_back(prop);
690 prop.set_key("/Unikey/OutputCharset");
691 prop.set_label(Unikey_OCNames[m_oc]);
693 prop.set_tip(_("Choose output charset"));
694 props.push_back(prop);
696 for (i=0; i<NUM_OUTPUTCHARSET; i++)
698 prop.set_key(String("/Unikey/OutputCharset/") + Unikey_OCNames[i] + String(m_oc==i?"-Checked":""));
699 prop.set_label(Unikey_OCNames[i]);
700 prop.set_icon(m_oc==i?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
702 props.push_back(prop);
707 prop.set_key("/Unikey/Options");
708 prop.set_label(_("Options"));
709 prop.set_icon(SCIM_ICONDIR SCIM_UNIKEY_ICON_CONFIGURE);
710 prop.set_tip(_("Configure Unikey here"));
711 props.push_back(prop);
714 prop.set_key(m_ukopt.spellCheckEnabled?
715 "/Unikey/Options/SpellCheck/Disable":"/Unikey/Options/SpellCheck/Enable");
716 prop.set_label(_("Enable spell check"));
717 prop.set_icon(m_ukopt.spellCheckEnabled?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
718 prop.set_tip(_("If enable, you can decrease mistake when typing"));
719 props.push_back(prop);
721 // auto restore keystroke
722 prop.set_key(m_ukopt.autoNonVnRestore?
723 "/Unikey/Options/AutoRestoreKeys/Disable":"/Unikey/Options/AutoRestoreKeys/Enable");
724 prop.set_label(_("Auto restore keys with invalid words"));
725 prop.set_icon(m_ukopt.autoNonVnRestore?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
726 prop.set_tip(_("When typing a word not in Vietnamese,\n"
727 "it will auto restore keystroke into original"));
728 props.push_back(prop);
731 prop.set_key(m_ukopt.modernStyle?
732 "/Unikey/Options/ModernStyle/Disable":"/Unikey/Options/ModernStyle/Enable");
733 prop.set_label(_("Use oà, uý (instead of òa, úy)"));
734 prop.set_icon(m_ukopt.modernStyle?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
736 props.push_back(prop);
739 prop.set_key(m_ukopt.freeMarking?
740 "/Unikey/Options/FreeMarking/Disable":"/Unikey/Options/FreeMarking/Enable");
741 prop.set_label(_("Allow type with more freedom"));
742 prop.set_icon(m_ukopt.freeMarking?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
744 props.push_back(prop);
747 prop.set_key(m_ukopt.macroEnabled?
748 "/Unikey/Options/EnabledMacro/Disable":"/Unikey/Options/EnabledMacro/Enable");
749 prop.set_label(_("Enable Macro"));
750 prop.set_icon(m_ukopt.macroEnabled?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
752 props.push_back(prop);
755 prop.set_key(m_preedit?"/Unikey/Options/Preedit/Disable":"/Unikey/Options/Preedit/Enable");
756 prop.set_label(_("Enable PreEdit"));
757 prop.set_icon(m_preedit?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
758 prop.set_tip(_("This option is best for most application\n"
759 "But you may don't like it because it have an underline when typing"));
760 props.push_back(prop);
762 // process w at begin
763 prop.set_key(m_process_w_AtBeginWord?
764 "/Unikey/Options/ProcessWAtBegin/Disable":"/Unikey/Options/ProcessWAtBegin/Enable");
765 prop.set_label(_("Process W at word begin"));
766 prop.set_icon(m_process_w_AtBeginWord?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
767 prop.set_tip(_("If enable, type W at begin\n"
768 "of word will change to Ư."));
769 props.push_back(prop);
774 void UnikeyInstance::trigger_property(const String &property)
780 if (!property.compare(0, strlen("/Unikey/InputMethod/"), "/Unikey/InputMethod/"))
782 for (i=0; i<NUM_INPUTMETHOD; i++)
783 if (!property.compare(strlen("/Unikey/InputMethod/"),
784 property.length() - strlen("/Unikey/InputMethod/"),
788 __config->write(SCIM_IMENGINE_UNIKEY_INPUTMETHOD, m_im);
795 else if (!property.compare(0, strlen("/Unikey/OutputCharset/"), "/Unikey/OutputCharset/"))
797 for (i=0; i<NUM_OUTPUTCHARSET; i++)
798 if (!property.compare(strlen("/Unikey/OutputCharset/"),
799 property.length() - strlen("/Unikey/OutputCharset/"),
803 __config->write(SCIM_IMENGINE_UNIKEY_OUTPUTCHARSET, m_oc);
810 else if (property == "/Unikey/Options/SpellCheck/Enable")
812 m_ukopt.spellCheckEnabled = true;
813 __config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, true);
816 else if (property == "/Unikey/Options/SpellCheck/Disable")
818 m_ukopt.spellCheckEnabled = false;
819 __config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, false);
823 // auto restore keystroke
824 else if (property == "/Unikey/Options/AutoRestoreKeys/Enable")
826 m_ukopt.autoNonVnRestore = true;
827 __config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, true);
830 else if (property == "/Unikey/Options/AutoRestoreKeys/Disable")
832 m_ukopt.autoNonVnRestore = false;
833 __config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, false);
838 else if (property == "/Unikey/Options/ModernStyle/Enable")
840 m_ukopt.modernStyle = true;
841 __config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, true);
844 else if (property == "/Unikey/Options/ModernStyle/Disable")
846 m_ukopt.modernStyle = false;
847 __config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, false);
852 else if (property == "/Unikey/Options/FreeMarking/Enable")
854 m_ukopt.freeMarking = true;
855 __config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, true);
858 else if (property == "/Unikey/Options/FreeMarking/Disable")
860 m_ukopt.freeMarking = false;
861 __config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, false);
865 else if (property == "/Unikey/Options/EnabledMacro/Enable")
867 m_ukopt.macroEnabled = true;
868 UnikeyLoadMacroTable(getMacroFile());
869 __config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, true);
872 else if (property == "/Unikey/Options/EnabledMacro/Disable")
874 m_ukopt.macroEnabled = false;
875 __config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, false);
880 else if (property == "/Unikey/Options/Preedit/Enable")
883 __config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, true);
886 else if (property == "/Unikey/Options/Preedit/Disable")
889 __config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, false);
893 // process w at begin
894 else if (property == "/Unikey/Options/ProcessWAtBegin/Enable")
896 m_process_w_AtBeginWord = true;
897 __config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, true);
900 else if (property == "/Unikey/Options/ProcessWAtBegin/Disable")
902 m_process_w_AtBeginWord = false;
903 __config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, false);