add more charset
authorMr.LeQuocTuan <Mr.LeQuocTuan@79bd180b-0a32-48ee-ac55-ada8cae9df61>
Thu, 18 Jun 2009 10:36:09 +0000 (10:36 +0000)
committerMr.LeQuocTuan <Mr.LeQuocTuan@79bd180b-0a32-48ee-ac55-ada8cae9df61>
Thu, 18 Jun 2009 10:36:09 +0000 (10:36 +0000)
git-svn-id: svn://localhost/trunk@7 79bd180b-0a32-48ee-ac55-ada8cae9df61

src/scim_unikey_imengine.cpp
src/scim_unikey_imengine.h
src/scim_unikey_setup.cpp
ukengine/diff/inputproc.cpp.diff

index 186050973f017b7e7c4e0b42fbeb17c4aa70ea22..d15d2ffefce1789caacac32d0548faa6ed91cd99 100644 (file)
 
 static unsigned char WordBreakSyms[] =
 {
-       ',', ';', ':', '.', '\"', '\'', '!', '?', ' ',
-       '<', '>', '=', '+', '-', '*', '/', '\\',
-       '_', '~', '`', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']',
-       '|'
+    ',', ';', ':', '.', '\"', '\'', '!', '?', ' ',
+    '<', '>', '=', '+', '-', '*', '/', '\\',
+    '_', '~', '`', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']',
+    '|'
 };
 
 static unsigned char WordAutoCommit[] =
 {
-       '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
-       'b', 'c', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n',
-       'p', 'q', 'r', 's', 't', 'v', 'x', 'z',
-       'B', 'C', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N',
-       'P', 'Q', 'R', 'S', 'T', 'V', 'X', 'Z'
+    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+    'b', 'c', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n',
+    'p', 'q', 'r', 's', 't', 'v', 'x', 'z',
+    'B', 'C', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N',
+    'P', 'Q', 'R', 'S', 'T', 'V', 'X', 'Z'
 };
 
 const String          Unikey_IMNames[]    = {"Telex", "Vni", "STelex"};
@@ -54,11 +54,18 @@ const unsigned int    NUM_INPUTMETHOD     = sizeof(Unikey_IM)/sizeof(Unikey_IM[0
 const String          Unikey_OCNames[]    = {"Unicode",
                                              "TCVN3",
                                              "VNI Win",
-                                             "VIQR"};
+                                             "VIQR",
+                                             "CString",
+                                             "NCR Decimal",
+                                             "NCR Hex"};
+
 const unsigned int    Unikey_OC[]         = {CONV_CHARSET_XUTF8,
                                              CONV_CHARSET_TCVN3,
                                              CONV_CHARSET_VNIWIN,
-                                             CONV_CHARSET_VIQR};
+                                             CONV_CHARSET_VIQR,
+                                             CONV_CHARSET_UNI_CSTRING,
+                                             CONV_CHARSET_UNIREF,
+                                             CONV_CHARSET_UNIREF_HEX};
 const unsigned int    NUM_OUTPUTCHARSET   = sizeof(Unikey_OC)/sizeof(Unikey_OC[0]);
 
 ConfigPointer   __config;
@@ -67,159 +74,159 @@ using namespace scim;
 
 extern "C"
 {
-       void scim_module_init(void)
-       {
-               UnikeySetup();
-       }
-
-       void scim_module_exit(void)
-       {
-               UnikeyCleanup();
-       }
-
-       unsigned int scim_imengine_module_init(ConfigPointer &config)
-       {
-               if (config.null())
-                       return 0;
-               __config = config;
-
-               return 1;
-       }
-
-       IMEngineFactoryPointer scim_imengine_module_create_factory(unsigned int index)
-       {
-               return new UnikeyFactory();
-       }
+    void scim_module_init(void)
+    {
+        UnikeySetup();
+    }
+
+    void scim_module_exit(void)
+    {
+        UnikeyCleanup();
+    }
+
+    unsigned int scim_imengine_module_init(ConfigPointer &config)
+    {
+        if (config.null())
+            return 0;
+        __config = config;
+
+        return 1;
+    }
+
+    IMEngineFactoryPointer scim_imengine_module_create_factory(unsigned int index)
+    {
+        return new UnikeyFactory();
+    }
 }
 
 UnikeyFactory::UnikeyFactory()
 {
-       set_languages("vi_VN");
+    set_languages("vi_VN");
 }
 UnikeyFactory::~UnikeyFactory()
 {
 }
 WideString UnikeyFactory::get_name() const
 {
-       return utf8_mbstowcs("Unikey");
+    return utf8_mbstowcs("Unikey");
 }
 String UnikeyFactory::get_uuid() const
 {
-       return String(String("16ef5139-de02-494f-8d98-ddfcd60bbae1"));
+    return String(String("16ef5139-de02-494f-8d98-ddfcd60bbae1"));
 }
 WideString UnikeyFactory::get_authors() const
 {
-       return utf8_mbstowcs("Le Quoc Tuan <mr.lequoctuan@gmail.com>");
+    return utf8_mbstowcs("Le Quoc Tuan <mr.lequoctuan@gmail.com>");
 }
 WideString UnikeyFactory::get_credits() const
 {
-       return utf8_mbstowcs(String("Scim-Unikey Input Method\n"
-                                                               "Version: " SCIM_UNIKEY_VERSION "\n"
-                                                               "Copyright © 2008-2009 Ubuntu-VN\n"
-                                                               "http://www.ubuntu-vn.org\n\n"
-                                                               "Thanks to Pham Kim Long for ukengine")
-               );
+    return utf8_mbstowcs(String("Scim-Unikey Input Method\n"
+                                "Version: " SCIM_UNIKEY_VERSION "\n"
+                                "Copyright © 2008-2009 Ubuntu-VN\n"
+                                "http://www.ubuntu-vn.org\n\n"
+                                "Thanks to Pham Kim Long for ukengine")
+        );
 }
 WideString UnikeyFactory::get_help() const
 {
-       return utf8_mbstowcs(_("This IME work best when environment variable are\n"
-                                                  "- GTK_IM_MODULE=scim-bridge\n"
-                                                  "- QT_IM_MODULE=xim\n"
-                                                  " If you use preedit, you don't not need that\n\n"
-                                                  
-                                                  "Some time, in some application, you \"must\"\n"
-                                                  "enable Preedit to type best\n\n"
-
-                                                  "In some application, scim can't enable,\n"
-                                                  "this is not a bug of scim-unikey.\n"
-                                                  "You can try this in terminal: app_name | scim\n\n"
-
-                                                  "This IME come into being not intend to\n"
-                                                  "replace scim-m17n, just a choose, I recommend\n"
-                                                  "use this combine with scim-m17n\n\n"
-
-                                                  "For other support goto:\n"
-                                                  "  http://forum.ubuntu-vn.org/viewforum.php?f=85"));
+    return utf8_mbstowcs(_("This IME work best when environment variable are\n"
+                           "- GTK_IM_MODULE=scim-bridge\n"
+                           "- QT_IM_MODULE=xim\n"
+                           " If you use preedit, you don't not need that\n\n"
+                           
+                           "Some time, in some application, you \"must\"\n"
+                           "enable Preedit to type best\n\n"
+
+                           "In some application, scim can't enable,\n"
+                           "this is not a bug of scim-unikey.\n"
+                           "You can try this in terminal: app_name | scim\n\n"
+
+                           "This IME come into being not intend to\n"
+                           "replace scim-m17n, just a choose, I recommend\n"
+                           "use this combine with scim-m17n\n\n"
+
+                           "For other support goto:\n"
+                           "  http://forum.ubuntu-vn.org/viewforum.php?f=85"));
 }
 String UnikeyFactory::get_icon_file() const
 {
-       return String(SCIM_ICONDIR SCIM_UNIKEY_ICON_FILENAME);
+    return String(SCIM_ICONDIR SCIM_UNIKEY_ICON_FILENAME);
 }
 
 IMEngineInstancePointer UnikeyFactory::create_instance(const String & encoding, int id)
 {
-       return new UnikeyInstance(this, encoding, id);
+    return new UnikeyInstance(this, encoding, id);
 }
 
 UnikeyInstance::UnikeyInstance(UnikeyFactory *factory, const String &encoding, int id)
-       :IMEngineInstanceBase(factory, encoding, id),
-        m_auto_commit(false)
+    :IMEngineInstanceBase(factory, encoding, id),
+     m_auto_commit(false)
 {
-       static bool t, o;  //temp variable
+    static bool t, o;  //temp variable
 
-       m_preeditstring.clear();
+    m_preeditstring.clear();
 
-       CreateDefaultUnikeyOptions(&m_ukopt);
+    CreateDefaultUnikeyOptions(&m_ukopt);
 
-       /* Read config
-          if can't read config, set it to default value*/
+    /* Read config
+       if can't read config, set it to default value*/
 
     t = __config->read(SCIM_IMENGINE_UNIKEY_INPUTMETHOD, &m_im);
-       if (!t) m_im = 0;
+    if (!t) m_im = 0;
 
     t = __config->read(SCIM_IMENGINE_UNIKEY_OUTPUTCHARSET, &m_oc);
-       if (!t) m_oc = 0;
+    if (!t) m_oc = 0;
 
-       t = __config->read(SCIM_IMENGINE_UNIKEY_PREEDIT, &m_preedit);
-       if (!t) m_preedit = SCIM_IMENGINE_UNIKEY_PREEDIT_DEF;
+    t = __config->read(SCIM_IMENGINE_UNIKEY_PREEDIT, &m_preedit);
+    if (!t) m_preedit = SCIM_IMENGINE_UNIKEY_PREEDIT_DEF;
 
     // read preedit switch key
-       m_preeditskey.clear();
-       String s;
-       int i = 0, j;
-       t = __config->read(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, &s);
-       if (!t) s=SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY_DEF;
-       if (s.length())
-       {
-               while (true)
-               {
-                       j=s.find(',', i);
-                       if (j!=String::npos)
-                               m_preeditskey.push_back(KeyEvent(s.substr(i, j-i)));
-                       else
-                               break;
-                       i = j+1;
-               }
-               m_preeditskey.push_back(KeyEvent(s.substr(i)));
-       } // end read preedit switch key
-
-       t = __config->read(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, &o);
-       m_process_w_AtBeginWord = t?o:SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
-
-       t = __config->read(SCIM_IMENGINE_UNIKEY_CODERTELEX, &o);
-       m_codertelex = t?o:SCIM_IMENGINE_UNIKEY_CODERTELEX_DEF;
+    m_preeditskey.clear();
+    String s;
+    int i = 0, j;
+    t = __config->read(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, &s);
+    if (!t) s=SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY_DEF;
+    if (s.length())
+    {
+        while (true)
+        {
+            j=s.find(',', i);
+            if (j!=String::npos)
+                m_preeditskey.push_back(KeyEvent(s.substr(i, j-i)));
+            else
+                break;
+            i = j+1;
+        }
+        m_preeditskey.push_back(KeyEvent(s.substr(i)));
+    } // end read preedit switch key
+
+    t = __config->read(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, &o);
+    m_process_w_AtBeginWord = t?o:SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
+
+    t = __config->read(SCIM_IMENGINE_UNIKEY_CODERTELEX, &o);
+    m_codertelex = t?o:SCIM_IMENGINE_UNIKEY_CODERTELEX_DEF;
 
 // Unikey Options
-       t = __config->read(SCIM_IMENGINE_UNIKEY_FREEMARKING, &o);
-       m_ukopt.freeMarking = t?o:SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
+    t = __config->read(SCIM_IMENGINE_UNIKEY_FREEMARKING, &o);
+    m_ukopt.freeMarking = t?o:SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
 
-       t = __config->read(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, &o);
-       m_ukopt.modernStyle = t?o:SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
+    t = __config->read(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, &o);
+    m_ukopt.modernStyle = t?o:SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
 
-       t = __config->read(SCIM_IMENGINE_UNIKEY_MACROENABLED, &o);
-       m_ukopt.macroEnabled = t?o:SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
+    t = __config->read(SCIM_IMENGINE_UNIKEY_MACROENABLED, &o);
+    m_ukopt.macroEnabled = t?o:SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
 
-       t = __config->read(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, &o);
-       m_ukopt.spellCheckEnabled = t?o:SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
+    t = __config->read(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, &o);
+    m_ukopt.spellCheckEnabled = t?o:SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
 
-       t = __config->read(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, &o);
-       m_ukopt.autoNonVnRestore = t?o:SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
+    t = __config->read(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, &o);
+    m_ukopt.autoNonVnRestore = t?o:SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
 
-       UnikeySetOptions(&m_ukopt);
+    UnikeySetOptions(&m_ukopt);
 
-       if (m_ukopt.macroEnabled)
+    if (m_ukopt.macroEnabled)
     {
-               UnikeyLoadMacroTable(getMacroFile());
+        UnikeyLoadMacroTable(getMacroFile());
     }
 }
 
