diff --git a/honoka/plugins/romkan.cpp b/honoka/plugins/romkan.cpp index a95304e..f925dfb 100644 --- a/honoka/plugins/romkan.cpp +++ b/honoka/plugins/romkan.cpp @@ -49,6 +49,12 @@ _("input the path of Roma-Kana convert table file."), HONOKA_DEFAULT_ROMKAN_TABLE_FILE )); + page->append(new HonokaSetupKeyItem( + _("Ascii to Kana convert key: "), + HONOKA_CONFIG_ROMKAN_A2K_KEY, + _("The key events to convert the ascii string to kana."), + HONOKA_DEFAULT_ROMKAN_A2K_KEY + )); HonokaSetupPage *sc = new HonokaSetupPage(_("shortcut keys: "),"",""); sc->append(new HonokaSetupKeyItem( _("Romkan input: "), @@ -213,7 +219,7 @@ //String rk_table = config->read(HONOKA_CONFIG_ROMKAN_TABLE_FILE,String(HONOKA_DEFAULT_ROMKAN_TABLE_FILE)); String rk_table = config->read(String(HONOKA_CONFIG_ROMKAN_TABLE_FILE) + postfix,String(HONOKA_DEFAULT_ROMKAN_TABLE_FILE)); - + scim_string_to_key_list(key_a2k,config->read(HONOKA_CONFIG_ROMKAN_A2K_KEY,String(HONOKA_DEFAULT_ROMKAN_A2K_KEY))); if (rk_table.size()) { loadTable(rk_table); } @@ -650,6 +656,10 @@ (key.code == SCIM_KEY_Super_R) || (key.code == SCIM_KEY_Hyper_L) || (key.code == SCIM_KEY_Hyper_R)) return true; + if (key_a2k.comp(key)) { + asciiToKana(); + return true; + } if (key_ascii_mode.comp(key)) { mode = ASCII; return true; @@ -704,3 +714,36 @@ } return l; } + + +/*! + \fn Honoka::Romkan::asciiToKana() + */ +void Honoka::Romkan::asciiToKana() +{ + inputMode m = mode; + WideString t = text; + reset(); + mode = ROMA; + WideString b; + for(unsigned int i = 0;i < t.length();i ++) { + if (((t[i] >= 0x0041) && (t[i] <= 0x005A)) || ((t[i] >= 0x0061) && (t[i] <= 0x007A))) { + b += t[i]; + } else { + if (b.length()) { + String s = utf8_wcstombs(b).c_str(); + for(unsigned int j = 0;j < s.length();j ++) insert(s[j]); + b.clear(); + } + text += t[i]; + setPos(getPos() + 1); + } + } + if (b.length()) { + String s = utf8_wcstombs(b).c_str(); + for(unsigned int j = 0;j < s.length();j ++) insert(s[j]); + } + mode = m; + return; + +} diff --git a/honoka/plugins/romkan.h b/honoka/plugins/romkan.h index 056081e..28b773f 100644 --- a/honoka/plugins/romkan.h +++ b/honoka/plugins/romkan.h @@ -35,6 +35,8 @@ #define HONOKA_CONFIG_ROMKAN_TABLE_FILE "/IMEngine/Honoka/Romkan/TableFile" #define HONOKA_DEFAULT_ROMKAN_TABLE_FILE "honoka-def.rkt" +#define HONOKA_CONFIG_ROMKAN_A2K_KEY "/IMEngine/Honoka/Romkan/AsciiToKana" +#define HONOKA_DEFAULT_ROMKAN_A2K_KEY "Hiragana_Katakana" using namespace std; @@ -101,6 +103,7 @@ void init(); void loadTable(const String &filename, bool inc = false); bool string2bool(const String &s); + void asciiToKana(); protected: String buf; @@ -113,7 +116,7 @@ bool xtProc; bool asciiCancel; bool removeRemainder; - HonokaKeyEventList key_ascii_mode,key_wascii_mode,key_toggle_hw,key_toggle_hk; + HonokaKeyEventList key_ascii_mode,key_wascii_mode,key_toggle_hw,key_toggle_hk,key_a2k; map RomkanTable; set keepTable; map tableConfig;