diff --git a/honoka/libhonoka/honokatimer.cpp b/honoka/libhonoka/honokatimer.cpp index 214f57a..ddfb481 100644 --- a/honoka/libhonoka/honokatimer.cpp +++ b/honoka/libhonoka/honokatimer.cpp @@ -54,9 +54,9 @@ /*! - \fn Honoka::HonokaTimer::self() + \fn HonokaTimer::self() */ -HonokaTimer * Honoka::HonokaTimer::self() +HonokaTimer * HonokaTimer::self() { if (!_self) { _self = new HonokaTimer(); @@ -67,9 +67,9 @@ /*! - \fn Honoka::HonokaTimer::destruct() + \fn HonokaTimer::destruct() */ -void Honoka::HonokaTimer::destruct() +void HonokaTimer::destruct() { if (_self == 0) return; delete _self; @@ -78,9 +78,9 @@ /*! - \fn Honoka::HonokaTimer::timer() + \fn HonokaTimer::timer() */ -void Honoka::HonokaTimer::timer() +void HonokaTimer::timer() { Transaction trans; uint32 counter = 1; @@ -96,9 +96,9 @@ /*! - \fn Honoka::HonokaTimer::exec() + \fn HonokaTimer::exec() */ -void Honoka::HonokaTimer::exec() +void HonokaTimer::exec() { timer_pid = fork(); if (timer_pid == 0) timer(); @@ -106,9 +106,9 @@ /*! - \fn Honoka::HonokaTimer::decode(const Transaction &trans) + \fn HonokaTimer::decode(const Transaction &trans) */ -uint32 Honoka::HonokaTimer::decode(const Transaction &trans) +uint32 HonokaTimer::decode(const Transaction &trans) { TransactionReader reader(trans); int cmd; @@ -124,9 +124,9 @@ /*! - \fn Honoka::HonokaTimer::eventFilter(const Transaction &trans) + \fn HonokaTimer::eventFilter(const Transaction &trans) */ -vector Honoka::HonokaTimer::eventFilter(const Transaction &trans) +vector HonokaTimer::eventFilter(const Transaction &trans) { vector res; uint32 c = decode(trans); @@ -143,9 +143,9 @@ /*! - \fn Honoka::HonokaTimer::appendDelayEvent(uint32 delay) + \fn HonokaTimer::appendDelayEvent(uint32 delay) */ -int Honoka::HonokaTimer::appendDelayEvent(uint32 delay) +int HonokaTimer::appendDelayEvent(uint32 delay) { eventCount ++; events.insert(pair(bef + delay,eventCount)); diff --git a/honoka/plugins/nicolainput.cpp b/honoka/plugins/nicolainput.cpp index 817b83d..915b3ac 100644 --- a/honoka/plugins/nicolainput.cpp +++ b/honoka/plugins/nicolainput.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include "nicolainput.h" #include "honoka_plugin_def.h" +#include #ifdef HAVE_CONFIG_H #include @@ -135,6 +136,8 @@ 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; @@ -215,6 +218,7 @@ 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); @@ -226,6 +230,9 @@ } } 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 ++; } @@ -242,14 +249,32 @@ { 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; } diff --git a/honoka/plugins/nicolainput.h b/honoka/plugins/nicolainput.h index cdc5fb1..57987e8 100644 --- a/honoka/plugins/nicolainput.h +++ b/honoka/plugins/nicolainput.h @@ -61,6 +61,7 @@ bool RShift; KeyEventList LShiftKey; KeyEventList RShiftKey; + unsigned int delay; map keymap; WideString vsc; WideString svsc; @@ -68,6 +69,8 @@ WideString vs2; WideString svs1; WideString svs2; + long bkt; + KeyEvent bk; }; } #endif