@@ -229,59 +236,59 @@ UnikeyInstance::~UnikeyInstance()
 
 void UnikeyInstance::focus_in()
 {
-       reset();
+    reset();
 
-       register_properties(CreatePropertyList());
+    register_properties(CreatePropertyList());
 
-       UnikeySetInputMethod(Unikey_IM[m_im]);
-       UnikeySetOutputCharset(Unikey_OC[m_oc]);
-       UnikeySetOptions(&m_ukopt);
+    UnikeySetInputMethod(Unikey_IM[m_im]);
+    UnikeySetOutputCharset(Unikey_OC[m_oc]);
+    UnikeySetOptions(&m_ukopt);
 }
 
 void UnikeyInstance::focus_out()
 {
-       reset();
+    reset();
 }
 
 void UnikeyInstance::reset()
 {
-       UnikeyResetBuf();
+    UnikeyResetBuf();
 
     m_lastkey_with_shift = false;
 
-       if (m_preedit)
-       {
-               if (m_preeditstring.length())
-               {
-                       commit_string(m_preeditstring);
-                       hide_preedit_string();
-                       m_preeditstring.clear();
-               }
-               m_auto_commit = false;
-       }
+    if (m_preedit)
+    {
+        if (m_preeditstring.length())
+        {
+            commit_string(m_preeditstring);
+            hide_preedit_string();
+            m_preeditstring.clear();
+        }
+        m_auto_commit = false;
+    }
 }
 
 void UnikeyInstance::Unikey_send_backspace(int nBackspace)
 {
-       static WideString ws;
-       static int n;
-
-       //  if surrounding text was provided, use it instead of send backspace
-       if (get_surrounding_text(ws, n, nBackspace, 0))
-       {
-               // for type in Auto Complete in OpenOffice
-               // Hope this not rise bugs in others application
-               // not use SCIM_KEY_NullKey, because GTK application crash when GTK_IM_MODULE=scim
-
-               forward_key_event(SCIM_KEY_VoidSymbol);
-
-               delete_surrounding_text(-ws.length(), ws.length());
-       }
-       else
-       {
-               for (int i=0; i < nBackspace; i++)
-                       forward_key_event(SCIM_KEY_BackSpace);
-       }
+    static WideString ws;
+    static int n;
+
+    //  if surrounding text was provided, use it instead of send backspace
+    if (get_surrounding_text(ws, n, nBackspace, 0))
+    {
+        // for type in Auto Complete in OpenOffice
+        // Hope this not rise bugs in others application
+        // not use SCIM_KEY_NullKey, because GTK application crash when GTK_IM_MODULE=scim
+
+        forward_key_event(SCIM_KEY_VoidSymbol);
+
+        delete_surrounding_text(-ws.length(), ws.length());
+    }
+    else
+    {
+        for (int i=0; i < nBackspace; i++)
+            forward_key_event(SCIM_KEY_BackSpace);
+    }
 }
 
 void UnikeyInstance::Unikey_update_preedit_string(const WideString s, const bool visible)
@@ -315,17 +322,17 @@ bool UnikeyInstance::process_key_event(const KeyEvent& key)
 {
     bool tmp;
 
-       for (int i; i<m_preeditskey.size(); i++)
-               if (key==m_preeditskey.at(i))
-               {
-                       reset();
-                       m_preedit=!m_preedit;
-                       register_properties(CreatePropertyList());
-                       return true;
-               }
+    for (int i; i<m_preeditskey.size(); i++)
+        if (key==m_preeditskey.at(i))
+        {
+            reset();
+            m_preedit=!m_preedit;
+            register_properties(CreatePropertyList());
+            return true;
+        }
 
     tmp = m_preedit?Unikey_process_key_event_preedit(key)
-               :Unikey_process_key_event_direct(key);
+        :Unikey_process_key_event_direct(key);
 
 
     if ((key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
@@ -338,595 +345,595 @@ bool UnikeyInstance::process_key_event(const KeyEvent& key)
         m_lastkey_with_shift = false;
     }
 
-       return tmp;
+    return tmp;
 }
 
 /** This method not use preedit string */
 bool UnikeyInstance::Unikey_process_key_event_direct(const KeyEvent& key)
 {
-       if (key.is_key_release())
-               return false;
-
-       if (key.is_control_down() || key.mask & SCIM_KEY_AltMask)
-       {
-               reset();
-               return false;
-       }
-
-       if (key.code >= SCIM_KEY_Shift_L && key.code <= SCIM_KEY_Hyper_R)
-               return false;
-
-       if (key.code == SCIM_KEY_BackSpace)
-       {
-               UnikeyBackspacePress();     // xu ly phim backspace
-               if (UnikeyBackspaces==0)    // neu ukengine bao khong can xoa ky tu nao,
-                       return false;  // thi tra lai backspace cho chuong trinh khach
-               else
-               {
-                       Unikey_send_backspace(UnikeyBackspaces);
-
-                       // append key that need change tone pos after press backspace
-                       if (UnikeyBufChars)
-                       {
-                               if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
-                                       commit_string(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));  // send the solved string to client
-                               else
-                               {
-                                       static unsigned char buf[1024];
-                                       int bufSize=sizeof(buf)/sizeof(buf[0]);
-
-                                       latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
-                                       commit_string(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0]) - bufSize));
-                               }
-                       }
-
-                       return true;
-               }
-       }
-
-       if (   (key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
-                  || (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
-               )
-       {
-               UnikeySetCapsState(key.mask & SCIM_KEY_ShiftMask,
-                                                  key.mask & SCIM_KEY_CapsLockMask);
+    if (key.is_key_release())
+        return false;
+
+    if (key.is_control_down() || key.mask & SCIM_KEY_AltMask)
+    {
+        reset();
+        return false;
+    }
+
+    if (key.code >= SCIM_KEY_Shift_L && key.code <= SCIM_KEY_Hyper_R)
+        return false;
+
+    if (key.code == SCIM_KEY_BackSpace)
+    {
+        UnikeyBackspacePress();     // xu ly phim backspace
+        if (UnikeyBackspaces==0)    // neu ukengine bao khong can xoa ky tu nao,
+            return false;  // thi tra lai backspace cho chuong trinh khach
+        else
+        {
+            Unikey_send_backspace(UnikeyBackspaces);
+
+            // append key that need change tone pos after press backspace
+            if (UnikeyBufChars)
+            {
+                if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
+                    commit_string(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));  // send the solved string to client
+                else
+                {
+                    static unsigned char buf[1024];
+                    int bufSize=sizeof(buf)/sizeof(buf[0]);
+
+                    latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
+                    commit_string(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0]) - bufSize));
+                }
+            }
+
+            return true;
+        }
+    }
+
+    if (   (key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
+           || (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
+        )
+    {
+        UnikeySetCapsState(key.mask & SCIM_KEY_ShiftMask,
+                           key.mask & SCIM_KEY_CapsLockMask);
 
         // shift + space to restore keystroke
-               if (m_lastkey_with_shift == false
+        if (m_lastkey_with_shift == false
             && key.mask & SCIM_KEY_ShiftMask
             && key.code == SCIM_KEY_space
-                       && !UnikeyAtWordBeginning())
+            && !UnikeyAtWordBeginning())
         {
-                       UnikeyRestoreKeyStrokes();
+            UnikeyRestoreKeyStrokes();
         }
 
-               else if ((key.code >= SCIM_KEY_KP_0 &&
-                                 key.code <= SCIM_KEY_KP_9))
+        else if ((key.code >= SCIM_KEY_KP_0 &&
+                  key.code <= SCIM_KEY_KP_9))
         {
-                       UnikeyPutChar(key.code);
+            UnikeyPutChar(key.code);
         }
 
-               else if (!m_process_w_AtBeginWord &&
-                                (key.code == SCIM_KEY_w || key.code == SCIM_KEY_W) &&
-                                UnikeyAtWordBeginning())
+        else if (!m_process_w_AtBeginWord &&
+                 (key.code == SCIM_KEY_w || key.code == SCIM_KEY_W) &&
+                 UnikeyAtWordBeginning())
         {
-                       UnikeyPutChar(key.code);
+            UnikeyPutChar(key.code);
         }
 
-               else if (m_codertelex && Unikey_IM[m_im] == UkTelex
-                                && (key.code == SCIM_KEY_bracketleft || key.code == SCIM_KEY_bracketright
-                                        || key.code == SCIM_KEY_braceleft || key.code == SCIM_KEY_braceright)
-                       )
+        else if (m_codertelex && Unikey_IM[m_im] == UkTelex
+                 && (key.code == SCIM_KEY_bracketleft || key.code == SCIM_KEY_bracketright
+                     || key.code == SCIM_KEY_braceleft || key.code == SCIM_KEY_braceright)
+            )
         {
-                       UnikeyPutChar(key.code);
+            UnikeyPutChar(key.code);
         }
-               else
+        else
         {
-                       UnikeyFilter(key.code);
+            UnikeyFilter(key.code);
         }
 
-               if (UnikeyBackspaces)
+        if (UnikeyBackspaces)
         {
-                       Unikey_send_backspace(UnikeyBackspaces);
+            Unikey_send_backspace(UnikeyBackspaces);
         }
 
-               if (UnikeyBufChars)
-               {
-                       if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
+        if (UnikeyBufChars)
+        {
+            if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
+            {
+                commit_string(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));  // send the solved string to client
+            }
+            else
             {
-                               commit_string(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));  // send the solved string to client
+                static unsigned char buf[1024];
+                int bufSize=sizeof(buf)/sizeof(buf[0]);
+
+                latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
+                commit_string(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0]) - bufSize));
             }
-                       else
-                       {
-                               static unsigned char buf[1024];
-                               int bufSize=sizeof(buf)/sizeof(buf[0]);
-
-                               latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
-                               commit_string(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0]) - bufSize));
-                       }
-               }
-               else
+        }
+        else
         {
             forward_key_event(key);
-                       return true;
+            return true;
         }
 
-               return true;
-       }
+        return true;
+    }
 
