diff --git a/scim-wnn/data/like-msime.rkt b/scim-wnn/data/like-msime.rkt index c28e26f..6fd5674 100644 --- a/scim-wnn/data/like-msime.rkt +++ b/scim-wnn/data/like-msime.rkt @@ -1,5 +1,5 @@ # utf8 -!nnMode true +$nnMode true $Key/Ascii null $Key/WideAscii null a あ diff --git a/scim-wnn/data/scim-wnn-def.rkt b/scim-wnn/data/scim-wnn-def.rkt index 294c489..63c8177 100644 --- a/scim-wnn/data/scim-wnn-def.rkt +++ b/scim-wnn/data/scim-wnn-def.rkt @@ -1,5 +1,5 @@ # utf8 -!nnMode false +$nnMode false $Key/Ascii q $Key/WideAscii Shift+Q a あ diff --git a/scim-wnn/src/romkan.cpp b/scim-wnn/src/romkan.cpp index 35258d5..a5c3df6 100644 --- a/scim-wnn/src/romkan.cpp +++ b/scim-wnn/src/romkan.cpp @@ -38,6 +38,7 @@ #define bind_textdomain_codeset(domain,codeset) #endif + Romkan::Romkan(ConfigPointer cfg) : PreEditor(cfg) { reset(); @@ -98,13 +99,7 @@ continue; } if ((k[0] == '$') && (!inc)) { - setConfigFromTable(k.substr(1),r); - continue; - } - if ((k[0] == '!') && (!inc)) { - bool v = true; - if ((r == "false") || (r == "FALSE") || (r == "0")) v = false; - setConfigFromTable(k.substr(1),v); + tableConfig.insert(pair(k.substr(1),r)); continue; } if (!r.size()) continue; @@ -122,35 +117,24 @@ } - /*! - \fn Romkan::setConfigFromTable(const String &name, const String &value) + \fn Romkan::string2bool(const String &s) */ -void Romkan::setConfigFromTable(const String &name, const String &value) +bool Romkan::string2bool(const String &s) { - if (name.substr(0,4) == String("Key/")) { - config->write(String(SCIM_CONFIG_WNN_ROMKAN_PREFIX) + name,value); - } + if ((s == "FALSE") || (s == "false") || (s == "False") || (s == "0") || (!s.size())) return(false); + else return(true); } /*! - \fn Romkan::setConfigFromTable(const String &name, bool value) - */ -void Romkan::setConfigFromTable(const String &name, bool value) -{ - config->write(String(SCIM_CONFIG_WNN_ROMKAN_PREFIX) + name,value); -} - - - -/*! \fn Romkan::init() */ void Romkan::init() { RomkanTable.clear(); keepTable.clear(); + tableConfig.clear(); String rk_table = config->read(SCIM_CONFIG_WNN_ROMKAN_TABLE_FILE,String(SCIM_DEFAULT_WNN_ROMKAN_TABLE_FILE)); @@ -174,14 +158,12 @@ } } - nnMode = config->read(SCIM_CONFIG_WNN_ROMKAN_NNMODE,SCIM_DEFAULT_WNN_ROMKAN_NNMODE); - scim_string_to_key_list(key_ascii_mode, - config->read(String(SCIM_CONFIG_WNN_KEY_ROMKAN_ASCIIMODE), - String(SCIM_DEFAULT_WNN_KEY_ROMKAN_ASCIIMODE))); - scim_string_to_key_list(key_wascii_mode, - config->read(String(SCIM_CONFIG_WNN_KEY_ROMKAN_WASCIIMODE), - String(SCIM_DEFAULT_WNN_KEY_ROMKAN_WASCIIMODE))); - + if (tableConfig.find("nnMode") != tableConfig.end()) + nnMode = string2bool(tableConfig["nnMode"]); + if (tableConfig.find("Key/Ascii") != tableConfig.end()) + scim_string_to_key_list(key_ascii_mode,tableConfig["Key/Ascii"]); + if (tableConfig.find("Key/WideAscii") != tableConfig.end()) + scim_string_to_key_list(key_wascii_mode,tableConfig["Key/WideAscii"]); } @@ -507,4 +489,3 @@ } - diff --git a/scim-wnn/src/romkan.h b/scim-wnn/src/romkan.h index a393c07..d04b795 100644 --- a/scim-wnn/src/romkan.h +++ b/scim-wnn/src/romkan.h @@ -69,8 +69,7 @@ WideString insert(char k); void init(); void loadTable(const String &filename, bool inc = false); - void setConfigFromTable(const String &name, const String &value); - void setConfigFromTable(const String &name, bool value); + bool string2bool(const String &s); protected: String buf; @@ -81,6 +80,7 @@ PreEditorKeyEventList key_ascii_mode,key_wascii_mode; map RomkanTable; set keepTable; + map tableConfig; }; #endif