| |
---|
| | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
| | ***************************************************************************/ |
---|
| | #include "nicolainput.h" |
---|
| | #include "honoka_plugin_def.h" |
---|
| | #include <sys/time.h> |
---|
| | |
---|
| | #ifdef HAVE_CONFIG_H |
---|
| | #include <config.h> |
---|
| | #endif |
---|
| |
---|
| | |
---|
| | |
---|
| | NicolaInput::NicolaInput(ConfigPointer cfg) : PreEditor(cfg) |
---|
| | { |
---|
| | bkt = 0; |
---|
| | delay = 100; |
---|
| | scim_string_to_key_list(LShiftKey,cfg->read(HONOKA_CONFIG_NICOLAINPUT_LSHIFT,String(HONOKA_DEFAULT_NICOLAINPUT_LSHIFT))); |
---|
| | scim_string_to_key_list(RShiftKey,cfg->read(HONOKA_CONFIG_NICOLAINPUT_RSHIFT,String(HONOKA_DEFAULT_NICOLAINPUT_RSHIFT))); |
---|
| | LShift = false; |
---|
| | RShift = false; |
---|
| |
---|
| | WideString w; |
---|
| | if (LShift) w = it->second.leftShift; |
---|
| | else if (RShift) w = it->second.rightShift; |
---|
| | else w = it->second.noShift; |
---|
| | bk = key; |
---|
| | if (w == vsc) { |
---|
| | for(unsigned int i = 0;i < vs1.length();i ++) { |
---|
| | if (vs1[i] == text[pos - 1]) text = text.substr(0,pos - 1) + vs2[i] + text.substr(pos); |
---|
| | } |
---|
| |
---|
| | if (svs1[i] == text[pos - 1]) text = text.substr(0,pos - 1) + svs2[i] + text.substr(pos); |
---|
| | } |
---|
| | } else |
---|
| | if (w.length()) { |
---|
| | struct timeval tv; |
---|
| | gettimeofday(&tv, NULL); |
---|
| | bkt = (tv.tv_sec * 1000000) + tv.tv_usec; |
---|
| | text = text.substr(0,pos) + w + text.substr(pos); |
---|
| | pos ++; |
---|
| | } |
---|
| | return true; |
---|
| |
---|
| | bool NicolaInput::keyEventHook(const KeyEvent &key) |
---|
| | { |
---|
| | for(unsigned int i = 0;i < RShiftKey.size();i ++) { |
---|
| | if (key.code == RShiftKey[i].code) { |
---|
| | if (key.is_key_press()) RShift = true; |
---|
| | if (key.is_key_press()) { |
---|
| | RShift = true; |
---|
| | struct timeval tv; |
---|
| | gettimeofday(&tv, NULL); |
---|
| | long t = (tv.tv_sec * 1000000) + tv.tv_usec; |
---|
| | if ((t - bkt) < (delay * 1000)) { |
---|
| | backspace(); |
---|
| | return(inputEvent(bk)); |
---|
| | } |
---|
| | } |
---|
| | else if (key.is_key_release()) RShift = false; |
---|
| | return true; |
---|
| | } |
---|
| | } |
---|
| | for(unsigned int i = 0;i < LShiftKey.size();i ++) { |
---|
| | if (key.code == LShiftKey[i].code) { |
---|
| | if (key.is_key_press()) LShift = true; |
---|
| | if (key.is_key_press()) { |
---|
| | LShift = true; |
---|
| | struct timeval tv; |
---|
| | gettimeofday(&tv, NULL); |
---|
| | long t = (tv.tv_sec * 1000000) + tv.tv_usec; |
---|
| | if ((t - bkt) < (delay * 1000)) { |
---|
| | backspace(); |
---|
| | return(inputEvent(bk)); |
---|
| | } |
---|
| | } |
---|
| | else if (key.is_key_release()) LShift = false; |
---|
| | return true; |
---|
| | } |
---|
| | } |
---|
| | |