-       // else
-       reset();
-       return false;
+    // else
+    reset();
+    return false;
 }
 
 /** This method use preedit string */
 bool UnikeyInstance::Unikey_process_key_event_preedit(const KeyEvent& key)
 {
-       static int i;
-
-       if (key.code == SCIM_KEY_Tab
-               || key.mask & SCIM_KEY_ControlMask
-               || key.mask & SCIM_KEY_AltMask)
-       {
-               if (m_preeditstring.length())
-               {
-                       commit_string(m_preeditstring);
-                       hide_preedit_string();
-                       m_preeditstring.clear();
-               }
-               reset();
-               return false;
-       }
-
-       if (key.is_key_release())
-               return false;
-
-       if (key.code >= SCIM_KEY_Shift_L && key.code <= SCIM_KEY_Hyper_R)
-               return false;
-
-       else if (key.code == SCIM_KEY_Tab || key.code == SCIM_KEY_Return
-                        || key.code == SCIM_KEY_Delete || key.code == SCIM_KEY_KP_Enter
-                        || (key.code >= SCIM_KEY_Home && key.code <= SCIM_KEY_Insert)
-                        || (key.code >= SCIM_KEY_KP_Home && key.code <= SCIM_KEY_KP_Delete)
-               )
-       {
-               if (m_preeditstring.length())
-               {
-                       commit_string(m_preeditstring);
-                       hide_preedit_string();
-                       m_preeditstring.clear();
-               }
-
-               reset();
-               return false;
-       }
-
-       else if (key.code == SCIM_KEY_BackSpace)
-       {
-               UnikeyBackspacePress();     // process Backspace
-
-               if (UnikeyBackspaces==0 || m_preeditstring.empty())    // if Unikey tell no Backspace
-               {
-                       reset();
-                       return false;  // Return Backspace to client
-               }
-               else
-               {
-                       static int len;
-
-                       len = m_preeditstring.length();
-                       if (len <= UnikeyBackspaces)
-                       {
-                               m_preeditstring.clear();
-                               hide_preedit_string();
-                               m_auto_commit = true;
-                       }
-                       else
-                       {
-                               m_preeditstring.erase(len - UnikeyBackspaces, UnikeyBackspaces);
-                               Unikey_update_preedit_string(m_preeditstring, true);
-                       }
-
-                       // append key that need change tone pos after press backspace
-                       if (UnikeyBufChars)
-                       {
-                               if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
-                                       m_preeditstring.append(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));
-                               else
-                               {
-                                       static unsigned char buf[1024];
-                                       int bufSize=sizeof(buf)/sizeof(buf[0]);
-
-                                       latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
-                                       m_preeditstring.append(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0])-bufSize));
-                               }
-
-                               m_auto_commit = false;
-                               Unikey_update_preedit_string(m_preeditstring, true);
-                       }
-               }
-
-               return true;
-       }
-
-       else if (   (key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
-                               || (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
-               )
-       {
-               UnikeySetCapsState(key.mask & SCIM_KEY_ShiftMask, key.mask & SCIM_KEY_CapsLockMask);
+    static int i;
+
+    if (key.code == SCIM_KEY_Tab
+        || key.mask & SCIM_KEY_ControlMask
+        || key.mask & SCIM_KEY_AltMask)
+    {
+        if (m_preeditstring.length())
+        {
+            commit_string(m_preeditstring);
+            hide_preedit_string();
+            m_preeditstring.clear();
+        }
+        reset();
+        return false;
+    }
+
+    if (key.is_key_release())
+        return false;
+
+    if (key.code >= SCIM_KEY_Shift_L && key.code <= SCIM_KEY_Hyper_R)
+        return false;
+
+    else if (key.code == SCIM_KEY_Tab || key.code == SCIM_KEY_Return
+             || key.code == SCIM_KEY_Delete || key.code == SCIM_KEY_KP_Enter
+             || (key.code >= SCIM_KEY_Home && key.code <= SCIM_KEY_Insert)
+             || (key.code >= SCIM_KEY_KP_Home && key.code <= SCIM_KEY_KP_Delete)
+        )
+    {
+        if (m_preeditstring.length())
+        {
+            commit_string(m_preeditstring);
+            hide_preedit_string();
+            m_preeditstring.clear();
+        }
+
+        reset();
+        return false;
+    }
+
+    else if (key.code == SCIM_KEY_BackSpace)
+    {
+        UnikeyBackspacePress();     // process Backspace
+
+        if (UnikeyBackspaces==0 || m_preeditstring.empty())    // if Unikey tell no Backspace
+        {
+            reset();
+            return false;  // Return Backspace to client
+        }
+        else
+        {
+            static int len;
+
+            len = m_preeditstring.length();
+            if (len <= UnikeyBackspaces)
+            {
+                m_preeditstring.clear();
+                hide_preedit_string();
+                m_auto_commit = true;
+            }
+            else
+            {
+                m_preeditstring.erase(len - UnikeyBackspaces, UnikeyBackspaces);
+                Unikey_update_preedit_string(m_preeditstring, true);
+            }
+
+            // append key that need change tone pos after press backspace
+            if (UnikeyBufChars)
+            {
+                if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
+                    m_preeditstring.append(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));
+                else
+                {
+                    static unsigned char buf[1024];
+                    int bufSize=sizeof(buf)/sizeof(buf[0]);
+
+                    latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
+                    m_preeditstring.append(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0])-bufSize));
+                }
+
+                m_auto_commit = false;
+                Unikey_update_preedit_string(m_preeditstring, true);
+            }
+        }
+
+        return true;
+    }
+
+    else if (   (key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
+                || (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
+        )
+    {
+        UnikeySetCapsState(key.mask & SCIM_KEY_ShiftMask, key.mask & SCIM_KEY_CapsLockMask);
 
         // auto commit char: commit char that never change later in preedit string
         // if macro enabled, then not auto commit. Because macro may change any word
-               if (m_ukopt.macroEnabled==0 && (UnikeyAtWordBeginning() || m_auto_commit))
-               {
-                       for (i = 0; i < sizeof(WordAutoCommit); i++)
-                               if (key.code == WordAutoCommit[i])
-                               {
-                                       UnikeyPutChar(key.code);
-                                       m_auto_commit = true;
+        if (m_ukopt.macroEnabled==0 && (UnikeyAtWordBeginning() || m_auto_commit))
+        {
+            for (i = 0; i < sizeof(WordAutoCommit); i++)
+                if (key.code == WordAutoCommit[i])
+                {
+                    UnikeyPutChar(key.code);
+                    m_auto_commit = true;
                     forward_key_event(key); // forward keyevent instead of return false
-                                       return true;
-                               }
-               } // end auto commit char
+                    return true;
+                }
+        } // end auto commit char
 
-               if (!m_process_w_AtBeginWord && (key.code == SCIM_KEY_w || key.code == SCIM_KEY_W) && UnikeyAtWordBeginning())
-               {
-                       UnikeyPutChar(key.code);
-                       m_auto_commit = true;
-                       return false;
-               }
+        if (!m_process_w_AtBeginWord && (key.code == SCIM_KEY_w || key.code == SCIM_KEY_W) && UnikeyAtWordBeginning())
+        {
+            UnikeyPutChar(key.code);
+            m_auto_commit = true;
+            return false;
+        }
 
-               m_auto_commit = false;
+        m_auto_commit = false;
 
-               if (m_lastkey_with_shift == false
+        if (m_lastkey_with_shift == false
             && key.mask & SCIM_KEY_ShiftMask
             && key.code == SCIM_KEY_space
-                       && !UnikeyAtWordBeginning())
+            && !UnikeyAtWordBeginning())
         {
-                       UnikeyRestoreKeyStrokes();
+            UnikeyRestoreKeyStrokes();
+        }
+        else if (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
+            UnikeyPutChar(key.code);
+        else if (m_codertelex && Unikey_IM[m_im] == UkTelex
+                 && (key.code == SCIM_KEY_bracketleft || key.code == SCIM_KEY_bracketright
+                     || key.code == SCIM_KEY_braceleft || key.code == SCIM_KEY_braceright)
+            )
+            UnikeyPutChar(key.code);
+        else
+            UnikeyFilter(key.code);
+
+        if (UnikeyBackspaces > 0)
+        {
+            static int len;
+
+            len = m_preeditstring.length();
+
+            if (len <= UnikeyBackspaces)
+                m_preeditstring.clear();
+            else
+                m_preeditstring.erase(len - UnikeyBackspaces, UnikeyBackspaces);
+        }
+
+        if (UnikeyBufChars > 0)
+        {
+            if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
+                m_preeditstring.append(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));
+            else
+            {
+                static unsigned char buf[1024];
+                int bufSize=sizeof(buf)/sizeof(buf[0]);
+
+                latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
+                m_preeditstring.append(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0])-bufSize));
+            }
+        }
+        else
+        {    
+            m_preeditstring.push_back(key.get_unicode_code());
+        }
+
+        if (m_preeditstring.length())
+        {
+            if (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
+            {
+                commit_string(m_preeditstring);
+                hide_preedit_string();
+                m_preeditstring.clear();
+                reset();
+                return true;
+            }
+            else
+            {
+                for (i=0; i < sizeof(WordBreakSyms); i++)
+                    if (WordBreakSyms[i] == m_preeditstring[m_preeditstring.length()-1] && key.code == WordBreakSyms[i])
+                    {
+                        commit_string(m_preeditstring);
+                        hide_preedit_string();
+                        m_preeditstring.clear();
+                        reset();
+                        return true;
+                    }
+            }
         }
-               else if (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
-                       UnikeyPutChar(key.code);
-               else if (m_codertelex && Unikey_IM[m_im] == UkTelex
-                                && (key.code == SCIM_KEY_bracketleft || key.code == SCIM_KEY_bracketright
-                                        || key.code == SCIM_KEY_braceleft || key.code == SCIM_KEY_braceright)
-                       )
-                       UnikeyPutChar(key.code);
-               else
-                       UnikeyFilter(key.code);
-
-               if (UnikeyBackspaces > 0)
-               {
-                       static int len;
-
-                       len = m_preeditstring.length();
-
-                       if (len <= UnikeyBackspaces)
-                               m_preeditstring.clear();
-                       else
-                               m_preeditstring.erase(len - UnikeyBackspaces, UnikeyBackspaces);
-               }
-
-               if (UnikeyBufChars > 0)
-               {
-                       if (Unikey_OC[m_oc] == CONV_CHARSET_XUTF8)
-                               m_preeditstring.append(utf8_mbstowcs((const char*)UnikeyBuf, UnikeyBufChars));
-                       else
-                       {
-                               static unsigned char buf[1024];
-                               int bufSize=sizeof(buf)/sizeof(buf[0]);
-
-                               latinToUtf(buf, UnikeyBuf, UnikeyBufChars, &bufSize);
-                               m_preeditstring.append(utf8_mbstowcs((const char*)buf, sizeof(buf)/sizeof(buf[0])-bufSize));
-                       }
-               }
-               else
-               {       
-                       m_preeditstring.push_back(key.get_unicode_code());
-               }
-
-               if (m_preeditstring.length())
-               {
-                       if (key.code >= SCIM_KEY_KP_Multiply && key.code <= SCIM_KEY_KP_9)
-                       {
-                               commit_string(m_preeditstring);
-                               hide_preedit_string();
-                               m_preeditstring.clear();
-                               reset();
-                               return true;
-                       }
-                       else
-                       {
-                               for (i=0; i < sizeof(WordBreakSyms); i++)
-                                       if (WordBreakSyms[i] == m_preeditstring[m_preeditstring.length()-1] && key.code == WordBreakSyms[i])
-                                       {
-                                               commit_string(m_preeditstring);
-                                               hide_preedit_string();
-                                               m_preeditstring.clear();
-                                               reset();
-                                               return true;
-                                       }
-                       }
-               }
 
         Unikey_update_preedit_string(m_preeditstring, true);
-               return true;
-       }
+        return true;
+    }
 
