[sinhala-cvs-commits] sinhala/scim/wijesekera/src Makefile.am, NONE, 1.1 altkey_def.h, NONE, 1.1 co
Brought to you by:
aratnaweera,
harshula
From: nidujay <ni...@us...> - 2006-08-16 09:41:23
|
Update of /cvsroot/sinhala/sinhala/scim/wijesekera/src In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv16976/src Added Files: Makefile.am altkey_def.h complex_def.h intl.h modlist_def.h scim_wijesekera_imengine.cpp scim_wijesekera_imengine.h scim_wijesekera_imengine_factory.cpp scim_wijesekera_imengine_factory.h scim_wijesekera_imengine_setup.cpp scim_wijesekera_prefs.h sinhala.h Log Message: Version 0.2.2 (Functionally equivalent to 0.2.1) Initial checkin. --- NEW FILE: sinhala.h --- /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2004 * Copyright (C) 2004 - 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _STATES_H #define _STATES_H #define ZWNJ 0x0c #define ZWJ 0x0d #define SCH_ANUSWARA 0x82 #define SCH_VISARGA 0x83 #define SCH_AYANNA 0x85 #define SCH_AAYANNA 0x86 #define SCH_AEYANNA 0x87 #define SCH_AEEYANNA 0x88 #define SCH_IYANNA 0x89 #define SCH_IIYANNA 0x8a #define SCH_UYANNA 0x8b #define SCH_UUYANNA 0x8c #define SCH_IRUYANNA 0x8d #define SCH_IRUUYANNA 0x8e #define SCH_ILUYANNA 0x8f #define SCH_ILUUYANNA 0x90 #define SCH_EYANNA 0x91 #define SCH_EEYANNA 0x92 #define SCH_AIYANNA 0x93 #define SCH_OYANNA 0x94 #define SCH_OOYANNA 0x95 #define SCH_AUYANNA 0x96 #define SCH_KAYANNA 0x9A #define SCH__KAYANNA 0x9B #define SCH_GAYANNA 0x9C #define SCH__GAYANNA 0x9D #define SCH_NAASIKAYA 0x9E #define SCH_NGAYANNA 0x9F #define SCH_CAYANNA 0xA0 #define SCH__CAYANNA 0xA1 #define SCH_JAYANNA 0xA2 #define SCH__JAYANNA 0xA3 #define SCH_NYAYANNA 0xA4 #define SCH_GNYAYANNA 0xA5 #define SCH_NJAYANNA 0xA6 #define SCH_TTAYANNA 0xA7 #define SCH__TTAYANNA 0xA8 #define SCH_DDAYANNA 0xA9 #define SCH__DDAYANNA 0xAA #define SCH__NAYANNA 0xAB #define SCH_NDDAYANNA 0xAC #define SCH_TAYANNA 0xAD #define SCH__TAYANNA 0xAE #define SCH_DAYANNA 0xAF #define SCH__DAYANNA 0xB0 #define SCH_NAYANNA 0xB1 #define SCH_NDAYANNA 0xB3 #define SCH_PAYANNA 0xB4 #define SCH__PAYANNA 0xB5 #define SCH_BAYANNA 0xB6 #define SCH__BAYANNA 0xB7 #define SCH_MAYANNA 0xB8 #define SCH_MBAYANNA 0xB9 #define SCH_YAYANNA 0xBA #define SCH_RAYANNA 0xBB #define SCH_LAYANNA 0xBD #define SCH_VAYANNA 0xC0 #define SCH_SHAYANNA 0xC1 #define SCH__SAYANNA 0xC2 #define SCH_SAYANNA 0xC3 #define SCH_HAYANNA 0xC4 #define SCH__LAYANNA 0xC5 #define SCH_FAYANNA 0xC6 #define SCH_AL 0xCA #define SCH_AELA 0xCF #define SCH_AEDA 0xD0 #define SCH_DAEDA 0xD1 #define SCH_IS 0xD2 #define SCH_DIS 0xD3 #define SCH_PAA 0xD4 #define SCH_DPAA 0xD6 #define SCH_GAETA 0xD8 #define SCH_KOMBUWA 0xD9 #define SCH_DKOMBUWA 0xDA #define SCH_KOMBUDEKA 0xDB #define SCH_KOMBUAELA 0xDC #define SCH_DKOMBUAELA 0xDD #define SCH_KOMBUGAYANU 0xDE #define SCH_GAYANU 0xDF #define SCH_DGAETA 0xF2 #define SCH_DGAYANU 0xF3 // Complex definitions #define SCH_YANSAYA 0 #define SCH_RAKRAANSAYA 1 #define SCH_REPAYA 2 #define SCH__LUYANNA 3 #define BV(x) (1<<x) // Keytranslation definitions typedef struct { const uint8_t CharIdx; // Unicode/Punctuation Character or Index to a // complex unicode character. Selection based on // next field (flags) uint8_t Flags; // See Below // Values of the following have meaning based on Flags uint8_t CmplxId; // Complex key identifier (if complex) uint8_t AltKeyId; // Id to AltKey mapping (if available) uint8_t ModListId; // Id of Modlist (if modifier) uint32 Key; }KeyTrans_t; // KeyTranslation related flags enum { eKxf_ChType0, // ChType=0 simple Unicode, 1=Punctuation, 2=Complex unicode eKxf_ChType1, eKxf_Commit, // Iyanna, IIyanna etc can't be modified eKxf_Modifier, // Modifier such as SCH_AL eKxf_AltAlso, // Also has a 3rd shift }; // names of complex characters #define COMPLEX_DEF(name) Cmplx_##name, enum { #include "complex_def.h" Cmplx_Max }; // modifier list names #define MODLIST_DEF(name) ModId_##name, enum { #include "modlist_def.h" ModId_Max }; // AltShift Key names #define ALTKEY_DEF(name,flags) AltIdx_##name, enum { #include "altkey_def.h" AltIdx_Max }; typedef struct { const int Count; const uint8_t *Data; }Complex_t; #define CHTYPE_SIMPLE 0 #define CHTYPE_PUNCT BV(eKxf_ChType0) #define CHTYPE_COMPLEX BV(eKxf_ChType1) #define CHTYPE____ 0 #define CHTYPE___C BV(eKxf_Commit) #define CHTYPE__M_ BV(eKxf_Modifier) #define CHTYPE__MC BV(eKxf_Modifier)|BV(eKxf_Commit) #define CHTYPE_A__ BV(eKxf_AltAlso) #define CHTYPE_A_C BV(eKxf_AltAlso)|BV(eKxf_Commit) #define CHTYPE_AM_ BV(eKxf_Modifier)|BV(eKxf_Modifier) #define CHTYPE_AMC BV(eKxf_AltAlso)|BV(eKxf_Modifier)|BV(eKxf_Commit) #define CHTYPE_MASK (BV(eKxf_ChType0)|BV(eKxf_ChType1)) // Mod lists indicate for a given modifier (e.g. SCH_AL) which characters will // get modified (e.g. SCH_EYANNA + SCH_AL = SCH_EEYANNA). // Modifer info typedef struct { const uint8_t Source; const uint8_t Result; const bool Commit; // Character can not be modified anymore (commit) }ModInfo_t; // Pointer list of ModInfo_t typedef struct { const uint8_t Size; // Size list const ModInfo_t *List; }ModListPtr_t; #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif /* _STATES_H */ --- NEW FILE: scim_wijesekera_imengine.cpp --- /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) * Copyright (C) 2004 - 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * The original code is scim_uim_imengine.cpp in scim-uim-0.1.3. * Copyright (C) 2004 James Su <su...@ts...> */ #define Uses_SCIM_UTILITY #define Uses_SCIM_IMENGINE #define Uses_SCIM_LOOKUP_TABLE #define Uses_SCIM_CONFIG_BASE #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <scim.h> #include "scim_wijesekera_imengine_factory.h" #include "scim_wijesekera_imengine.h" #include "scim_wijesekera_prefs.h" #include "intl.h" // Keyboard map KeyTrans_t KeyTrans[]={ {SCH_REPAYA, CHTYPE_COMPLEX|CHTYPE____, Cmplx_repaya, 0, 0, SCIM_KEY_grave}, {SCH_RAKRAANSAYA, CHTYPE_COMPLEX|CHTYPE__M_, Cmplx_rakaransaya, 0, 0, SCIM_KEY_asciitilde}, {SCH_PAA, CHTYPE_SIMPLE|CHTYPE__MC, 0, 0, ModId_Max, SCIM_KEY_q}, {SCH_DPAA, CHTYPE_SIMPLE|CHTYPE__MC, 0, 0, ModId_Max, SCIM_KEY_Q}, {SCH_AYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_w}, {SCH_UYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_W}, {SCH_AEDA, CHTYPE_SIMPLE|CHTYPE__MC, 0, 0, ModId_Aeda, SCIM_KEY_e}, {SCH_DAEDA, CHTYPE_SIMPLE|CHTYPE__MC, 0, 0, ModId_DAeda, SCIM_KEY_E}, {SCH_RAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_r}, {SCH_IRUYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_R}, {SCH_EYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_t}, {SCH_OYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_T}, {SCH_HAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_y}, {SCH_SHAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_Y}, {SCH_MAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_u}, {SCH_MBAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_U}, {SCH_SAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_i}, {SCH__SAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_I}, {SCH_DAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_o}, {SCH__DAYANNA, CHTYPE_SIMPLE|CHTYPE_A__, 0, AltIdx_NDAYANNA, 0, SCIM_KEY_O}, {SCH_CAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_p}, {SCH__CAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_P}, {SCH_NYAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_bracketleft}, {SCH_GNYAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_braceleft}, {';', CHTYPE_PUNCT|CHTYPE____, 0, 0, 0, SCIM_KEY_bracketright }, {':', CHTYPE_PUNCT|CHTYPE____, 0, 0, 0, SCIM_KEY_braceright}, {SCH_AL, CHTYPE_SIMPLE|CHTYPE__M_, 0, 0, ModId_Al, SCIM_KEY_a}, {SCH_GAYANU, CHTYPE_SIMPLE|CHTYPE_AM_, 0, AltIdx_DGAYANU, ModId_Gayanu, SCIM_KEY_A}, {SCH_IS, CHTYPE_SIMPLE|CHTYPE__MC, 0, 0, ModId_Max, SCIM_KEY_s}, {SCH_DIS, CHTYPE_SIMPLE|CHTYPE__MC, 0, 0, ModId_Max, SCIM_KEY_S}, {SCH_AELA, CHTYPE_SIMPLE|CHTYPE__M_, 0, 0, ModId_Aela, SCIM_KEY_d}, {SCH_GAETA, CHTYPE_SIMPLE|CHTYPE__M_, 0, 0, ModId_Gaeta, SCIM_KEY_D}, {SCH_KOMBUWA, CHTYPE_SIMPLE|CHTYPE__M_, 0, 0, ModId_Kombu, SCIM_KEY_f}, {SCH_FAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_F}, {SCH_TTAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_g}, {SCH_GAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_G}, {SCH_YAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_h}, {SCH_YANSAYA, CHTYPE_COMPLEX|CHTYPE__M_, Cmplx_yansaya, 0, ModId_Max, SCIM_KEY_H}, {SCH_VAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_j}, {SCH__LUYANNA, CHTYPE_COMPLEX|CHTYPE___C, Cmplx_mluyanna, 0, 0, SCIM_KEY_J}, {SCH_NAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_k}, {SCH__NAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_K}, {SCH_KAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_l}, {SCH__KAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_L}, {SCH_TAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_semicolon}, {SCH__TAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_colon}, {'.', CHTYPE_PUNCT|CHTYPE____, 0, 0, 0, SCIM_KEY_quoteright}, {',', CHTYPE_PUNCT|CHTYPE____, 0, 0, 0, SCIM_KEY_quotedbl}, {'\'', CHTYPE_PUNCT|CHTYPE____, 0, 0, 0, SCIM_KEY_z}, {'\"', CHTYPE_PUNCT|CHTYPE____, 0, 0, 0, SCIM_KEY_Z}, {SCH_ANUSWARA, CHTYPE_SIMPLE|CHTYPE___C, 0, 0, 0, SCIM_KEY_x}, {SCH_NAASIKAYA, CHTYPE_SIMPLE|CHTYPE_A__, 0, AltIdx_VISARGA, 0, SCIM_KEY_X}, {SCH_JAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_c}, {SCH__JAYANNA, CHTYPE_SIMPLE|CHTYPE_A__, 0, AltIdx_NJAYANNA, 0, SCIM_KEY_C}, {SCH_DDAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_v}, {SCH__DDAYANNA, CHTYPE_SIMPLE|CHTYPE_A__, 0, AltIdx_NDDAYANNA, 0, SCIM_KEY_V}, {SCH_IYANNA, CHTYPE_SIMPLE|CHTYPE___C, 0, 0, 0, SCIM_KEY_b}, {SCH_IIYANNA, CHTYPE_SIMPLE|CHTYPE___C, 0, 0, 0, SCIM_KEY_B}, {SCH_BAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_n}, {SCH__BAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_N}, {SCH_PAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_m}, {SCH__PAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_M}, {SCH_LAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_comma}, {SCH__LAYANNA, CHTYPE_SIMPLE|CHTYPE_A__, 0, AltIdx_ILUYANNA, 0, SCIM_KEY_less}, {SCH_GAYANNA, CHTYPE_SIMPLE|CHTYPE____, 0, 0, 0, SCIM_KEY_period}, {SCH__GAYANNA, CHTYPE_SIMPLE|CHTYPE_A__, 0, AltIdx_NGAYANNA, 0, SCIM_KEY_greater}, },AltTrans[]={ // 3rd Shift Characters #define ALTKEY_DEF(name,flags) \ {SCH_##name, flags, 0, 0, ModId_Max, 0}, // key is redundant #include "altkey_def.h" }; // definition of 'complex' characters const uint8_t yansaya[] = { 0xca, ZWJ, 0xba }; const uint8_t rakaransaya[] = { 0xca, ZWJ, 0xbb }; const uint8_t repaya[] = { 0xbb, 0xca, ZWJ }; const uint8_t mluyanna[] = { SCH__LAYANNA, SCH_PAA }; // List of complex characters #define COMPLEX_DEF(name) {sizeof(name)/sizeof(uint8_t), name}, const Complex_t ComplexList[] = { #include "complex_def.h" }; // All modifications performed by some modifier keys static const ModInfo_t AlMods[] = { { SCH_EYANNA, SCH_EEYANNA, true}, { SCH_OYANNA, SCH_OOYANNA, true}, { SCH_KOMBUWA, SCH_DKOMBUWA, false}, // What do you think? { SCH_KOMBUAELA, SCH_DKOMBUAELA, true}, }; static const ModInfo_t AelaMods[] = { { SCH_AYANNA, SCH_AAYANNA, true}, { SCH_KOMBUWA, SCH_KOMBUAELA, false}, { SCH_DKOMBUWA, SCH_DKOMBUAELA, true}, }; static const ModInfo_t AedaMods[] = { { SCH_AYANNA, SCH_AEYANNA, true}, }; static const ModInfo_t DAedaMods[] = { { SCH_AYANNA, SCH_AEEYANNA, true}, }; static const ModInfo_t GaetaMods[] = { { SCH_IRUYANNA, SCH_IRUUYANNA, true}, { SCH_GAETA, SCH_DGAETA, true}, }; static const ModInfo_t KombuMods[] = { { SCH_EYANNA, SCH_AIYANNA, true}, { SCH_AL, SCH_DKOMBUWA, true}, { SCH_KOMBUWA, SCH_KOMBUDEKA, true}, { SCH_AELA, SCH_KOMBUAELA, false}, { SCH_GAYANU, SCH_KOMBUGAYANU, true}, }; static const ModInfo_t GayanuMods[] = { { SCH_UYANNA, SCH_UUYANNA, true}, { SCH_ILUYANNA, SCH_ILUUYANNA, true}, { SCH_OYANNA, SCH_AUYANNA, true}, { SCH_KOMBUWA, SCH_KOMBUGAYANU, true}, }; // List of ModLists (i.e. list of lists defined above) #define MODLIST_DEF(name) { sizeof(name##Mods)/sizeof(ModInfo_t), name##Mods}, static const ModListPtr_t ModLists[] = { #include "modlist_def.h" }; WijesekeraInstance::WijesekeraInstance (WijesekeraFactory *factory, const String &encoding, int id) : IMEngineInstanceBase (factory, encoding, id), m_factory (factory), m_prev_key (0,0), AuxCount(0) { SCIM_DEBUG_IMENGINE(1) << "Create WIJESEKERA Instance : "; } WijesekeraInstance::~WijesekeraInstance () { } void WijesekeraInstance::build_unicode_char(unsigned char lsb, unsigned char *u) { if (lsb >= 128) { u[0] = 0xe0; if (lsb < 192) { u[1] = 0xb6; u[2] = lsb; } else { u[1] = 0xb7; u[2] = (lsb & 0x3f) | 0x80; } u[3] = 0; } else if ((lsb == 0x0c) || (lsb == 0x0d)) { u[0] = 0xe2; u[1] = 0x80; u[2] = 0x80 | lsb; u[3] = 0; } else { u[0] = 0; } } void WijesekeraInstance::translate_and_commit(void) { uint8_t buf[32],*d=buf; if(!AuxCount) { return; } buf[0]=0; for(int i=0;i<AuxCount;i++,d+=3) { // XXX Assume everything is 3 bytes build_unicode_char(Aux[i], d); } commit_string(utf8_mbstowcs((const char*)buf)); Aux[0]=0; AuxCount=0; } void WijesekeraInstance::display_aux(void) { uint8_t buf[32],*d=buf; if(!AuxCount) { hide_aux_string(); return; } buf[0]=0; for(int i=0;i<AuxCount;i++,d+=3) { // XXX Assume everything is 3 bytes build_unicode_char(Aux[i], d); } update_aux_string(utf8_mbstowcs((const char *)buf), AttributeList()); show_aux_string(); } void WijesekeraInstance::build_complex_char(const uint8_t idx) { const uint8_t *c=ComplexList[idx].Data; int i=ComplexList[idx].Count; while(i--) { Aux[AuxCount++]=*c; c++; } Aux[AuxCount]=0; } void WijesekeraInstance::handle_modifier(const KeyTrans_t *kt) { const ModListPtr_t *ml=ModLists; bool found=false; // find the matching ModList if(kt->ModListId<ModId_Max) { ml=&ModLists[kt->ModListId]; found=true; } if(found) { // now find the modifiee (if any) const ModInfo_t *mi=ml->List; found=false; for(int i=0;i<ml->Size;i++,mi++) { if(Aux[AuxCount-1]==mi->Source) { Aux[AuxCount-1]=mi->Result; if(mi->Commit) { translate_and_commit(); } return; } } } if(Aux[AuxCount-1]>= SCH_AL && Aux[AuxCount-1] <= SCH_DGAYANU) { // disallow modifications to modifications (e.g. SCH_KOMBUDEKA + // SCH_AELA) return; } if((kt->Flags&CHTYPE_MASK)==CHTYPE_COMPLEX) { build_complex_char(kt->CmplxId); } else { // XXX Assume simple Aux[AuxCount++]=kt->CharIdx; Aux[AuxCount]=0; } if(kt->Flags&BV(eKxf_Commit)) { // keys such as paa-pilla translate_and_commit(); } } bool WijesekeraInstance::handle_key(const KeyEvent& key) { KeyTrans_t *kt=&KeyTrans[0]; bool found=false; if(is_shift_handled(key)) { for(int i=0;i<sizeof(KeyTrans)/sizeof(KeyTrans[0]);i++,kt++) { if(kt->Key==key.code) { // matched some key if(key.is_mod2_down()) { // we're actually looking for the Alt Shift key if(kt->Flags&BV(eKxf_AltAlso)) { kt=&AltTrans[kt->AltKeyId]; } else { return true; // Just trap key } } found=true; break; } } } if(!found) { translate_and_commit(); display_aux(); return false; } if(kt->Flags&BV(eKxf_Modifier)) { if(!AuxCount) { // for now we won't allow lonely modifiers (simpler) update_aux_string(utf8_mbstowcs("<!!>"), AttributeList()); show_aux_string(); return true; } else { handle_modifier(kt); } } else { // not a modifier. Commit what was already in aux string translate_and_commit(); if((kt->Flags&CHTYPE_MASK)==CHTYPE_SIMPLE) { Aux[AuxCount++]=kt->CharIdx; Aux[AuxCount]=0; } else if((kt->Flags&CHTYPE_MASK)==CHTYPE_PUNCT) { Aux[AuxCount++]=kt->CharIdx; Aux[AuxCount]=0; commit_string(utf8_mbstowcs((const char*)Aux)); AuxCount=0; } else if((kt->Flags&CHTYPE_MASK)==CHTYPE_COMPLEX) { build_complex_char(kt->CmplxId); } else { commit_string(utf8_mbstowcs("Unknown CHTYPE")); } if(kt->Flags&BV(eKxf_Commit)) { translate_and_commit(); } } display_aux(); return true; } bool WijesekeraInstance::process_key_event (const KeyEvent& key) { SCIM_DEBUG_IMENGINE(2) << "process_key_event.\n"; char temp[64]; if(key.code==SCIM_KEY_NullKey) { return false; } // ignore key release. if (key.is_key_release ()) { return true; } // ignore modifier keys if (key.code == SCIM_KEY_Shift_L || key.code == SCIM_KEY_Shift_R || key.code == SCIM_KEY_Alt_L || key.code == SCIM_KEY_Alt_R || key.code == SCIM_KEY_Control_L || key.code == SCIM_KEY_Control_R) return false; // lookup user defined key binds if (process_key_event_lookup_keybind (key)) return true; if(!handle_key(key)) { return false; } return true; } bool WijesekeraInstance::process_key_event_lookup_keybind (const KeyEvent& key) { return false; } void WijesekeraInstance::move_preedit_caret (unsigned int pos) { } void WijesekeraInstance::select_candidate (unsigned int item) { SCIM_DEBUG_IMENGINE(2) << "select_candidate.\n"; select_candidate_no_direct (item); } void WijesekeraInstance::select_candidate_no_direct (unsigned int item) { SCIM_DEBUG_IMENGINE(2) << "select_candidate_no_direct.\n"; m_lookup_table.set_cursor_pos_in_current_page (item); update_lookup_table (m_lookup_table); } void WijesekeraInstance::update_lookup_table_page_size (unsigned int page_size) { SCIM_DEBUG_IMENGINE(2) << "update_lookup_table_page_size.\n"; m_lookup_table.set_page_size (page_size); } void WijesekeraInstance::lookup_table_page_up () { SCIM_DEBUG_IMENGINE(2) << "lookup_table_page_up.\n"; m_lookup_table.page_up (); update_lookup_table (m_lookup_table); } void WijesekeraInstance::lookup_table_page_down () { SCIM_DEBUG_IMENGINE(2) << "lookup_table_page_down.\n"; m_lookup_table.page_down (); update_lookup_table (m_lookup_table); } void WijesekeraInstance::reset () { SCIM_DEBUG_IMENGINE(2) << "reset.\n"; m_lookup_table.clear (); update_preedit_caret (0); update_preedit_string (utf8_mbstowcs ("")); hide_lookup_table (); hide_preedit_string (); } void WijesekeraInstance::focus_in () { SCIM_DEBUG_IMENGINE(2) << "focus_in.\n"; hide_aux_string (); } void WijesekeraInstance::focus_out () { SCIM_DEBUG_IMENGINE(2) << "focus_out.\n"; } void WijesekeraInstance::trigger_property (const String &property) { String wijesekera_prop = property.substr (property.find_last_of ('/') + 1); SCIM_DEBUG_IMENGINE(2) << "trigger_property : " << property << " - " << wijesekera_prop << "\n"; } /* vi:ts=4:nowrap:ai:expandtab */ --- NEW FILE: altkey_def.h --- #ifndef ALTKEY_DEF #define ALTKEY_DEF(name,flags) #endif ALTKEY_DEF(NDAYANNA, CHTYPE_SIMPLE|CHTYPE____) ALTKEY_DEF(DGAYANU, CHTYPE_SIMPLE|CHTYPE__M_) // modifier without a list ALTKEY_DEF(VISARGA, CHTYPE_SIMPLE|CHTYPE___C) ALTKEY_DEF(NJAYANNA, CHTYPE_SIMPLE|CHTYPE____) ALTKEY_DEF(NDDAYANNA,CHTYPE_SIMPLE|CHTYPE____) ALTKEY_DEF(ILUYANNA, CHTYPE_SIMPLE|CHTYPE____) ALTKEY_DEF(NGAYANNA, CHTYPE_SIMPLE|CHTYPE____) #undef ALTKEY_DEF --- NEW FILE: complex_def.h --- #ifndef COMPLEX_DEF #define COMPLEX_DEF(name) #endif COMPLEX_DEF(yansaya) COMPLEX_DEF(rakaransaya) COMPLEX_DEF(repaya) COMPLEX_DEF(mluyanna) #undef COMPLEX_DEF --- NEW FILE: scim_wijesekera_imengine_factory.h --- /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2004 * Copyright (C) 2004 - 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * The original code is scim_uim_imengine.cpp in scim-uim-0.1.3. * Copyright (C) 2004 James Su <su...@ts...> */ #ifndef __SCIM_WIJESEKERA_IMENGINE_FACTORY_H__ #define __SCIM_WIJESEKERA_IMENGINE_FACTORY_H__ #define Uses_SCIM_ICONV #include <scim.h> using namespace scim; class WijesekeraFactory : public IMEngineFactoryBase { String m_uuid; friend class WijesekeraInstance; /* config */ ConfigPointer m_config; Connection m_reload_signal_connection; public: WijesekeraFactory (const String &lang, const String &uuid, const ConfigPointer &config); virtual ~WijesekeraFactory (); virtual WideString get_name () const; virtual WideString get_authors () const; virtual WideString get_credits () const; virtual WideString get_help () const; virtual String get_uuid () const; virtual String get_icon_file () const; virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1); private: void reload_config (const ConfigPointer &config); }; #endif /* __SCIM_WIJESEKERA_IMENGINE_FACTORY_H__ */ /* vi:ts=4:nowrap:ai:expandtab */ --- NEW FILE: scim_wijesekera_imengine_factory.cpp --- /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) * Copyright (C) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * The original code is scim_uim_imengine.cpp in scim-uim-0.1.3. * Copyright (C) 2004 James Su <su...@ts...> */ #define Uses_SCIM_UTILITY #define Uses_SCIM_IMENGINE #define Uses_SCIM_CONFIG_BASE #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <scim.h> #include "scim_wijesekera_imengine_factory.h" #include "scim_wijesekera_imengine.h" #include "scim_wijesekera_prefs.h" #include "intl.h" #define scim_module_init wijesekera_LTX_scim_module_init #define scim_module_exit wijesekera_LTX_scim_module_exit #define scim_imengine_module_init wijesekera_LTX_scim_imengine_module_init #define scim_imengine_module_create_factory wijesekera_LTX_scim_imengine_module_create_factory #define SCIM_CONFIG_IMENGINE_WIJESEKERA_UUID "/IMEngine/Wijesekera/UUID-" #ifndef SCIM_WIJESEKERA_ICON_FILE #define SCIM_WIJESEKERA_ICON_FILE (SCIM_ICONDIR"/scim-wijesekera.png") #endif static ConfigPointer _scim_config (0); extern "C" { void scim_module_init (void) { bindtextdomain (GETTEXT_PACKAGE, SCIM_WIJESEKERA_LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); } void scim_module_exit (void) { _scim_config.reset (); } uint32 scim_imengine_module_init (const ConfigPointer &config) { SCIM_DEBUG_IMENGINE(1) << "Initialize WIJESEKERA Engine.\n"; _scim_config = config; return 1; } IMEngineFactoryPointer scim_imengine_module_create_factory (uint32 engine) { WijesekeraFactory *factory = 0; try { factory = new WijesekeraFactory (String ("si_LK"), String ("eecc608c-900e-490e-b533-74b0738b2c7d"), _scim_config); } catch (...) { delete factory; factory = 0; } return factory; } } WijesekeraFactory::WijesekeraFactory (const String &lang, const String &uuid, const ConfigPointer &config) : m_uuid (uuid), m_config (config) { SCIM_DEBUG_IMENGINE(1) << "Create Wijesekera Factory :\n"; SCIM_DEBUG_IMENGINE(1) << " Lang : " << lang << "\n"; SCIM_DEBUG_IMENGINE(1) << " UUID : " << uuid << "\n"; if (lang.length () >= 2) set_languages (lang); // config reload_config (m_config); m_reload_signal_connection = m_config->signal_connect_reload (slot (this, &WijesekeraFactory::reload_config)); } WijesekeraFactory::~WijesekeraFactory () { } WideString WijesekeraFactory::get_name () const { return utf8_mbstowcs (String ("Wijesekera")); } WideString WijesekeraFactory::get_authors () const { return WideString (); } WideString WijesekeraFactory::get_credits () const { return WideString (); } WideString WijesekeraFactory::get_help () const { return WideString (); } String WijesekeraFactory::get_uuid () const { return m_uuid; } String WijesekeraFactory::get_icon_file () const { return String (SCIM_WIJESEKERA_ICON_FILE); } IMEngineInstancePointer WijesekeraFactory::create_instance (const String &encoding, int id) { return new WijesekeraInstance (this, encoding, id); } void WijesekeraFactory::reload_config (const ConfigPointer &config) { if (!config) return; } --- NEW FILE: Makefile.am --- AM_CPPFLAGS = \ -DSCIM_WIJESEKERA_LOCALEDIR=\"$(datadir)/locale\" \ -DSCIM_ICONDIR=\"@SCIM_ICONDIR@\" INCLUDE = \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/src noinst_HEADERS = \ intl.h \ scim_wijesekera_imengine_factory.h \ scim_wijesekera_imengine.h \ scim_wijesekera_prefs.h moduledir = @SCIM_MODULEDIR@/IMEngine module_LTLIBRARIES = wijesekera.la wijesekera_la_SOURCES = \ scim_wijesekera_imengine_factory.cpp \ scim_wijesekera_imengine.cpp wijesekera_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ wijesekera_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ wijesekera_la_LDFLAGS = \ -avoid-version \ -rpath $(moduledir) \ -module \ @LIBTOOL_EXPORT_OPTIONS@ \ @SCIM_LIBS@ if SCIM_BUILD_SETUP SETUP_MODULE = wijesekera-imengine-setup.la endif setupmoduledir = @SCIM_MODULEDIR@/SetupUI setupmodule_LTLIBRARIES = $(SETUP_MODULE) wijesekera_imengine_setup_la_SOURCES = scim_wijesekera_imengine_setup.cpp wijesekera_imengine_setup_la_CFLAGS = @SCIM_GTKUTILS_CFLAGS@ @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ wijesekera_imengine_setup_la_CXXFLAGS= @SCIM_GTKUTILS_CFLAGS@ @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ wijesekera_imengine_setup_la_LDFLAGS = -avoid-version \ -rpath $(setupmoduledir) \ -module \ @LIBTOOL_EXPORT_OPTIONS@ \ @SCIM_GTKUTILS_LIBS@ \ @LTLIBINTL@ \ @SCIM_LIBS@ --- NEW FILE: intl.h --- /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) * Copyright (C) 2004 - 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __INTL_H__ #define __INTL_H__ #ifdef HAVE_CONFIG_H #include <config.h> #endif #ifdef HAVE_GETTEXT #include <libintl.h> #define _(String) dgettext(GETTEXT_PACKAGE,String) #define N_(String) (String) #else #define _(String) (String) #define N_(String) (String) #define bindtextdomain(Package,Directory) #define textdomain(domain) #define bind_textdomain_codeset(domain,codeset) #endif #endif /* __INTL_H__ */ --- NEW FILE: scim_wijesekera_imengine.h --- /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2004 * Copyright (C) 2004 - 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * The original code is scim_uim_imengine.cpp in scim-uim-0.1.3. * Copyright (C) 2004 James Su <su...@ts...> */ #ifndef __SCIM_WIJESEKERA_IMENGINE_H__ #define __SCIM_WIJESEKERA_IMENGINE_H__ #include <scim.h> using namespace scim; #include "sinhala.h" class WijesekeraInstance : public IMEngineInstanceBase { friend class WijesekeraFactory; private: WijesekeraFactory *m_factory; KeyEvent m_prev_key; /* for candidates window */ CommonLookupTable m_lookup_table; /* for toolbar */ PropertyList m_properties; uint8_t Aux[32]; // Aux String (in LSBs) int AuxCount; // # of bytes in string public: WijesekeraInstance (WijesekeraFactory *factory, const String &encoding, int id = -1); virtual ~WijesekeraInstance (); virtual bool process_key_event (const KeyEvent& key); virtual void move_preedit_caret (unsigned int pos); virtual void select_candidate (unsigned int item); virtual void update_lookup_table_page_size (unsigned int page_size); virtual void lookup_table_page_up (void); virtual void lookup_table_page_down (void); virtual void reset (void); virtual void focus_in (void); virtual void focus_out (void); virtual void trigger_property (const String &property); public: private: // actions private: void select_candidate_no_direct (unsigned int item); /* processing key event */ bool process_key_event_lookup_keybind (const KeyEvent &key); bool process_key_event_without_preedit (const KeyEvent &key); bool process_key_event_with_preedit (const KeyEvent &key); bool process_key_event_with_candidate (const KeyEvent &key); bool process_remaining_key_event (const KeyEvent &key); inline bool is_shift_handled(const KeyEvent &key) { return (key.mask==0||key.is_shift_down()||key.is_mod2_down()); } void build_unicode_char(unsigned char lsb, unsigned char *u); void translate_and_commit(void); void build_complex_char(const uint8_t idx); void display_aux(void); void handle_modifier(const KeyTrans_t *kt); bool handle_key(const KeyEvent& key); }; #endif /* __SCIM_WIJESEKERA_IMENGINE_H__ */ /* vi:ts=4:nowrap:ai:expandtab */ --- NEW FILE: scim_wijesekera_imengine_setup.cpp --- /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2004 * Copyright (C) 2004 - 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * Based on scim-hangul. * Copyright (c) 2004 James Su <su...@tu...> */ #define Uses_SCIM_CONFIG_BASE #include <gtk/gtk.h> #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <scim.h> #include <gtk/scimkeyselection.h> #include "scim_wijesekera_prefs.h" #include "intl.h" using namespace scim; #define scim_module_init wijesekera_imengine_setup_LTX_scim_module_init #define scim_module_exit wijesekera_imengine_setup_LTX_scim_module_exit #define scim_setup_module_create_ui wijesekera_imengine_setup_LTX_scim_setup_module_create_ui #define scim_setup_module_get_category wijesekera_imengine_setup_LTX_scim_setup_module_get_category #define scim_setup_module_get_name wijesekera_imengine_setup_LTX_scim_setup_module_get_name #define scim_setup_module_get_description wijesekera_imengine_setup_LTX_scim_setup_module_get_description #define scim_setup_module_load_config wijesekera_imengine_setup_LTX_scim_setup_module_load_config #define scim_setup_module_save_config wijesekera_imengine_setup_LTX_scim_setup_module_save_config #define scim_setup_module_query_changed wijesekera_imengine_setup_LTX_scim_setup_module_query_changed #define DATA_POINTER_KEY "scim-wijesekera::ConfigPointer" static GtkWidget * create_setup_window (); static void load_config (const ConfigPointer &config); static void save_config (const ConfigPointer &config); static bool query_changed (); // Module Interface. extern "C" { void scim_module_init (void) { bindtextdomain (GETTEXT_PACKAGE, SCIM_WIJESEKERA_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); } void scim_module_exit (void) { } GtkWidget * scim_setup_module_create_ui (void) { return create_setup_window (); } String scim_setup_module_get_category (void) { return String ("IMEngine"); } String scim_setup_module_get_name (void) { return String (_("Wijesekera")); } String scim_setup_module_get_description (void) { return String (_("Wijesekera IMEngine Module.")); } void scim_setup_module_load_config (const ConfigPointer &config) { load_config (config); } void scim_setup_module_save_config (const ConfigPointer &config) { save_config (config); } bool scim_setup_module_query_changed () { return query_changed (); } } // extern "C" // Internal data structure struct KeyboardConfigData { const char *key; String data; const char *label; const char *title; const char *tooltip; GtkWidget *entry; GtkWidget *button; }; struct KeyboardConfigPage { const char *label; KeyboardConfigData *data; }; struct ComboConfigData { const char *label; const char *data; }; // Internal data declaration. static bool __have_changed = true; static GtkTooltips * __widget_tooltips = 0; static KeyboardConfigData __config_keyboards_common [] = { { NULL, "", NULL, NULL, NULL, NULL, NULL, }, }; static KeyboardConfigData __config_keyboards_mode [] = { { NULL, "", NULL, NULL, NULL, NULL, NULL, }, }; static KeyboardConfigData __config_keyboards_caret [] = { { NULL, "", NULL, NULL, NULL, NULL, NULL, }, }; static KeyboardConfigData __config_keyboards_candidates [] = { { NULL, "", NULL, NULL, NULL, NULL, NULL, }, }; static struct KeyboardConfigPage __key_conf_pages[] = { {N_("Common keys"), __config_keyboards_common}, {N_("Mode keys"), __config_keyboards_mode}, {N_("Caret keys"), __config_keyboards_caret}, {N_("Candidates keys"), __config_keyboards_candidates}, }; static unsigned int __key_conf_pages_num = sizeof (__key_conf_pages) / sizeof (KeyboardConfigPage); static void on_default_editable_changed (GtkEditable *editable, gpointer user_data); static void on_default_toggle_button_toggled (GtkToggleButton *togglebutton, gpointer user_data); static void on_default_key_selection_clicked (GtkButton *button, gpointer user_data); #if 0 static void on_default_combo_changed (GtkEditable *editable, gpointer user_data); #endif static void setup_widget_value (); #if 0 static GtkWidget * create_combo_widget (const char *label_text, GtkWidget **widget, gpointer data_p, gpointer candidates_p) { GtkWidget *hbox, *label; hbox = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox); gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); label = gtk_label_new (label_text); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); *widget = gtk_combo_new (); gtk_combo_set_value_in_list (GTK_COMBO (*widget), TRUE, FALSE); gtk_combo_set_case_sensitive (GTK_COMBO (*widget), TRUE); gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (*widget)->entry), FALSE); gtk_widget_show (*widget); gtk_box_pack_start (GTK_BOX (hbox), *widget, FALSE, FALSE, 4); g_object_set_data (G_OBJECT (GTK_COMBO (*widget)->entry), DATA_POINTER_KEY, (gpointer) candidates_p); g_signal_connect ((gpointer) GTK_COMBO (*widget)->entry, "changed", G_CALLBACK (on_default_combo_changed), data_p); return hbox; } #endif #define APPEND_ENTRY(text, tooltip, widget, i) \ { \ label = gtk_label_new (NULL); \ gtk_label_set_text_with_mnemonic (GTK_LABEL (label), text); \ gtk_widget_show (label); \ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); \ gtk_misc_set_padding (GTK_MISC (label), 4, 0); \ gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, \ (GtkAttachOptions) (GTK_FILL), \ (GtkAttachOptions) (GTK_FILL), 4, 4); \ widget = gtk_entry_new (); \ gtk_widget_show (widget); \ gtk_table_attach (GTK_TABLE (table), widget, 1, 2, i, i+1, \ (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), \ (GtkAttachOptions) (GTK_FILL), 4, 4); \ if (tooltip && *tooltip) \ gtk_tooltips_set_tip (__widget_tooltips, widget, \ tooltip, NULL); \ } static GtkWidget * create_options_page () { GtkWidget *vbox, *table, *label; vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox); table = gtk_table_new (2, 2, FALSE); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 4); gtk_widget_show (table); if (!__widget_tooltips) __widget_tooltips = gtk_tooltips_new(); return vbox; } static GtkWidget * create_keyboard_page (unsigned int page) { GtkWidget *table; GtkWidget *label; if (page >= __key_conf_pages_num) return NULL; KeyboardConfigData *data = __key_conf_pages[page].data; table = gtk_table_new (3, 3, FALSE); gtk_widget_show (table); if (!__widget_tooltips) __widget_tooltips = gtk_tooltips_new(); // Create keyboard setting. for (unsigned int i = 0; data[i].key; ++ i) { APPEND_ENTRY(_(data[i].label), _(data[i].tooltip), data[i].entry, i); gtk_entry_set_editable (GTK_ENTRY (data[i].entry), FALSE); data[i].button = gtk_button_new_with_label ("..."); gtk_widget_show (data[i].button); gtk_table_attach (GTK_TABLE (table), data[i].button, 2, 3, i, i+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 4, 4); gtk_label_set_mnemonic_widget (GTK_LABEL (label), data[i].button); } for (unsigned int i = 0; data[i].key; ++ i) { g_signal_connect ((gpointer) data[i].button, "clicked", G_CALLBACK (on_default_key_selection_clicked), &(data[i])); g_signal_connect ((gpointer) data[i].entry, "changed", G_CALLBACK (on_default_editable_changed), &(data[i].data)); } #if 0 for (unsigned int i = 0; data[i].key; ++ i) { gtk_tooltips_set_tip (__widget_tooltips, data[i].entry, _(data[i].tooltip), NULL); } #endif return table; } static GtkWidget * create_setup_window () { static GtkWidget *window = NULL; if (!window) { GtkWidget *notebook = gtk_notebook_new(); gtk_widget_show (notebook); window = notebook; gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); // Create the first page. GtkWidget *page = create_options_page (); GtkWidget *label = gtk_label_new (_("Options")); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); // Create the key bind pages. for (unsigned int i = 0; i < __key_conf_pages_num; i++) { page = create_keyboard_page (i); label = gtk_label_new (_(__key_conf_pages[i].label)); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); } // for preventing enabling left arrow. gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 1); gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0); setup_widget_value (); } return window; } #if 0 static void setup_combo_value (GtkCombo *combo, ComboConfigData *data, const String & str) { GList *list = NULL; const char *defval = NULL; for (unsigned int i = 0; data[i].label; i++) { list = g_list_append (list, (gpointer) _(data[i].label)); if (!strcmp (data[i].data, str.c_str ())) defval = _(data[i].label); } gtk_combo_set_popdown_strings (combo, list); g_list_free (list); if (defval) gtk_entry_set_text (GTK_ENTRY (combo->entry), defval); } #endif static void setup_widget_value () { #if 0 if (__widget_command) { gtk_entry_set_text ( GTK_ENTRY (__widget_command), __config_sample_string.c_str ()); } #endif for (unsigned int j = 0; j < __key_conf_pages_num; ++j) { for (unsigned int i = 0; __key_conf_pages[j].data[i].key; ++ i) { if (__key_conf_pages[j].data[i].entry) { gtk_entry_set_text ( GTK_ENTRY (__key_conf_pages[j].data[i].entry), __key_conf_pages[j].data[i].data.c_str ()); } } } } static void load_config (const ConfigPointer &config) { if (config.null ()) return; #if 0 __config_sample_string = config->read (String (SCIM_WIJESEKERA_CONFIG_SAMPLE_STRING), __config_sample_string); #endif for (unsigned int j = 0; j < __key_conf_pages_num; ++ j) { for (unsigned int i = 0; __key_conf_pages[j].data[i].key; ++ i) { __key_conf_pages[j].data[i].data = config->read (String (__key_conf_pages[j].data[i].key), __key_conf_pages[j].data[i].data); } } setup_widget_value (); __have_changed = false; } static void save_config (const ConfigPointer &config) { if (config.null ()) return; #if 0 config->write (String (SCIM_WIJESEKERA_CONFIG_SAMPLE_STRING), __config_sample_string); #endif for (unsigned int j = 0; j < __key_conf_pages_num; j++) { for (unsigned int i = 0; __key_conf_pages[j].data[i].key; ++ i) { config->write (String (__key_conf_pages[j].data[i].key), __key_conf_pages[j].data[i].data); } } __have_changed = false; } static bool query_changed () { return __have_changed; } static void on_default_toggle_button_toggled (GtkToggleButton *togglebutton, gpointer user_data) { bool *toggle = static_cast<bool*> (user_data); if (toggle) { *toggle = gtk_toggle_button_get_active (togglebutton); __have_changed = true; } } static void on_default_editable_changed (GtkEditable *editable, gpointer user_data) { String *str = static_cast <String *> (user_data); if (str) { *str = String (gtk_entry_get_text (GTK_ENTRY (editable))); __have_changed = true; } } static void on_default_key_selection_clicked (GtkButton *button, gpointer user_data) { KeyboardConfigData *data = static_cast <KeyboardConfigData *> (user_data); if (data) { GtkWidget *dialog = scim_key_selection_dialog_new (_(data->title)); gint result; scim_key_selection_dialog_set_keys ( SCIM_KEY_SELECTION_DIALOG (dialog), gtk_entry_get_text (GTK_ENTRY (data->entry))); result = gtk_dialog_run (GTK_DIALOG (dialog)); if (result == GTK_RESPONSE_OK) { const gchar *keys = scim_key_selection_dialog_get_keys ( SCIM_KEY_SELECTION_DIALOG (dialog)); if (!keys) keys = ""; if (strcmp (keys, gtk_entry_get_text (GTK_ENTRY (data->entry))) != 0) gtk_entry_set_text (GTK_ENTRY (data->entry), keys); } gtk_widget_destroy (dialog); } } static void on_default_combo_changed (GtkEditable *editable, gpointer user_data) { String *str = static_cast<String *> (user_data); ComboConfigData *data = static_cast<ComboConfigData *> (g_object_get_data (G_OBJECT (editable), DATA_POINTER_KEY)); if (!str) return; if (!data) return; const char *label = gtk_entry_get_text (GTK_ENTRY (editable)); for (unsigned int i = 0; data[i].label; i++) { if (label && !strcmp (_(data[i].label), label)) { *str = data[i].data; __have_changed = true; break; } } } /* vi:ts=4:nowrap:ai:expandtab */ --- NEW FILE: scim_wijesekera_prefs.h --- /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2004 * Copyright (C) 2004 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __SCIM_WIJESEKERA_PREFS_H__ #define __SCIM_WIJESEKERA_PREFS_H__ #endif /* __SCIM_WIJESEKERA_PREFS_H__ */ /* vi:ts=4:nowrap:ai:expandtab */ --- NEW FILE: modlist_def.h --- #ifndef MODLIST_DEF #define MODLIST_DEF(name) #endif MODLIST_DEF(Al) MODLIST_DEF(Aela) MODLIST_DEF(Aeda) MODLIST_DEF(DAeda) MODLIST_DEF(Gaeta) MODLIST_DEF(Kombu) MODLIST_DEF(Gayanu) #undef MODLIST_DEF |