diff --git a/honoka/plugins/asciiinput.cpp b/honoka/plugins/asciiinput.cpp index 7928ab0..31b4a5c 100644 --- a/honoka/plugins/asciiinput.cpp +++ b/honoka/plugins/asciiinput.cpp @@ -41,6 +41,8 @@ AsciiInput::AsciiInput(ConfigPointer cfg) : PreEditor(cfg) { scim_string_to_key_list(lowProprotyKey,cfg->read(HONOKA_CONFIG_ASCIIINPUT_LOW_PRIORITY_KEY,String(HONOKA_DEFAULT_ASCIIINPUT_LOW_PRIORITY_KEY))); + scim_string_to_key_list(autoCommitKey,cfg->read(HONOKA_CONFIG_ASCIIINPUT_AUTO_COMMIT_KEY,String(HONOKA_DEFAULT_ASCIIINPUT_AUTO_COMMIT_KEY))); + autoCommit = cfg->read(HONOKA_CONFIG_ASCIIINPUT_AUTO_COMMIT,HONOKA_DEFAULT_ASCIIINPUT_AUTO_COMMIT); } @@ -113,6 +115,17 @@ (key.code == SCIM_KEY_Hyper_L) || (key.code == SCIM_KEY_Hyper_R)) return true; + if (autoCommit) { + if (autoCommitKey.comp(key)) { + String c; + if (isprint(key.get_ascii_code())) c += key.get_ascii_code(); + setCommitString(text.substr(0,pos) + utf8_mbstowcs(c)); + reset(); + pos = 0; + return true; + } + } + if (isprint(key.get_ascii_code()) && (!key.is_alt_down()) && (!key.is_control_down())) { String c; c += key.get_ascii_code(); diff --git a/honoka/plugins/asciiinput.h b/honoka/plugins/asciiinput.h index d649324..22576da 100644 --- a/honoka/plugins/asciiinput.h +++ b/honoka/plugins/asciiinput.h @@ -48,7 +48,8 @@ virtual bool keyEventHook(const KeyEvent &key); protected: - HonokaKeyEventList lowProprotyKey; + HonokaKeyEventList lowProprotyKey,autoCommitKey; + bool autoCommit; protected: bool keyEvent(const KeyEvent &key); }; diff --git a/honoka/plugins/asciiplugin.cpp b/honoka/plugins/asciiplugin.cpp index b607587..9f07368 100644 --- a/honoka/plugins/asciiplugin.cpp +++ b/honoka/plugins/asciiplugin.cpp @@ -55,6 +55,18 @@ _("set the key that lowers priority."), String(HONOKA_DEFAULT_ASCIIINPUT_LOW_PRIORITY_KEY) )); + page->append(new HonokaSetupBoolItem( + _("Use automatic committing: "), + String(HONOKA_CONFIG_ASCIIINPUT_AUTO_COMMIT), + _("if you want to commit the string when you press the specific key,check it."), + HONOKA_DEFAULT_ASCIIINPUT_AUTO_COMMIT + )); + page->append(new HonokaSetupKeyItem( + _("Automatic committing key: "), + String(HONOKA_CONFIG_ASCIIINPUT_AUTO_COMMIT_KEY), + _("set the key that commit the string automatic."), + String(HONOKA_DEFAULT_ASCIIINPUT_AUTO_COMMIT_KEY) + )); HonokaSetupPage *sc = new HonokaSetupPage(_("shortcut keys: "),"",""); sc->append(new HonokaSetupKeyItem( diff --git a/honoka/plugins/asciiplugin.h b/honoka/plugins/asciiplugin.h index e5e3418..cb1857d 100644 --- a/honoka/plugins/asciiplugin.h +++ b/honoka/plugins/asciiplugin.h @@ -37,6 +37,10 @@ #define HONOKA_DEFAULT_WORDSPREDICTION_FILE "/usr/share/dict/words" #define HONOKA_CONFIG_ASCIIINPUT_LOW_PRIORITY_KEY "/IMEngine/Honoka/AsciiInput/LowPriorityKey" #define HONOKA_DEFAULT_ASCIIINPUT_LOW_PRIORITY_KEY "" +#define HONOKA_CONFIG_ASCIIINPUT_AUTO_COMMIT_KEY "/IMEngine/Honoka/AsciiInput/AutoCommitKey" +#define HONOKA_DEFAULT_ASCIIINPUT_AUTO_COMMIT_KEY "space,comma,period" +#define HONOKA_CONFIG_ASCIIINPUT_AUTO_COMMIT "/IMEngine/Honoka/AsciiInput/AutoCommit" +#define HONOKA_DEFAULT_ASCIIINPUT_AUTO_COMMIT false using namespace std; using namespace scim;