-       // else (key non process)
-       reset();
-       return false;
+    // else (key non process)
+    reset();
+    return false;
 }
 
 PropertyList UnikeyInstance::CreatePropertyList()
 {
-       PropertyList props;
-       int i;
+    PropertyList props;
+    int i;
 
-       Property prop("", "", "", "");
+    Property prop("", "", "", "");
 
 // input method
-       prop.set_key("/Unikey/InputMethod");
-       prop.set_label(Unikey_IMNames[m_im]);
-       prop.set_icon("");
-       prop.set_tip(_("Choose input method"));
-       props.push_back(prop);
-
-       for (i=0; i<NUM_INPUTMETHOD; i++)
-       {
-               prop.set_key(String("/Unikey/InputMethod/") + Unikey_IMNames[i] + String(m_im==i?"-Checked":""));
-               prop.set_label(Unikey_IMNames[i]);
-               prop.set_icon(m_im==i?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-               prop.set_tip("");
-               props.push_back(prop);
-       }
+    prop.set_key("/Unikey/InputMethod");
+    prop.set_label(Unikey_IMNames[m_im]);
+    prop.set_icon("");
+    prop.set_tip(_("Choose input method"));
+    props.push_back(prop);
+
+    for (i=0; i<NUM_INPUTMETHOD; i++)
+    {
+        prop.set_key(String("/Unikey/InputMethod/") + Unikey_IMNames[i] + String(m_im==i?"-Checked":""));
+        prop.set_label(Unikey_IMNames[i]);
+        prop.set_icon(m_im==i?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+        prop.set_tip("");
+        props.push_back(prop);
+    }
 
 // output charset
 
-       prop.set_key("/Unikey/OutputCharset");
-       prop.set_label(Unikey_OCNames[m_oc]);
-       prop.set_icon("");
-       prop.set_tip(_("Choose output charset"));
-       props.push_back(prop);
-
-       for (i=0; i<NUM_OUTPUTCHARSET; i++)
-       {
-               prop.set_key(String("/Unikey/OutputCharset/") + Unikey_OCNames[i] + String(m_oc==i?"-Checked":""));
-               prop.set_label(Unikey_OCNames[i]);
-               prop.set_icon(m_oc==i?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-               prop.set_tip("");
-               props.push_back(prop);
-       }
+    prop.set_key("/Unikey/OutputCharset");
+    prop.set_label(Unikey_OCNames[m_oc]);
+    prop.set_icon("");
+    prop.set_tip(_("Choose output charset"));
+    props.push_back(prop);
+
+    for (i=0; i<NUM_OUTPUTCHARSET; i++)
+    {
+        prop.set_key(String("/Unikey/OutputCharset/") + Unikey_OCNames[i] + String(m_oc==i?"-Checked":""));
+        prop.set_label(Unikey_OCNames[i]);
+        prop.set_icon(m_oc==i?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+        prop.set_tip("");
+        props.push_back(prop);
+    }
 
 // unikey options
     // menu
-       prop.set_key("/Unikey/Options");
-       prop.set_label(_("Options"));
-       prop.set_icon(SCIM_ICONDIR SCIM_UNIKEY_ICON_CONFIGURE);
-       prop.set_tip(_("Configure Unikey here"));
-       props.push_back(prop);
-
-       // spellcheck
-       prop.set_key(m_ukopt.spellCheckEnabled?
-                                "/Unikey/Options/SpellCheck/Disable":"/Unikey/Options/SpellCheck/Enable");
-       prop.set_label(_("Enable spell check"));
-       prop.set_icon(m_ukopt.spellCheckEnabled?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip(_("If enable, you can decrease mistake when typing"));
-       props.push_back(prop);
-       
-       // auto restore keystroke
-       prop.set_key(m_ukopt.autoNonVnRestore?
-                                "/Unikey/Options/AutoRestoreKeys/Disable":"/Unikey/Options/AutoRestoreKeys/Enable");
-       prop.set_label(_("Auto restore keys with invalid words"));
-       prop.set_icon(m_ukopt.autoNonVnRestore?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip(_("When typing a word not in Vietnamese,\n"
-                                                 "it will auto restore keystroke into orginal"));
-       props.push_back(prop);
-
-       // modern style
-       prop.set_key(m_ukopt.modernStyle?
-                                "/Unikey/Options/ModernStyle/Disable":"/Unikey/Options/ModernStyle/Enable");
-       prop.set_label(_("Use oà, uý (instead of òa, úy)"));
-       prop.set_icon(m_ukopt.modernStyle?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip("");
-       props.push_back(prop);
-
-       // freeMarking
-       prop.set_key(m_ukopt.freeMarking?
-                                "/Unikey/Options/FreeMarking/Disable":"/Unikey/Options/FreeMarking/Enable");
-       prop.set_label(_("Allow type with more freedom"));
-       prop.set_icon(m_ukopt.freeMarking?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip("");
-       props.push_back(prop);
-
-       // macro
-       prop.set_key(m_ukopt.macroEnabled?
-                                "/Unikey/Options/EnabledMacro/Disable":"/Unikey/Options/EnabledMacro/Enable");
-       prop.set_label(_("Enable Macro"));
-       prop.set_icon(m_ukopt.macroEnabled?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip("");
-       props.push_back(prop);
-
-       // preedit
-       prop.set_key(m_preedit?"/Unikey/Options/Preedit/Disable":"/Unikey/Options/Preedit/Enable");
-       prop.set_label(_("Enable PreEdit"));
-       prop.set_icon(m_preedit?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip(_("This option is best for most application\n"
-                                  "But you may don't like it because it have an underline when typing"));
-       props.push_back(prop);
-
-       // process w at begin
-       prop.set_key(m_process_w_AtBeginWord?
-                                "/Unikey/Options/ProcessWAtBegin/Disable":"/Unikey/Options/ProcessWAtBegin/Enable");
-       prop.set_label(_("Process W at word begin"));
-       prop.set_icon(m_process_w_AtBeginWord?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip(_("If enable, type W at begin\n"
-                                  "of word will change to Ư."));
-       props.push_back(prop);
-
-       // coder telex [,],{,}
-       prop.set_key(m_codertelex?
-                                "/Unikey/Options/CoderTelex/Disable":"/Unikey/Options/CoderTelex/Enable");
-       prop.set_label(_("Not use [,],{,} on Telex"));
-       prop.set_icon(m_codertelex?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
-       prop.set_tip(_("Not use [,],{,} for map on Telex"));
-       props.push_back(prop);
-
-
-       return props;
+    prop.set_key("/Unikey/Options");
+    prop.set_label(_("Options"));
+    prop.set_icon(SCIM_ICONDIR SCIM_UNIKEY_ICON_CONFIGURE);
+    prop.set_tip(_("Configure Unikey here"));
+    props.push_back(prop);
+
+    // spellcheck
+    prop.set_key(m_ukopt.spellCheckEnabled?
+                 "/Unikey/Options/SpellCheck/Disable":"/Unikey/Options/SpellCheck/Enable");
+    prop.set_label(_("Enable spell check"));
+    prop.set_icon(m_ukopt.spellCheckEnabled?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip(_("If enable, you can decrease mistake when typing"));
+    props.push_back(prop);
+    
+    // auto restore keystroke
+    prop.set_key(m_ukopt.autoNonVnRestore?
+                 "/Unikey/Options/AutoRestoreKeys/Disable":"/Unikey/Options/AutoRestoreKeys/Enable");
+    prop.set_label(_("Auto restore keys with invalid words"));
+    prop.set_icon(m_ukopt.autoNonVnRestore?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip(_("When typing a word not in Vietnamese,\n"
+                   "it will auto restore keystroke into orginal"));
+    props.push_back(prop);
+
+    // modern style
+    prop.set_key(m_ukopt.modernStyle?
+                 "/Unikey/Options/ModernStyle/Disable":"/Unikey/Options/ModernStyle/Enable");
+    prop.set_label(_("Use oà, uý (instead of òa, úy)"));
+    prop.set_icon(m_ukopt.modernStyle?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip("");
+    props.push_back(prop);
+
+    // freeMarking
+    prop.set_key(m_ukopt.freeMarking?
+                 "/Unikey/Options/FreeMarking/Disable":"/Unikey/Options/FreeMarking/Enable");
+    prop.set_label(_("Allow type with more freedom"));
+    prop.set_icon(m_ukopt.freeMarking?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip("");
+    props.push_back(prop);
+
+    // macro
+    prop.set_key(m_ukopt.macroEnabled?
+                 "/Unikey/Options/EnabledMacro/Disable":"/Unikey/Options/EnabledMacro/Enable");
+    prop.set_label(_("Enable Macro"));
+    prop.set_icon(m_ukopt.macroEnabled?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip("");
+    props.push_back(prop);
+
+    // preedit
+    prop.set_key(m_preedit?"/Unikey/Options/Preedit/Disable":"/Unikey/Options/Preedit/Enable");
+    prop.set_label(_("Enable PreEdit"));
+    prop.set_icon(m_preedit?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip(_("This option is best for most application\n"
+                   "But you may don't like it because it have an underline when typing"));
+    props.push_back(prop);
+
+    // process w at begin
+    prop.set_key(m_process_w_AtBeginWord?
+                 "/Unikey/Options/ProcessWAtBegin/Disable":"/Unikey/Options/ProcessWAtBegin/Enable");
+    prop.set_label(_("Process W at word begin"));
+    prop.set_icon(m_process_w_AtBeginWord?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip(_("If enable, type W at begin\n"
+                   "of word will change to Ư."));
+    props.push_back(prop);
+
+    // coder telex [,],{,}
+    prop.set_key(m_codertelex?
+                 "/Unikey/Options/CoderTelex/Disable":"/Unikey/Options/CoderTelex/Enable");
+    prop.set_label(_("Not use [,],{,} on Telex"));
+    prop.set_icon(m_codertelex?SCIM_ICONDIR SCIM_UNIKEY_ICON_CHECK:"");
+    prop.set_tip(_("Not use [,],{,} for map on Telex"));
+    props.push_back(prop);
+
+
+    return props;
 }
 
 void UnikeyInstance::trigger_property(const String &property)
 {
-       bool change = false;
-       int i;
+    bool change = false;
+    int i;
 
 // input method
-       if (!property.compare(0, strlen("/Unikey/InputMethod/"), "/Unikey/InputMethod/"))
-       {
-               for (i=0; i<NUM_INPUTMETHOD; i++)
-                       if (!property.compare(strlen("/Unikey/InputMethod/"),
+    if (!property.compare(0, strlen("/Unikey/InputMethod/"), "/Unikey/InputMethod/"))
+    {
+        for (i=0; i<NUM_INPUTMETHOD; i++)
+            if (!property.compare(strlen("/Unikey/InputMethod/"),
                                   property.length() - strlen("/Unikey/InputMethod/"),
                                   Unikey_IMNames[i]))
-                       {
-                               m_im = i;
-                               __config->write(SCIM_IMENGINE_UNIKEY_INPUTMETHOD, m_im);
-                               change = true;
-                               break;
-                       }
-       }
+            {
+                m_im = i;
+                __config->write(SCIM_IMENGINE_UNIKEY_INPUTMETHOD, m_im);
+                change = true;
+                break;
+            }
+    }
 
 // output charset
-       else if (!property.compare(0, strlen("/Unikey/OutputCharset/"), "/Unikey/OutputCharset/"))
-       {
-               for (i=0; i<NUM_OUTPUTCHARSET; i++)
-                       if (!property.compare(strlen("/Unikey/OutputCharset/"),
-                                                                 property.length() - strlen("/Unikey/OutputCharset/"),
-                                                                 Unikey_OCNames[i]))
-                       {
-                               m_oc = i;
-                               __config->write(SCIM_IMENGINE_UNIKEY_OUTPUTCHARSET, m_oc);
-                               change = true;
-                               break;
-                       }
-       }
+    else if (!property.compare(0, strlen("/Unikey/OutputCharset/"), "/Unikey/OutputCharset/"))
+    {
+        for (i=0; i<NUM_OUTPUTCHARSET; i++)
+            if (!property.compare(strlen("/Unikey/OutputCharset/"),
+                                  property.length() - strlen("/Unikey/OutputCharset/"),
+                                  Unikey_OCNames[i]))
+            {
+                m_oc = i;
+                __config->write(SCIM_IMENGINE_UNIKEY_OUTPUTCHARSET, m_oc);
+                change = true;
+                break;
+            }
+    }
 
 // spellcheck
-       else if (property == "/Unikey/Options/SpellCheck/Enable")
-       {
-               m_ukopt.spellCheckEnabled = true;
-               __config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/SpellCheck/Disable")
-       {
-               m_ukopt.spellCheckEnabled = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, false);
-               change = true;
-       }
+    else if (property == "/Unikey/Options/SpellCheck/Enable")
+    {
+        m_ukopt.spellCheckEnabled = true;
+        __config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/SpellCheck/Disable")
+    {
+        m_ukopt.spellCheckEnabled = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, false);
+        change = true;
+    }
 
 // auto restore keystroke
-       else if (property == "/Unikey/Options/AutoRestoreKeys/Enable")
-       {
-               m_ukopt.autoNonVnRestore = true;
-               __config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/AutoRestoreKeys/Disable")
-       {
-               m_ukopt.autoNonVnRestore = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, false);
-               change = true;
-       }
+    else if (property == "/Unikey/Options/AutoRestoreKeys/Enable")
+    {
+        m_ukopt.autoNonVnRestore = true;
+        __config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/AutoRestoreKeys/Disable")
+    {
+        m_ukopt.autoNonVnRestore = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, false);
+        change = true;
+    }
 
 // modern style
-       else if (property == "/Unikey/Options/ModernStyle/Enable")
-       {
-               m_ukopt.modernStyle = true;
-               __config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/ModernStyle/Disable")
-       {
-               m_ukopt.modernStyle = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, false);
-               change = true;
-       }
+    else if (property == "/Unikey/Options/ModernStyle/Enable")
+    {
+        m_ukopt.modernStyle = true;
+        __config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/ModernStyle/Disable")
+    {
+        m_ukopt.modernStyle = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, false);
+        change = true;
+    }
 
 // free Marking
-       else if (property == "/Unikey/Options/FreeMarking/Enable")
-       {
-               m_ukopt.freeMarking = true;
-               __config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/FreeMarking/Disable")
-       {
-               m_ukopt.freeMarking = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, false);
-               change = true;
-       }
+    else if (property == "/Unikey/Options/FreeMarking/Enable")
+    {
+        m_ukopt.freeMarking = true;
+        __config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/FreeMarking/Disable")
+    {
+        m_ukopt.freeMarking = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, false);
+        change = true;
+    }
 // macro 
-       else if (property == "/Unikey/Options/EnabledMacro/Enable")
-       {
-               m_ukopt.macroEnabled = true;
+    else if (property == "/Unikey/Options/EnabledMacro/Enable")
+    {
+        m_ukopt.macroEnabled = true;
         UnikeyLoadMacroTable(getMacroFile());
-               __config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/EnabledMacro/Disable")
-       {
-               m_ukopt.macroEnabled = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, false);
-               change = true;
-       }
+        __config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/EnabledMacro/Disable")
+    {
+        m_ukopt.macroEnabled = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, false);
+        change = true;
+    }
 
 // preedit
-       else if (property == "/Unikey/Options/Preedit/Enable")
-       {
-               m_preedit = true;
-               __config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/Preedit/Disable")
-       {
-               m_preedit = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, false);
-               change = true;
-       }
+    else if (property == "/Unikey/Options/Preedit/Enable")
+    {
+        m_preedit = true;
+        __config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/Preedit/Disable")
+    {
+        m_preedit = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, false);
+        change = true;
+    }
 
 // process w at begin
-       else if (property == "/Unikey/Options/ProcessWAtBegin/Enable")
-       {
-               m_process_w_AtBeginWord = true;
-               __config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/ProcessWAtBegin/Disable")
-       {
-               m_process_w_AtBeginWord = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, false);
-               change = true;
-       }
+    else if (property == "/Unikey/Options/ProcessWAtBegin/Enable")
+    {
+        m_process_w_AtBeginWord = true;
+        __config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/ProcessWAtBegin/Disable")
+    {
+        m_process_w_AtBeginWord = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, false);
+        change = true;
+    }
 
 // coder telex
-       else if (property == "/Unikey/Options/CoderTelex/Enable")
-       {
-               m_codertelex = true;
-               __config->write(SCIM_IMENGINE_UNIKEY_CODERTELEX, true);
-               change = true;
-       }
-       else if (property == "/Unikey/Options/CoderTelex/Disable")
-       {
-               m_codertelex = false;
-               __config->write(SCIM_IMENGINE_UNIKEY_CODERTELEX, false);
-               change = true;
-       }
-
-       if (change)
-       {
-               __config->flush();
+    else if (property == "/Unikey/Options/CoderTelex/Enable")
+    {
+        m_codertelex = true;
+        __config->write(SCIM_IMENGINE_UNIKEY_CODERTELEX, true);
+        change = true;
+    }
+    else if (property == "/Unikey/Options/CoderTelex/Disable")
+    {
+        m_codertelex = false;
+        __config->write(SCIM_IMENGINE_UNIKEY_CODERTELEX, false);
+        change = true;
+    }
+
+    if (change)
+    {
+        __config->flush();
         focus_out();
-               focus_in();
-       }
+        focus_in();
+    }
 }
index d8eef9fb30f40c9a2a2d2f35345dc5f7a6a43eaa..2c191cd5c7fb455764b6c700f3a78524a4cbcebf 100644 (file)
@@ -17,51 +17,51 @@ using namespace scim;
 
 class UnikeyFactory : public IMEngineFactoryBase
 {
-       friend class UnikeyInstance;
+    friend class UnikeyInstance;
 
 public:
-       UnikeyFactory();
-       virtual ~UnikeyFactory ();
+    UnikeyFactory();
+    virtual ~UnikeyFactory ();
 
-       virtual WideString  get_name () const;
-       virtual WideString  get_authors () const;
-       virtual WideString  get_credits () const;
-       virtual WideString  get_help () const;
-       virtual String      get_uuid () const;
-       virtual String      get_icon_file () const;
+    virtual WideString  get_name () const;
+    virtual WideString  get_authors () const;
+    virtual WideString  get_credits () const;
+    virtual WideString  get_help () const;
+    virtual String      get_uuid () const;
+    virtual String      get_icon_file () const;
 
-       virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1);
+    virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1);
 };
 
 class UnikeyInstance : public IMEngineInstanceBase
 {
 public:
-       UnikeyInstance(UnikeyFactory *factory, const String& encoding, int id = -1);
-       virtual ~UnikeyInstance ();
+    UnikeyInstance(UnikeyFactory *factory, const String& encoding, int id = -1);
+    virtual ~UnikeyInstance ();
 
-       virtual bool process_key_event(const KeyEvent& key);
-       virtual void reset();
-       virtual void focus_in();
-       virtual void focus_out();
-       virtual void trigger_property(const String &property);
+    virtual bool process_key_event(const KeyEvent& key);
+    virtual void reset();
+    virtual void focus_in();
+    virtual void focus_out();
+    virtual void trigger_property(const String &property);
 
 private:
-       bool Unikey_process_key_event_direct(const KeyEvent& key);
-       bool Unikey_process_key_event_preedit(const KeyEvent& key);
-       void Unikey_send_backspace(int nBackspace);
-       void Unikey_update_preedit_string(const WideString s, const bool visible);
-       PropertyList CreatePropertyList();
+    bool Unikey_process_key_event_direct(const KeyEvent& key);
+    bool Unikey_process_key_event_preedit(const KeyEvent& key);
+    void Unikey_send_backspace(int nBackspace);
+    void Unikey_update_preedit_string(const WideString s, const bool visible);
+    PropertyList CreatePropertyList();
 
-       int m_im;                               // input method
-       int m_oc;                               // output charset
-       UnikeyOptions m_ukopt;                  // Unikey Options
-       WideString m_preeditstring;             // store PreEdit String
-       bool m_preedit;                         // is PreEdit On?
-       bool m_codertelex;                      // is CoderTelex on?
-       bool m_process_w_AtBeginWord;           // process W at Begin Word?
-       bool m_auto_commit;                     // auto commit?
-       std::vector<KeyEvent> m_preeditskey;    // keys to switch preedit and non preedit mode
-       bool m_lastkey_with_shift;              // last press key with modifier is shift
+    int m_im;                             // input method
+    int m_oc;                             // output charset
+    UnikeyOptions m_ukopt;                // Unikey Options
+    WideString m_preeditstring;           // store PreEdit String
+    bool m_preedit;                       // is PreEdit On?
+    bool m_codertelex;                    // is CoderTelex on?
+    bool m_process_w_AtBeginWord;         // process W at Begin Word?
+    bool m_auto_commit;                   // auto commit?
+    std::vector<KeyEvent> m_preeditskey;  // keys to switch preedit and non preedit mode
+    bool m_lastkey_with_shift;            // last press key with modifier is shift
 };
 
 #endif
index 7776d567d2315df919b76099da061a3949ca940d..ace4b8994d0422689140af0fab66fd695aabd9e2 100644 (file)
@@ -80,585 +80,585 @@ static void on_hotkey_button_clicked(GtkButton *button, gpointer user_data);
 
 extern "C"
 {
-       void scim_module_init(void)
-       {
-       }
-
-       void scim_module_exit(void)
-       {
-       }
-
-       GtkWidget * scim_setup_module_create_ui (void)
-       {
-               return create_setup_window();
-       }
-
-       String scim_setup_module_get_category (void)
-       {
-               return String("IMEngine");
-       }
-
-       String scim_setup_module_get_name(void)
-       {
-               return String(_("Unikey Setup"));
-       }
-
-       String scim_setup_module_get_description(void)
-       {
-               return String("Setup scim-unikey v" SCIM_UNIKEY_VERSION " IMEngine.");
-       }
-
-       void scim_setup_module_load_config(const ConfigPointer &config)
-       {
-               load_config(config);
-       }
-
-       void scim_setup_module_save_config(const ConfigPointer &config)
-       {
-               save_config(config);
-       }
-
-       bool scim_setup_module_query_changed()
-       {
-               return query_changed();
-       }
+    void scim_module_init(void)
+    {
+    }
+
+    void scim_module_exit(void)
+    {
+    }
+
+    GtkWidget * scim_setup_module_create_ui (void)
+    {
+        return create_setup_window();
+    }
+
+    String scim_setup_module_get_category (void)
+    {
+        return String("IMEngine");
+    }
+
+    String scim_setup_module_get_name(void)
+    {
+        return String(_("Unikey Setup"));
+    }
+
+    String scim_setup_module_get_description(void)
+    {
+        return String("Setup scim-unikey v" SCIM_UNIKEY_VERSION " IMEngine.");
+    }
+
+    void scim_setup_module_load_config(const ConfigPointer &config)
+    {
+        load_config(config);
+    }
+
+    void scim_setup_module_save_config(const ConfigPointer &config)
+    {
+        save_config(config);
+    }
+
+    bool scim_setup_module_query_changed()
+    {
+        return query_changed();
+    }
 } // extern "C"
 
 static GtkWidget* create_setup_window()
 {
-       static GtkWidget *window = 0;
-       if (!window)
-       {
-               gtk_window_set_default_icon_from_file(SCIM_ICONDIR SCIM_UNIKEY_ICON_FILENAME, NULL);
-               __widget_tooltips = gtk_tooltips_new();
+    static GtkWidget *window = 0;
+    if (!window)
+    {
+        gtk_window_set_default_icon_from_file(SCIM_ICONDIR SCIM_UNIKEY_ICON_FILENAME, NULL);
+        __widget_tooltips = gtk_tooltips_new();
 
 // Create the toplevel box.
-               window = gtk_hbox_new(false, 0);
+        window = gtk_hbox_new(false, 0);
 
 // create vbox
-               GtkWidget *vbox0 = gtk_vbox_new(false, 0);
-               gtk_box_pack_start(GTK_BOX(window), vbox0, false, false, 0);
+        GtkWidget *vbox0 = gtk_vbox_new(false, 0);
+        gtk_box_pack_start(GTK_BOX(window), vbox0, false, false, 0);
 
 // create Common Frame
-               GtkWidget *fr = gtk_frame_new(_("Unikey option"));
-               gtk_box_pack_start(GTK_BOX(vbox0), fr, false, false, 0);
+        GtkWidget *fr = gtk_frame_new(_("Unikey option"));
+        gtk_box_pack_start(GTK_BOX(vbox0), fr, false, false, 0);
 
-               GtkWidget *vbox = gtk_vbox_new(false, 5);
-               gtk_container_add(GTK_CONTAINER(fr), vbox);
-               gtk_container_set_border_width(GTK_CONTAINER(fr), 5);
+        GtkWidget *vbox = gtk_vbox_new(false, 5);
+        gtk_container_add(GTK_CONTAINER(fr), vbox);
+        gtk_container_set_border_width(GTK_CONTAINER(fr), 5);
 
 // create spellcheck checkbox
-               __widget_spellcheckenabled = gtk_check_button_new_with_label(_("Enable spell check"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_spellcheckenabled, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_spellcheckenabled), 5);
-               g_signal_connect(__widget_spellcheckenabled, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_spellcheckenabled);
+        __widget_spellcheckenabled = gtk_check_button_new_with_label(_("Enable spell check"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_spellcheckenabled, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_spellcheckenabled), 5);
+        g_signal_connect(__widget_spellcheckenabled, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_spellcheckenabled);
 
-               gtk_tooltips_set_tip (__widget_tooltips, __widget_spellcheckenabled,
-                                                         _("If enable, you can decrease mistake when typing"), NULL);
+        gtk_tooltips_set_tip (__widget_tooltips, __widget_spellcheckenabled,
+                              _("If enable, you can decrease mistake when typing"), NULL);
 
 // create autononvnrestore checkbox
-               __widget_autononvnrestore = gtk_check_button_new_with_label(_("Auto restore keys with invalid words"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_autononvnrestore, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_autononvnrestore), 5);
-               g_signal_connect(__widget_autononvnrestore, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_autononvnrestore);
+        __widget_autononvnrestore = gtk_check_button_new_with_label(_("Auto restore keys with invalid words"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_autononvnrestore, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_autononvnrestore), 5);
+        g_signal_connect(__widget_autononvnrestore, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_autononvnrestore);
 
-               gtk_tooltips_set_tip (__widget_tooltips, __widget_autononvnrestore,
-                                                         _("When typing a word not in Vietnamese,\n"
-                                                         "it will auto restore keystroke into orginal"), NULL);
+        gtk_tooltips_set_tip (__widget_tooltips, __widget_autononvnrestore,
+                              _("When typing a word not in Vietnamese,\n"
+                              "it will auto restore keystroke into orginal"), NULL);
 
 // create modernstyle checkbox
-               __widget_modernstyle = gtk_check_button_new_with_label(_("Use oà, uý (instead of òa, úy)"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_modernstyle, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_modernstyle), 5);
-               g_signal_connect(__widget_modernstyle, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_modernstyle);
+        __widget_modernstyle = gtk_check_button_new_with_label(_("Use oà, uý (instead of òa, úy)"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_modernstyle, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_modernstyle), 5);
+        g_signal_connect(__widget_modernstyle, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_modernstyle);
 
 // create freemarking checkbox
-               __widget_freemarking = gtk_check_button_new_with_label(_("Allow type with more freedom"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_freemarking, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_freemarking), 5);
-               g_signal_connect(__widget_freemarking, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_freemarking);
+        __widget_freemarking = gtk_check_button_new_with_label(_("Allow type with more freedom"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_freemarking, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_freemarking), 5);
+        g_signal_connect(__widget_freemarking, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_freemarking);
 
 /*
 // create preedit frame
 */
-               GtkWidget *prefr = gtk_frame_new(_("Typing mode"));
-               gtk_container_set_border_width(GTK_CONTAINER(prefr), 5);
-               gtk_box_pack_start(GTK_BOX(vbox0), prefr, false, false, 0);
+        GtkWidget *prefr = gtk_frame_new(_("Typing mode"));
+        gtk_container_set_border_width(GTK_CONTAINER(prefr), 5);
+        gtk_box_pack_start(GTK_BOX(vbox0), prefr, false, false, 0);
 
-               vbox = gtk_vbox_new(false, 5);
-               gtk_container_add(GTK_CONTAINER(prefr), vbox);
+        vbox = gtk_vbox_new(false, 5);
+        gtk_container_add(GTK_CONTAINER(prefr), vbox);
 
 // create preedit switch key
-               GtkWidget *psbox = gtk_hbox_new(false, 0);
-               gtk_box_pack_start(GTK_BOX(vbox), psbox, false, false, 0);
+        GtkWidget *psbox = gtk_hbox_new(false, 0);
+        gtk_box_pack_start(GTK_BOX(vbox), psbox, false, false, 0);
 
-               GtkWidget *lpskey = gtk_label_new(_("Mode switch key:"));
-               gtk_box_pack_start(GTK_BOX(psbox), lpskey, false, false, 5);
+        GtkWidget *lpskey = gtk_label_new(_("Mode switch key:"));
+        gtk_box_pack_start(GTK_BOX(psbox), lpskey, false, false, 5);
 
-               __widget_preedit_skey = gtk_entry_new();
-               gtk_entry_set_editable(GTK_ENTRY(__widget_preedit_skey), false);
-               gtk_box_pack_start(GTK_BOX(psbox), __widget_preedit_skey, true, false, 0);
+        __widget_preedit_skey = gtk_entry_new();
+        gtk_entry_set_editable(GTK_ENTRY(__widget_preedit_skey), false);
+        gtk_box_pack_start(GTK_BOX(psbox), __widget_preedit_skey, true, false, 0);
 
-               GtkWidget *bpskey = gtk_button_new_with_label("...");
-               gtk_box_pack_start(GTK_BOX(psbox), bpskey, true, true, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(bpskey), 5);
-               g_signal_connect(bpskey, "clicked", G_CALLBACK(on_hotkey_button_clicked), __widget_preedit_skey);
+        GtkWidget *bpskey = gtk_button_new_with_label("...");
+        gtk_box_pack_start(GTK_BOX(psbox), bpskey, true, true, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(bpskey), 5);
+        g_signal_connect(bpskey, "clicked", G_CALLBACK(on_hotkey_button_clicked), __widget_preedit_skey);
 
 
 // create preedit checkbox
-               __widget_preedit = gtk_check_button_new_with_label(_("Preedit is default"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_preedit, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_preedit), 5);
-               g_signal_connect(__widget_preedit, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_preedit);
+        __widget_preedit = gtk_check_button_new_with_label(_("Preedit is default"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_preedit, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_preedit), 5);
+        g_signal_connect(__widget_preedit, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_preedit);
 
-               gtk_tooltips_set_tip (__widget_tooltips, __widget_preedit,
-                                                         _("This option is best for most application\n"
-                                                         "But you may don't like it because it have an underline when typing"), NULL);
+        gtk_tooltips_set_tip (__widget_tooltips, __widget_preedit,
+                              _("This option is best for most application\n"
+                              "But you may don't like it because it have an underline when typing"), NULL);
 
 
 
 //
-               vbox = gtk_vbox_new(false, 0);
-               gtk_box_pack_start(GTK_BOX(window), vbox, true, true, 0);
+        vbox = gtk_vbox_new(false, 0);
+        gtk_box_pack_start(GTK_BOX(window), vbox, true, true, 0);
 
 // right frame 1
-               fr = gtk_frame_new(_("Macro option"));
-               gtk_box_pack_start(GTK_BOX(vbox), fr, false, true, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(fr), 5);
+        fr = gtk_frame_new(_("Macro option"));
+        gtk_box_pack_start(GTK_BOX(vbox), fr, false, true, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(fr), 5);
 
-               // (frame 2)
-               GtkWidget *fr2 = gtk_frame_new(_("Telex option"));
-               gtk_box_pack_start(GTK_BOX(vbox), fr2, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(fr2), 5);
+        // (frame 2)
+        GtkWidget *fr2 = gtk_frame_new(_("Telex option"));
+        gtk_box_pack_start(GTK_BOX(vbox), fr2, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(fr2), 5);
 
-               vbox = gtk_vbox_new(false, 5);
-               gtk_container_add(GTK_CONTAINER(fr), vbox);
+        vbox = gtk_vbox_new(false, 5);
+        gtk_container_add(GTK_CONTAINER(fr), vbox);
 
 // create macroenabled checkbox
-               __widget_macroenabled = gtk_check_button_new_with_label(_("Enable Macro"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_macroenabled, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_macroenabled), 5);
-               g_signal_connect(__widget_macroenabled, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_macroenabled);
+        __widget_macroenabled = gtk_check_button_new_with_label(_("Enable Macro"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_macroenabled, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_macroenabled), 5);
+        g_signal_connect(__widget_macroenabled, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_macroenabled);
 
 // create macroedit button
-               GtkWidget* __widget_macrotable = gtk_button_new_with_label(_("Macro Table"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_macrotable, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_macrotable), 5);
-               g_signal_connect(__widget_macrotable, "clicked", G_CALLBACK(on_macrotable_button_clicked), NULL);
+        GtkWidget* __widget_macrotable = gtk_button_new_with_label(_("Macro Table"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_macrotable, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_macrotable), 5);
+        g_signal_connect(__widget_macrotable, "clicked", G_CALLBACK(on_macrotable_button_clicked), NULL);
 
-               gtk_tooltips_set_tip (__widget_tooltips, __widget_macrotable,
-                                                         _("Edit the macro table for Macro function"), NULL);
+        gtk_tooltips_set_tip (__widget_tooltips, __widget_macrotable,
+                              _("Edit the macro table for Macro function"), NULL);
 
 
 // right frame 2
-               vbox = gtk_vbox_new(false, 5);
-               gtk_container_add(GTK_CONTAINER(fr2), vbox);
+        vbox = gtk_vbox_new(false, 5);
+        gtk_container_add(GTK_CONTAINER(fr2), vbox);
 
 // create process w at word begin checkbox
-               __widget_processwatwordbegin = gtk_check_button_new_with_label(_("Process W at word begin"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_processwatwordbegin, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_processwatwordbegin), 5);
-               g_signal_connect(__widget_processwatwordbegin, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_processwatwordbegin);
+        __widget_processwatwordbegin = gtk_check_button_new_with_label(_("Process W at word begin"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_processwatwordbegin, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_processwatwordbegin), 5);
+        g_signal_connect(__widget_processwatwordbegin, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_processwatwordbegin);
 
-               gtk_tooltips_set_tip (__widget_tooltips, __widget_processwatwordbegin,
-                                                         _("If enable, type W at begin\n"
-                                                         "of word will change to Ư."), NULL);
+        gtk_tooltips_set_tip (__widget_tooltips, __widget_processwatwordbegin,
+                              _("If enable, type W at begin\n"
+                              "of word will change to Ư."), NULL);
 
 // create coder telex checkbox
-               __widget_codertelex = gtk_check_button_new_with_label(_("Not use [,],{,} on Telex"));
-               gtk_box_pack_start(GTK_BOX(vbox), __widget_codertelex, false, false, 0);
-               gtk_container_set_border_width(GTK_CONTAINER(__widget_codertelex), 5);
-               g_signal_connect(__widget_codertelex, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_codertelex);
+        __widget_codertelex = gtk_check_button_new_with_label(_("Not use [,],{,} on Telex"));
+        gtk_box_pack_start(GTK_BOX(vbox), __widget_codertelex, false, false, 0);
+        gtk_container_set_border_width(GTK_CONTAINER(__widget_codertelex), 5);
+        g_signal_connect(__widget_codertelex, "toggled", G_CALLBACK(on_default_toggle_button_toggled), &__unikey_codertelex);
 
-               gtk_tooltips_set_tip (__widget_tooltips, __widget_codertelex,
-                                                         _("Not use [,],{,} for map on Telex"), NULL);
+        gtk_tooltips_set_tip (__widget_tooltips, __widget_codertelex,
+                              _("Not use [,],{,} for map on Telex"), NULL);
 
 
-               setup_widget_value();
-               gtk_widget_show_all(window);
-       }
-       return window;
+        setup_widget_value();
+        gtk_widget_show_all(window);
+    }
+    return window;
 }
 
 static void setup_widget_value()
 {
-       if (__widget_preedit)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_preedit), __unikey_preedit);
+    if (__widget_preedit)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_preedit), __unikey_preedit);
 
-       if (__widget_spellcheckenabled)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_spellcheckenabled), __unikey_spellcheckenabled);
+    if (__widget_spellcheckenabled)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_spellcheckenabled), __unikey_spellcheckenabled);
 
-       if (__widget_autononvnrestore)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_autononvnrestore), __unikey_autononvnrestore);
+    if (__widget_autononvnrestore)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_autononvnrestore), __unikey_autononvnrestore);
 
-       if (__widget_modernstyle)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_modernstyle), __unikey_modernstyle);
+    if (__widget_modernstyle)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_modernstyle), __unikey_modernstyle);
 
-       if (__widget_freemarking)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_freemarking), __unikey_freemarking);
+    if (__widget_freemarking)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_freemarking), __unikey_freemarking);
 
