Nicolaプラグインのシフト遅延タイマー。
1 parent 1d1b187 commit 2cb0d5309479d78021729e080b963f6ad7198213
@tamra tamra authored on 21 Dec 2005
Showing 3 changed files
View
28
honoka/libhonoka/honokatimer.cpp
 
 
 
/*!
\fn Honoka::HonokaTimer::self()
\fn HonokaTimer::self()
*/
HonokaTimer * Honoka::HonokaTimer::self()
HonokaTimer * HonokaTimer::self()
{
if (!_self) {
_self = new HonokaTimer();
_self->exec();
}
 
 
/*!
\fn Honoka::HonokaTimer::destruct()
\fn HonokaTimer::destruct()
*/
void Honoka::HonokaTimer::destruct()
void HonokaTimer::destruct()
{
if (_self == 0) return;
delete _self;
_self = 0;
}
 
 
/*!
\fn Honoka::HonokaTimer::timer()
\fn HonokaTimer::timer()
*/
void Honoka::HonokaTimer::timer()
void HonokaTimer::timer()
{
Transaction trans;
uint32 counter = 1;
while(1) {
}
 
 
/*!
\fn Honoka::HonokaTimer::exec()
\fn HonokaTimer::exec()
*/
void Honoka::HonokaTimer::exec()
void HonokaTimer::exec()
{
timer_pid = fork();
if (timer_pid == 0) timer();
}
 
 
/*!
\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;
if (reader.get_command(cmd)) {
}
 
 
/*!
\fn Honoka::HonokaTimer::eventFilter(const Transaction &trans)
\fn HonokaTimer::eventFilter(const Transaction &trans)
*/
vector<int> Honoka::HonokaTimer::eventFilter(const Transaction &trans)
vector<int> HonokaTimer::eventFilter(const Transaction &trans)
{
vector<int> res;
uint32 c = decode(trans);
if (c == 0) return res;
}
 
 
/*!
\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<uint32,int>(bef + delay,eventCount));
return eventCount;
View
47
honoka/plugins/nicolainput.cpp
* 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;
}
}
View
3
■■
honoka/plugins/nicolainput.h
bool LShift;
bool RShift;
KeyEventList LShiftKey;
KeyEventList RShiftKey;
unsigned int delay;
map<KeyEvent,NicolaKey> keymap;
WideString vsc;
WideString svsc;
WideString vs1;
WideString vs2;
WideString svs1;
WideString svs2;
long bkt;
KeyEvent bk;
};
}
#endif