-       if (__widget_macroenabled)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_macroenabled), __unikey_macroenabled);
+    if (__widget_macroenabled)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_macroenabled), __unikey_macroenabled);
 
-       if (__widget_codertelex)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_codertelex), __unikey_codertelex);
+    if (__widget_codertelex)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_codertelex), __unikey_codertelex);
 
-       if (__widget_processwatwordbegin)
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_processwatwordbegin), __unikey_processwatwordbegin);
+    if (__widget_processwatwordbegin)
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(__widget_processwatwordbegin), __unikey_processwatwordbegin);
 }
 
 static void load_config(const ConfigPointer &config)
 {
-       if (!config.null())
-       {
-               bool t;
-               t = config->read(SCIM_IMENGINE_UNIKEY_PREEDIT, &__unikey_preedit);
-               if (!t) __unikey_preedit = SCIM_IMENGINE_UNIKEY_PREEDIT_DEF;
+    if (!config.null())
+    {
+        bool t;
+        t = config->read(SCIM_IMENGINE_UNIKEY_PREEDIT, &__unikey_preedit);
+        if (!t) __unikey_preedit = SCIM_IMENGINE_UNIKEY_PREEDIT_DEF;
 
-               String s;               
-               t = config->read(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, &s);
-               gtk_entry_set_text(GTK_ENTRY(__widget_preedit_skey), t?s.c_str():SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY_DEF);
+        String s;        
+        t = config->read(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, &s);
+        gtk_entry_set_text(GTK_ENTRY(__widget_preedit_skey), t?s.c_str():SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY_DEF);
 
-               t = config->read(SCIM_IMENGINE_UNIKEY_FREEMARKING, &__unikey_freemarking);
-               if (!t) __unikey_freemarking = SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
+        t = config->read(SCIM_IMENGINE_UNIKEY_FREEMARKING, &__unikey_freemarking);
+        if (!t) __unikey_freemarking = SCIM_IMENGINE_UNIKEY_FREEMARKING_DEF;
 
-               t = config->read(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, &__unikey_modernstyle);
-               if (!t) __unikey_modernstyle = SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
+        t = config->read(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, &__unikey_modernstyle);
+        if (!t) __unikey_modernstyle = SCIM_IMENGINE_UNIKEY_MODERNSTYLE_DEF;
 
-               t = config->read(SCIM_IMENGINE_UNIKEY_MACROENABLED, &__unikey_macroenabled);
-               if (!t) __unikey_macroenabled = SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
+        t = config->read(SCIM_IMENGINE_UNIKEY_MACROENABLED, &__unikey_macroenabled);
+        if (!t) __unikey_macroenabled = SCIM_IMENGINE_UNIKEY_MACROENABLED_DEF;
 
-               t = config->read(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, &__unikey_spellcheckenabled);
-               if (!t) __unikey_spellcheckenabled = SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
+        t = config->read(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, &__unikey_spellcheckenabled);
+        if (!t) __unikey_spellcheckenabled = SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED_DEF;
 
-               t = config->read(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, &__unikey_autononvnrestore);
-               if (!t) __unikey_autononvnrestore = SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
+        t = config->read(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, &__unikey_autononvnrestore);
+        if (!t) __unikey_autononvnrestore = SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE_DEF;
 
-               t = config->read(SCIM_IMENGINE_UNIKEY_CODERTELEX, &__unikey_codertelex);
-               if (!t) __unikey_codertelex = SCIM_IMENGINE_UNIKEY_CODERTELEX_DEF;
+        t = config->read(SCIM_IMENGINE_UNIKEY_CODERTELEX, &__unikey_codertelex);
+        if (!t) __unikey_codertelex = SCIM_IMENGINE_UNIKEY_CODERTELEX_DEF;
 
-               t = config->read(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, &__unikey_processwatwordbegin);
-               if (!t) __unikey_processwatwordbegin = SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
+        t = config->read(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, &__unikey_processwatwordbegin);
+        if (!t) __unikey_processwatwordbegin = SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN_DEF;
 
-               __macStore.init();
-               __macStore.loadFromFile(getMacroFile());
+        __macStore.init();
+        __macStore.loadFromFile(getMacroFile());
 
-               setup_widget_value();
-               __have_changed = false;
-       }
+        setup_widget_value();
+        __have_changed = false;
+    }
 }
 
 static void save_config(const ConfigPointer &config)
 {
-       if (!config.null())
-       {
-               config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, __unikey_preedit);
-               String s = String(gtk_entry_get_text(GTK_ENTRY(__widget_preedit_skey)));
-               config->write(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, s);
-               config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, __unikey_freemarking);
-               config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, __unikey_modernstyle);
-               config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, __unikey_macroenabled);
-               config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, __unikey_spellcheckenabled);
-               config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, __unikey_autononvnrestore);
-               config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, __unikey_autononvnrestore);
-               config->write(SCIM_IMENGINE_UNIKEY_CODERTELEX, __unikey_codertelex);
-               config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, __unikey_processwatwordbegin);
-
-               s = String(getMacroFile());
-               FILE *f = fopen(s.c_str(), "wt");
-               if (f == NULL)
-               {
-                       s = s.substr(0, s.rfind('/'));
-                       int tmp=system((String("mkdir ") + s).c_str());
-               }
-               else
-                       fclose(f);
-
-               __macStore.writeToFile(getMacroFile());
-
-               __have_changed = false;
-       }
+    if (!config.null())
+    {
+        config->write(SCIM_IMENGINE_UNIKEY_PREEDIT, __unikey_preedit);
+        String s = String(gtk_entry_get_text(GTK_ENTRY(__widget_preedit_skey)));
+        config->write(SCIM_IMENGINE_UNIKEY_PREEDIT_SWITCH_KEY, s);
+        config->write(SCIM_IMENGINE_UNIKEY_FREEMARKING, __unikey_freemarking);
+        config->write(SCIM_IMENGINE_UNIKEY_MODERNSTYLE, __unikey_modernstyle);
+        config->write(SCIM_IMENGINE_UNIKEY_MACROENABLED, __unikey_macroenabled);
+        config->write(SCIM_IMENGINE_UNIKEY_SPELLCHECKENABLED, __unikey_spellcheckenabled);
+        config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, __unikey_autononvnrestore);
+        config->write(SCIM_IMENGINE_UNIKEY_AUTONONVNRESTORE, __unikey_autononvnrestore);
+        config->write(SCIM_IMENGINE_UNIKEY_CODERTELEX, __unikey_codertelex);
+        config->write(SCIM_IMENGINE_UNIKEY_PROCESSWATWORDBEGIN, __unikey_processwatwordbegin);
+
+        s = String(getMacroFile());
+        FILE *f = fopen(s.c_str(), "wt");
+        if (f == NULL)
+        {
+            s = s.substr(0, s.rfind('/'));
+            int tmp=system((String("mkdir ") + s).c_str());
+        }
+        else
+            fclose(f);
+
+        __macStore.writeToFile(getMacroFile());
+
+        __have_changed = false;
+    }
 }
 
 static bool query_changed()
 {
-       return __have_changed;
+    return __have_changed;
 }
 
 static void on_default_toggle_button_toggled(GtkToggleButton *togglebutton, gpointer user_data)
 {
-       bool *toggle = static_cast<bool*> (user_data);
+    bool *toggle = static_cast<bool*> (user_data);
 
-       if (toggle)
-       {
-               *toggle = gtk_toggle_button_get_active (togglebutton);
-               __have_changed = true;
-       }
+    if (toggle)
+    {
+        *toggle = gtk_toggle_button_get_active (togglebutton);
+        __have_changed = true;
+    }
 }
 
 enum {COL_KEY = 0, COL_REPLACE, NUM_COLS};
 
 static void on_macrotable_button_clicked(GtkButton *button, gpointer user_data)
 {
-       GtkWidget           *dialog;
-       GtkWidget           *treeview;
-       GtkTreeModel        *model;
-       GtkTreeViewColumn   *col;
-       GtkWidget           *contentarea;
-       GtkWidget           *hbox, *vbox;
-       GtkCellRenderer     *renderer;
+    GtkWidget           *dialog;
+    GtkWidget           *treeview;
+    GtkTreeModel        *model;
+    GtkTreeViewColumn   *col;
+    GtkWidget           *contentarea;
+    GtkWidget           *hbox, *vbox;
+    GtkCellRenderer     *renderer;
 
 // create main dialog
-       dialog = gtk_dialog_new();
-       gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 300);
-       gtk_window_set_title(GTK_WINDOW(dialog), _("Macro table definition"));
-       gtk_dialog_add_buttons(GTK_DIALOG(dialog),
-                                                  GTK_STOCK_OK, GTK_RESPONSE_OK,
-                                                  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                                  NULL);
+    dialog = gtk_dialog_new();
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 300);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Macro table definition"));
+    gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+                           GTK_STOCK_OK, GTK_RESPONSE_OK,
+                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                           NULL);
 
-       //contentarea = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); // only for GTK >= 2.14
-       contentarea = GTK_DIALOG(dialog)->vbox;
+    //contentarea = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); // only for GTK >= 2.14
+    contentarea = GTK_DIALOG(dialog)->vbox;
 
-       hbox = gtk_hbox_new (false, 5);
-       gtk_container_add(GTK_CONTAINER(contentarea), hbox);
+    hbox = gtk_hbox_new (false, 5);
+    gtk_container_add(GTK_CONTAINER(contentarea), hbox);
 
 // create scroll window and tree view
-       model = GTK_TREE_MODEL(create_and_fill_list_store());
+    model = GTK_TREE_MODEL(create_and_fill_list_store());
 
-       treeview = gtk_tree_view_new_with_model (model);
+    treeview = gtk_tree_view_new_with_model (model);
 
-       GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
-       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+    GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
-       gtk_box_pack_start(GTK_BOX(hbox), scroll, true, true, 0);
-       gtk_container_add(GTK_CONTAINER(scroll), treeview);
+    gtk_box_pack_start(GTK_BOX(hbox), scroll, true, true, 0);
+    gtk_container_add(GTK_CONTAINER(scroll), treeview);
 
 // create key column
-       renderer = gtk_cell_renderer_text_new();
-       g_object_set(renderer, "editable", true, NULL);
-       g_object_set(renderer, "width-chars", MAX_MACRO_KEY_LEN+4, NULL);
-       g_signal_connect(renderer, "edited", G_CALLBACK(on_key_edited), model);
-       col = gtk_tree_view_column_new_with_attributes(_("Word"), renderer, "text", COL_KEY, NULL);
-       gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), col);
+    renderer = gtk_cell_renderer_text_new();
+    g_object_set(renderer, "editable", true, NULL);
+    g_object_set(renderer, "width-chars", MAX_MACRO_KEY_LEN+4, NULL);
+    g_signal_connect(renderer, "edited", G_CALLBACK(on_key_edited), model);
+    col = gtk_tree_view_column_new_with_attributes(_("Word"), renderer, "text", COL_KEY, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), col);
 
 // create replace column
-       renderer = gtk_cell_renderer_text_new();
-       g_object_set(renderer, "editable", true, NULL);
-       //g_object_set(renderer, "width-chars", MAX_MACRO_KEY_LEN*3, NULL);
-       g_signal_connect(renderer, "edited", G_CALLBACK(on_replace_edited), model);
-       col = gtk_tree_view_column_new_with_attributes(_("Replace with"), renderer, "text", COL_REPLACE, NULL);
-       gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), col);
+    renderer = gtk_cell_renderer_text_new();
+    g_object_set(renderer, "editable", true, NULL);
+    //g_object_set(renderer, "width-chars", MAX_MACRO_KEY_LEN*3, NULL);
+    g_signal_connect(renderer, "edited", G_CALLBACK(on_replace_edited), model);
+    col = gtk_tree_view_column_new_with_attributes(_("Replace with"), renderer, "text", COL_REPLACE, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), col);
 
-       vbox = gtk_vbox_new (false, 0);
-       gtk_box_pack_end(GTK_BOX(hbox), vbox, false, false, 6);
+    vbox = gtk_vbox_new (false, 0);
+    gtk_box_pack_end(GTK_BOX(hbox), vbox, false, false, 6);
 
 // create Del button
-       GtkWidget* btDel = gtk_button_new_with_label (_("Delete"));
-       gtk_box_pack_start(GTK_BOX(vbox), btDel, false, true, 3);
-       g_signal_connect(btDel, "clicked", G_CALLBACK(on_del_macro_clicked), treeview);
+    GtkWidget* btDel = gtk_button_new_with_label (_("Delete"));
+    gtk_box_pack_start(GTK_BOX(vbox), btDel, false, true, 3);
+    g_signal_connect(btDel, "clicked", G_CALLBACK(on_del_macro_clicked), treeview);
 
 // create DelAll button
-       GtkWidget *btDelAll = gtk_button_new_with_label (_("Delete All"));
-       gtk_box_pack_start(GTK_BOX(vbox), btDelAll, false, true, 3);
-       g_signal_connect(btDelAll, "clicked", G_CALLBACK(on_delall_macro_clicked), model);
+    GtkWidget *btDelAll = gtk_button_new_with_label (_("Delete All"));
+    gtk_box_pack_start(GTK_BOX(vbox), btDelAll, false, true, 3);
+    g_signal_connect(btDelAll, "clicked", G_CALLBACK(on_delall_macro_clicked), model);
 
-       gtk_widget_show_all(dialog);
-       gint result = gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_show_all(dialog);
+    gint result = gtk_dialog_run(GTK_DIALOG(dialog));
 
 // save Macro Table
-       if (result == GTK_RESPONSE_OK)
-       {
-               __macStore.init();
-               gtk_tree_model_foreach(model, iter_2_macro, NULL);
+    if (result == GTK_RESPONSE_OK)
+    {
+        __macStore.init();
+        gtk_tree_model_foreach(model, iter_2_macro, NULL);
 
-               __have_changed = true;
-       }
+        __have_changed = true;
+    }
 
-       g_object_unref(model);
-       gtk_widget_destroy(dialog);
+    g_object_unref(model);
+    gtk_widget_destroy(dialog);
 }
 
 static void on_end_macro_table(GtkListStore *liststore)
 {
-       GtkTreeIter     iter;
-       gchar           *lastkey;
-       gint n;
-
-       n = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(liststore), NULL);
-       if (n)
-       {
-               gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(liststore), &iter, NULL, n-1);
-       }
-       else
-       {
-               gtk_list_store_append(liststore, &iter);
-               gtk_list_store_set(liststore, &iter, COL_KEY, "...", COL_REPLACE, "...", -1);
-               return;
-       }
-
-       gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, COL_KEY, &lastkey, -1);
-       if (strcmp(lastkey, "...") || n==0)
-       {
-               gtk_list_store_append(liststore, &iter);
-               gtk_list_store_set(liststore, &iter, COL_KEY, "...", COL_REPLACE, "...", -1);
-       }
+    GtkTreeIter     iter;
+    gchar           *lastkey;
+    gint n;
+
+    n = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(liststore), NULL);
+    if (n)
+    {
+        gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(liststore), &iter, NULL, n-1);
+    }
+    else
+    {
+        gtk_list_store_append(liststore, &iter);
+        gtk_list_store_set(liststore, &iter, COL_KEY, "...", COL_REPLACE, "...", -1);
+        return;
+    }
+
+    gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, COL_KEY, &lastkey, -1);
+    if (strcmp(lastkey, "...") || n==0)
+    {
+        gtk_list_store_append(liststore, &iter);
+        gtk_list_store_set(liststore, &iter, COL_KEY, "...", COL_REPLACE, "...", -1);
+    }
 }
 
 static void on_del_macro_clicked(GtkButton *button, gpointer user_data)
 {
-       GtkTreeView     *treeview;
-       GtkListStore    *liststore;
-       GtkTreeSelection*tselect;
-       GtkTreeIter     iter;
-       gchar           *lastkey;
-
-       treeview = GTK_TREE_VIEW(user_data);
-       tselect = gtk_tree_view_get_selection(treeview);
-
-       if (gtk_tree_selection_get_selected(tselect, NULL, &iter))
-       {
-               liststore = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
-               gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, COL_KEY, &lastkey, -1);
-               if (strcmp(lastkey, "..."))
-                       gtk_list_store_remove(liststore, &iter);
-       }
+    GtkTreeView     *treeview;
+    GtkListStore    *liststore;
+    GtkTreeSelection*tselect;
+    GtkTreeIter     iter;
+    gchar           *lastkey;
+
+    treeview = GTK_TREE_VIEW(user_data);
+    tselect = gtk_tree_view_get_selection(treeview);
+
+    if (gtk_tree_selection_get_selected(tselect, NULL, &iter))
+    {
+        liststore = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
+        gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, COL_KEY, &lastkey, -1);
+        if (strcmp(lastkey, "..."))
+            gtk_list_store_remove(liststore, &iter);
+    }
 }
 
 static void on_delall_macro_clicked(GtkButton *button, gpointer user_data)
 {
-       GtkListStore    *liststore;
-       GtkTreeIter     iter;
+    GtkListStore    *liststore;
+    GtkTreeIter     iter;
 
-       liststore = GTK_LIST_STORE(user_data);
+    liststore = GTK_LIST_STORE(user_data);
 
-       gtk_list_store_clear(liststore);
-       on_end_macro_table(liststore);
+    gtk_list_store_clear(liststore);
+    on_end_macro_table(liststore);
 }
 
 static GtkListStore* create_and_fill_list_store()
 {
-       GtkListStore*   liststore;
-       GtkTreeIter     iter;
-       FILE            *f;
-       char            key[MAX_MACRO_KEY_LEN*3], replace[MAX_MACRO_TEXT_LEN*3];
-       UKBYTE          *p;
-       int             i, inLen, maxOutLen, ret;
+    GtkListStore*   liststore;
+    GtkTreeIter     iter;
+    FILE            *f;
+    char            key[MAX_MACRO_KEY_LEN*3], replace[MAX_MACRO_TEXT_LEN*3];
+    UKBYTE          *p;
+    int             i, inLen, maxOutLen, ret;
 
-       liststore = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
+    liststore = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
 
 // add key and replace to liststore
-       for (int i=0 ; i < __macStore.getCount() ; i++)
-       {
-               p = (UKBYTE *)__macStore.getKey(i);
-               inLen = -1;
-               maxOutLen = sizeof(key);
-               ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_UNIUTF8,
-                                               (UKBYTE *) p, (UKBYTE *)key,
-                                               &inLen, &maxOutLen);
-               if (ret != 0)
-                       continue;
-
-               p = (UKBYTE *)__macStore.getText(i);
-               inLen = -1;
-               maxOutLen = sizeof(replace);
-               ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_UNIUTF8,
-                                               p, (UKBYTE *)replace,
-                                               &inLen, &maxOutLen);
-               if (ret != 0)
-                       continue;
-
-               gtk_list_store_append(liststore, &iter);
-               gtk_list_store_set(liststore, &iter, COL_KEY, key, COL_REPLACE, replace, -1);
-       }
-
-       on_end_macro_table(liststore);
-       return liststore;
+    for (int i=0 ; i < __macStore.getCount() ; i++)
+    {
+        p = (UKBYTE *)__macStore.getKey(i);
+        inLen = -1;
+        maxOutLen = sizeof(key);
+        ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_UNIUTF8,
+                        (UKBYTE *) p, (UKBYTE *)key,
+                        &inLen, &maxOutLen);
+        if (ret != 0)
+            continue;
+
+        p = (UKBYTE *)__macStore.getText(i);
+        inLen = -1;
+        maxOutLen = sizeof(replace);
+        ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_UNIUTF8,
+                        p, (UKBYTE *)replace,
+                        &inLen, &maxOutLen);
+        if (ret != 0)
+            continue;
+
+        gtk_list_store_append(liststore, &iter);
+        gtk_list_store_set(liststore, &iter, COL_KEY, key, COL_REPLACE, replace, -1);
+    }
+
+    on_end_macro_table(liststore);
+    return liststore;
 }
 
 static void on_key_edited (GtkCellRendererText *celltext, const gchar *string_path, const gchar *new_text, gpointer data)
 {
-       GtkTreeModel    *model;
-       GtkTreeIter     iter;
-       gchar           *curkey, *oldkey, *oldreplace;
-       bool            b;
+    GtkTreeModel    *model;
+    GtkTreeIter     iter;
+    gchar           *curkey, *oldkey, *oldreplace;
+    bool            b;
 
-       model = GTK_TREE_MODEL (data);
+    model = GTK_TREE_MODEL (data);
 
-       if (!strcmp(new_text, "..."))
-               return;
+    if (!strcmp(new_text, "..."))
+        return;
 
-       b = gtk_tree_model_get_iter_first(model, &iter);
-       while (b)
-       {
-               gtk_tree_model_get(model, &iter, COL_KEY, &curkey, -1);
-               if (!strcmp(curkey, new_text))
-                       return;
+    b = gtk_tree_model_get_iter_first(model, &iter);
+    while (b)
+    {
+        gtk_tree_model_get(model, &iter, COL_KEY, &curkey, -1);
+        if (!strcmp(curkey, new_text))
+            return;
 
-               b = gtk_tree_model_iter_next(model, &iter);
-       }
-       gtk_tree_model_get_iter_from_string(model, &iter, string_path);
-       gtk_tree_model_get(model, &iter, COL_KEY, &oldkey, COL_REPLACE, &oldreplace, -1);
+        b = gtk_tree_model_iter_next(model, &iter);
+    }
+    gtk_tree_model_get_iter_from_string(model, &iter, string_path);
+    gtk_tree_model_get(model, &iter, COL_KEY, &oldkey, COL_REPLACE, &oldreplace, -1);
 
-       gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_KEY, new_text, -1);
-       if (!strcmp(oldkey, "..."))
-               gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_REPLACE, _("(replace text)"));
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_KEY, new_text, -1);
+    if (!strcmp(oldkey, "..."))
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_REPLACE, _("(replace text)"));
 
-       on_end_macro_table(GTK_LIST_STORE(model));
+    on_end_macro_table(GTK_LIST_STORE(model));
 }
 
 static void on_replace_edited (GtkCellRendererText *celltext, const gchar *string_path, const gchar *new_text, gpointer data)
 {
-       GtkTreeModel    *model;
-       GtkTreeIter     iter;
-       gchar           *oldkey;
+    GtkTreeModel    *model;
+    GtkTreeIter     iter;
+    gchar           *oldkey;
 
-       model = GTK_TREE_MODEL (data);
-       gtk_tree_model_get_iter_from_string(model, &iter, string_path);
+    model = GTK_TREE_MODEL (data);
+    gtk_tree_model_get_iter_from_string(model, &iter, string_path);
 
-       gtk_tree_model_get(model, &iter, COL_KEY, &oldkey, -1);
-       if (strcmp(oldkey, "..."))
-               gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_REPLACE, new_text, -1);
+    gtk_tree_model_get(model, &iter, COL_KEY, &oldkey, -1);
+    if (strcmp(oldkey, "..."))
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_REPLACE, new_text, -1);
 }
 
 static gboolean iter_2_macro(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
 {
-       gchar   *key, *replace;
-       GtkTreeIter c;
+    gchar   *key, *replace;
+    GtkTreeIter c;
 
-       c = *iter;
+    c = *iter;
 
-       if (!gtk_tree_model_iter_next(model, &c))
-               return true;
-       gtk_tree_model_get(model, iter, COL_KEY, &key, COL_REPLACE, &replace, -1);
+    if (!gtk_tree_model_iter_next(model, &c))
+        return true;
+    gtk_tree_model_get(model, iter, COL_KEY, &key, COL_REPLACE, &replace, -1);
 
-       __macStore.addItem(key, replace, CONV_CHARSET_XUTF8);
+    __macStore.addItem(key, replace, CONV_CHARSET_XUTF8);
 
-       return false;
+    return false;
 }
 
 static void on_hotkey_button_clicked (GtkButton *button, gpointer data)
 {
-       GtkWidget *wid = (GtkWidget*)data;
-
-       GtkWidget *dialog = scim_key_selection_dialog_new("Edit hotkey");
-       gint r;
-       const gchar *hotkeys = gtk_entry_get_text(GTK_ENTRY(wid));
-       
-       if (hotkeys)
-       {
-               scim_key_selection_dialog_set_keys(
-                       SCIM_KEY_SELECTION_DIALOG(dialog), hotkeys);
-       }
-
-       r = gtk_dialog_run(GTK_DIALOG(dialog));
-
-       if (r == GTK_RESPONSE_OK)
-       {
-               const gchar *newkeys = scim_key_selection_dialog_get_keys(SCIM_KEY_SELECTION_DIALOG(dialog));
-               gtk_entry_set_text(GTK_ENTRY(wid), newkeys?newkeys:"");
-               __have_changed = true;
-       }
-
-       gtk_widget_destroy(dialog);
+    GtkWidget *wid = (GtkWidget*)data;
+
+    GtkWidget *dialog = scim_key_selection_dialog_new("Edit hotkey");
+    gint r;
+    const gchar *hotkeys = gtk_entry_get_text(GTK_ENTRY(wid));
+    
+    if (hotkeys)
+    {
+        scim_key_selection_dialog_set_keys(
+            SCIM_KEY_SELECTION_DIALOG(dialog), hotkeys);
+    }
+
+    r = gtk_dialog_run(GTK_DIALOG(dialog));
+
+    if (r == GTK_RESPONSE_OK)
+    {
+        const gchar *newkeys = scim_key_selection_dialog_get_keys(SCIM_KEY_SELECTION_DIALOG(dialog));
+        gtk_entry_set_text(GTK_ENTRY(wid), newkeys?newkeys:"");
+        __have_changed = true;
+    }
+
+    gtk_widget_destroy(dialog);
 }
index 9625e7ab42fa01e7f20bb289889cdc1629066f34..dc16f48249758073e48c1e084be9cdf99580e459 100644 (file)
@@ -1,5 +1,5 @@
 --- orginal/inputproc.cpp      2009-04-14 00:16:33.000000000 +0700
-+++ inputproc.cpp      2009-06-18 14:39:10.000000000 +0700
++++ inputproc.cpp      2009-06-18 15:04:22.000000000 +0700
 @@ -20,7 +20,7 @@
   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   * Boston, MA 02111-1307, USA.