summaryrefslogtreecommitdiff
path: root/inputmethods/multikey
Unidiff
Diffstat (limited to 'inputmethods/multikey') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 74c99c7..1c17172 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -856,384 +856,387 @@ ushort Keyboard::parseKoreanInput (ushort c) {
856 switch (echar) { 856 switch (echar) {
857 /* 857 /*
858 case 0x11a9: 858 case 0x11a9:
859 prev = combineKoreanChars(schar, mchar, 0x11a8); 859 prev = combineKoreanChars(schar, mchar, 0x11a8);
860 schar = 0x1100; 860 schar = 0x1100;
861 break; 861 break;
862 */ 862 */
863 case 0x11aa: 863 case 0x11aa:
864 prev = combineKoreanChars(schar, mchar, 0x11a8); 864 prev = combineKoreanChars(schar, mchar, 0x11a8);
865 schar = 0x1109; 865 schar = 0x1109;
866 break; 866 break;
867 case 0x11ac: 867 case 0x11ac:
868 prev = combineKoreanChars(schar, mchar, 0x11ab); 868 prev = combineKoreanChars(schar, mchar, 0x11ab);
869 schar = 0x110c; 869 schar = 0x110c;
870 break; 870 break;
871 case 0x11ad: 871 case 0x11ad:
872 prev = combineKoreanChars(schar, mchar, 0x11ab); 872 prev = combineKoreanChars(schar, mchar, 0x11ab);
873 schar = 0x1112; 873 schar = 0x1112;
874 break; 874 break;
875 case 0x11b0: 875 case 0x11b0:
876 prev = combineKoreanChars(schar, mchar, 0x11af); 876 prev = combineKoreanChars(schar, mchar, 0x11af);
877 schar = 0x1100; 877 schar = 0x1100;
878 break; 878 break;
879 case 0x11b1: 879 case 0x11b1:
880 prev = combineKoreanChars(schar, mchar, 0x11af); 880 prev = combineKoreanChars(schar, mchar, 0x11af);
881 schar = 0x1106; 881 schar = 0x1106;
882 break; 882 break;
883 case 0x11b2: 883 case 0x11b2:
884 prev = combineKoreanChars(schar, mchar, 0x11af); 884 prev = combineKoreanChars(schar, mchar, 0x11af);
885 schar = 0x1107; 885 schar = 0x1107;
886 break; 886 break;
887 case 0x11b3: 887 case 0x11b3:
888 prev = combineKoreanChars(schar, mchar, 0x11af); 888 prev = combineKoreanChars(schar, mchar, 0x11af);
889 schar = 0x1109; 889 schar = 0x1109;
890 break; 890 break;
891 case 0x11b4: 891 case 0x11b4:
892 prev = combineKoreanChars(schar, mchar, 0x11af); 892 prev = combineKoreanChars(schar, mchar, 0x11af);
893 schar = 0x1110; 893 schar = 0x1110;
894 break; 894 break;
895 case 0x11b9: 895 case 0x11b9:
896 prev = combineKoreanChars(schar, mchar, 0x11b8); 896 prev = combineKoreanChars(schar, mchar, 0x11b8);
897 schar = 0x1109; 897 schar = 0x1109;
898 break; 898 break;
899 /* 899 /*
900 case 0x11bb: 900 case 0x11bb:
901 prev = combineKoreanChars(schar, mchar, 0x11ba); 901 prev = combineKoreanChars(schar, mchar, 0x11ba);
902 schar = 0x1109; 902 schar = 0x1109;
903 break; 903 break;
904 */ 904 */
905 default: 905 default:
906 906
907 if (constoe(echar)) { 907 if (constoe(echar)) {
908 908
909 prev = combineKoreanChars(schar, mchar, 0); 909 prev = combineKoreanChars(schar, mchar, 0);
910 schar = constoe(echar); 910 schar = constoe(echar);
911 } 911 }
912 break; 912 break;
913 } 913 }
914 914
915 emit key( prev, prev, 0, true, false ); 915 emit key( prev, prev, 0, true, false );
916 916
917 mchar = c; echar = 0; 917 mchar = c; echar = 0;
918 918
919 return combineKoreanChars(schar, mchar, 0); 919 return combineKoreanChars(schar, mchar, 0);
920 920
921 } 921 }
922 else { 922 else {
923 schar = 0; mchar = 0; echar = 0; 923 schar = 0; mchar = 0; echar = 0;
924 return c; 924 return c;
925 } 925 }
926 926
927 } 927 }
928 else /*if (c == ' ')*/ return c; 928 else /*if (c == ' ')*/ return c;
929 929
930 930
931 // and now... finally delete previous char, and return new char 931 // and now... finally delete previous char, and return new char
932 emit key( 8, Qt::Key_Backspace, 0, true, false ); 932 emit key( 8, Qt::Key_Backspace, 0, true, false );
933 933
934 934
935 return combineKoreanChars( schar, mchar, echar); 935 return combineKoreanChars( schar, mchar, echar);
936 936
937} 937}
938 938
939ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 939ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
940 940
941 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 941 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
942 942
943} 943}
944 944
945ushort Keyboard::constoe(const ushort c) { 945ushort Keyboard::constoe(const ushort c) {
946 946
947 // converts schars to echars if possible 947 // converts schars to echars if possible
948 948
949 if (0x1100 <= c && c <= 0x1112) { // schar to echar 949 if (0x1100 <= c && c <= 0x1112) { // schar to echar
950 950
951 switch (c) { 951 switch (c) {
952 case 0x1100: return 0x11a8; 952 case 0x1100: return 0x11a8;
953 case 0x1101: return 0x11a9; 953 case 0x1101: return 0x11a9;
954 case 0x1102: return 0x11ab; 954 case 0x1102: return 0x11ab;
955 case 0x1103: return 0x11ae; 955 case 0x1103: return 0x11ae;
956 case 0x1105: return 0x11af; 956 case 0x1105: return 0x11af;
957 case 0x1106: return 0x11b7; 957 case 0x1106: return 0x11b7;
958 case 0x1107: return 0x11b8; 958 case 0x1107: return 0x11b8;
959 case 0x1109: return 0x11ba; 959 case 0x1109: return 0x11ba;
960 case 0x110a: return 0x11bb; 960 case 0x110a: return 0x11bb;
961 case 0x110b: return 0x11bc; 961 case 0x110b: return 0x11bc;
962 case 0x110c: return 0x11bd; 962 case 0x110c: return 0x11bd;
963 case 0x110e: return 0x11be; 963 case 0x110e: return 0x11be;
964 case 0x110f: return 0x11bf; 964 case 0x110f: return 0x11bf;
965 case 0x1110: return 0x11c0; 965 case 0x1110: return 0x11c0;
966 case 0x1111: return 0x11c1; 966 case 0x1111: return 0x11c1;
967 case 0x1112: return 0x11c2; 967 case 0x1112: return 0x11c2;
968 default: return 0; 968 default: return 0;
969 969
970 } 970 }
971 971
972 } else { //echar to schar 972 } else { //echar to schar
973 973
974 switch (c) { 974 switch (c) {
975 case 0x11a8: return 0x1100; 975 case 0x11a8: return 0x1100;
976 case 0x11a9: return 0x1101; 976 case 0x11a9: return 0x1101;
977 case 0x11ab: return 0x1102; 977 case 0x11ab: return 0x1102;
978 case 0x11ae: return 0x1103; 978 case 0x11ae: return 0x1103;
979 case 0x11af: return 0x1105; 979 case 0x11af: return 0x1105;
980 case 0x11b7: return 0x1106; 980 case 0x11b7: return 0x1106;
981 case 0x11b8: return 0x1107; 981 case 0x11b8: return 0x1107;
982 case 0x11ba: return 0x1109; 982 case 0x11ba: return 0x1109;
983 case 0x11bb: return 0x110a; 983 case 0x11bb: return 0x110a;
984 case 0x11bc: return 0x110b; 984 case 0x11bc: return 0x110b;
985 case 0x11bd: return 0x110c; 985 case 0x11bd: return 0x110c;
986 case 0x11be: return 0x110e; 986 case 0x11be: return 0x110e;
987 case 0x11bf: return 0x110f; 987 case 0x11bf: return 0x110f;
988 case 0x11c0: return 0x1110; 988 case 0x11c0: return 0x1110;
989 case 0x11c1: return 0x1111; 989 case 0x11c1: return 0x1111;
990 case 0x11c2: return 0x1112; 990 case 0x11c2: return 0x1112;
991 default: return 0; 991 default: return 0;
992 992
993 } 993 }
994 994
995 } 995 }
996} 996}
997 997
998 998
999// Keys::Keys {{{1 999// Keys::Keys {{{1
1000 1000
1001Keys::Keys() { 1001Keys::Keys() {
1002 1002
1003 Config *config = new Config ("multikey"); 1003 Config *config = new Config ("multikey");
1004 config->setGroup( "keymaps" ); 1004 config->setGroup( "keymaps" );
1005 QString map = config->readEntry( "current" ); 1005 QString map = config->readEntry( "current" );
1006 delete config; 1006 delete config;
1007 1007
1008 if (map.isNull() || !(QFile(map).exists())) { 1008 if (map.isNull() || !(QFile(map).exists())) {
1009 1009
1010 Config *config = new Config("locale"); 1010 Config *config = new Config("locale");
1011 config->setGroup( "Language" ); 1011 config->setGroup( "Language" );
1012 QString l = config->readEntry( "Language" , "en" ); 1012 QString l = config->readEntry( "Language" , "en" );
1013 delete config; 1013 delete config;
1014 1014
1015 map = QPEApplication::qpeDir() + "/share/multikey/" 1015 map = QPEApplication::qpeDir() + "/share/multikey/"
1016 + l + ".keymap"; 1016 + l + ".keymap";
1017 1017
1018 } 1018 }
1019 1019
1020 setKeysFromFile(map); 1020 setKeysFromFile(map);
1021} 1021}
1022 1022
1023Keys::Keys(const char * filename) { 1023Keys::Keys(const char * filename) {
1024 1024
1025 setKeysFromFile(filename); 1025 setKeysFromFile(filename);
1026} 1026}
1027 1027
1028// Keys::setKeysFromFile {{{2 1028// Keys::setKeysFromFile {{{2
1029void Keys::setKeysFromFile(const char * filename) { 1029void Keys::setKeysFromFile(const char * filename) {
1030 1030
1031 QFile f(filename); 1031 QFile f(filename);
1032 1032
1033 if (f.open(IO_ReadOnly)) { 1033 if (f.open(IO_ReadOnly)) {
1034 1034
1035 QTextStream t(&f); 1035 QTextStream t(&f);
1036 int row; 1036 int row;
1037 int qcode; 1037 int qcode;
1038 ushort unicode; 1038 ushort unicode;
1039 int width; 1039 int width;
1040 QString buf; 1040 QString buf;
1041 QString comment; 1041 QString comment;
1042 char * xpm[256]; //couldnt be larger than that... could it? 1042 char * xpm[256]; //couldnt be larger than that... could it?
1043 QPixmap *xpm2pix = 0; 1043 QPixmap *xpm2pix = 0;
1044 1044
1045 buf = t.readLine(); 1045 buf = t.readLine();
1046 while (buf) { 1046 while (buf) {
1047 1047
1048 // get rid of comments
1049 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1050
1048 // key definition 1051 // key definition
1049 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1052 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1050 // no $1 type referencing!!! this implementation of regexp sucks 1053 // no $1 type referencing!!! this implementation of regexp sucks
1051 1054
1052 // dont know of any sscanf() type funcs in Qt lib 1055 // dont know of any sscanf() type funcs in Qt lib
1053 QTextStream tmp (buf, IO_ReadOnly); 1056 QTextStream tmp (buf, IO_ReadOnly);
1054 tmp >> row >> qcode >> unicode >> width >> comment; 1057 tmp >> row >> qcode >> unicode >> width >> comment;
1055 1058
1056 buf = t.readLine(); 1059 buf = t.readLine();
1057 int xpmLineCount = 0; 1060 int xpmLineCount = 0;
1058 xpm2pix = 0; 1061 xpm2pix = 0;
1059 1062
1060 // erase blank space 1063 // erase blank space
1061 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1064 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1062 1065
1063 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1066 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1064 1067
1065 QString xpmBuf = buf.stripWhiteSpace(); 1068 QString xpmBuf = buf.stripWhiteSpace();
1066 1069
1067 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1070 xpm[xpmLineCount] = new char [xpmBuf.length()];
1068 1071
1069 int j = 0; 1072 int j = 0;
1070 for (ushort i = 0; i < xpmBuf.length(); i++) { 1073 for (ushort i = 0; i < xpmBuf.length(); i++) {
1071 if (xpmBuf[i].latin1() != '"') { 1074 if (xpmBuf[i].latin1() != '"') {
1072 1075
1073 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1076 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1074 j++; 1077 j++;
1075 } 1078 }
1076 1079
1077 } 1080 }
1078 // have to close that facker up 1081 // have to close that facker up
1079 ((char *)xpm[xpmLineCount])[j] = '\0'; 1082 ((char *)xpm[xpmLineCount])[j] = '\0';
1080 1083
1081 xpmLineCount++; 1084 xpmLineCount++;
1082 buf = t.readLine(); 1085 buf = t.readLine();
1083 } 1086 }
1084 if (xpmLineCount) { 1087 if (xpmLineCount) {
1085 1088
1086 xpm2pix = new QPixmap((const char **)xpm); 1089 xpm2pix = new QPixmap((const char **)xpm);
1087 for (int i = 0; i < xpmLineCount; i++) 1090 for (int i = 0; i < xpmLineCount; i++)
1088 1091
1089 delete [] (xpm[i]); 1092 delete [] (xpm[i]);
1090 1093
1091 } 1094 }
1092 setKey(row, qcode, unicode, width, xpm2pix); 1095 setKey(row, qcode, unicode, width, xpm2pix);
1093 } 1096 }
1094 1097
1095 // shift map 1098 // shift map
1096 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1099 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1097 1100
1098 QTextStream tmp (buf, IO_ReadOnly); 1101 QTextStream tmp (buf, IO_ReadOnly);
1099 ushort lower, shift; 1102 ushort lower, shift;
1100 tmp >> lower >> shift; 1103 tmp >> lower >> shift;
1101 1104
1102 shiftMap.insert(lower, shift); 1105 shiftMap.insert(lower, shift);
1103 1106
1104 buf = t.readLine(); 1107 buf = t.readLine();
1105 } 1108 }
1106 1109
1107 // meta key map 1110 // meta key map
1108 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1111 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1109 1112
1110 QTextStream tmp (buf, IO_ReadOnly); 1113 QTextStream tmp (buf, IO_ReadOnly);
1111 ushort lower, shift; 1114 ushort lower, shift;
1112 QChar m; 1115 QChar m;
1113 tmp >> m >> lower >> shift; 1116 tmp >> m >> lower >> shift;
1114 1117
1115 metaMap.insert(lower, shift); 1118 metaMap.insert(lower, shift);
1116 1119
1117 buf = t.readLine(); 1120 buf = t.readLine();
1118 } 1121 }
1119 1122
1120 // other variables like lang & title 1123 // other variables like lang & title
1121 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1124 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1122 1125
1123 QTextStream tmp (buf, IO_ReadOnly); 1126 QTextStream tmp (buf, IO_ReadOnly);
1124 QString name, equals, value; 1127 QString name, equals, value;
1125 1128
1126 tmp >> name >> equals >> value; 1129 tmp >> name >> equals >> value;
1127 1130
1128 if (name == "lang") { 1131 if (name == "lang") {
1129 1132
1130 lang = value; 1133 lang = value;
1131 1134
1132 } 1135 }
1133 1136
1134 buf = t.readLine(); 1137 buf = t.readLine();
1135 } 1138 }
1136 // comments 1139 // comments
1137 else if (buf.contains(QRegExp("^\\s*#"))) { 1140 else if (buf.contains(QRegExp("^\\s*#"))) {
1138 1141
1139 buf = t.readLine(); 1142 buf = t.readLine();
1140 1143
1141 } else { // blank line, or garbage 1144 } else { // blank line, or garbage
1142 1145
1143 buf = t.readLine(); 1146 buf = t.readLine();
1144 1147
1145 } 1148 }
1146 1149
1147 } 1150 }
1148 f.close(); 1151 f.close();
1149 } 1152 }
1150 1153
1151} 1154}
1152 1155
1153// Keys::setKey {{{2 1156// Keys::setKey {{{2
1154void Keys::setKey(const int row, const int qcode, const ushort unicode, 1157void Keys::setKey(const int row, const int qcode, const ushort unicode,
1155 const int width, QPixmap *pix) { 1158 const int width, QPixmap *pix) {
1156 1159
1157 Key * key; 1160 Key * key;
1158 key = new Key; 1161 key = new Key;
1159 key->qcode = qcode; 1162 key->qcode = qcode;
1160 key->unicode = unicode; 1163 key->unicode = unicode;
1161 key->width = width; 1164 key->width = width;
1162 1165
1163 // share key->pressed between same keys 1166 // share key->pressed between same keys
1164 bool found = 0; 1167 bool found = 0;
1165 for (int i = 1; i <= 5; i++) { 1168 for (int i = 1; i <= 5; i++) {
1166 for (unsigned int j = 0; j < keys[i].count(); j++) 1169 for (unsigned int j = 0; j < keys[i].count(); j++)
1167 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1170 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1168 1171
1169 key->pressed = keys[i].at(j)->pressed; 1172 key->pressed = keys[i].at(j)->pressed;
1170 found = 1; 1173 found = 1;
1171 } 1174 }
1172 1175
1173 } 1176 }
1174 if (!found) { 1177 if (!found) {
1175 1178
1176 key->pressed = new bool; 1179 key->pressed = new bool;
1177 *(key->pressed) = 0; 1180 *(key->pressed) = 0;
1178 } 1181 }
1179 1182
1180 key->pix = pix; 1183 key->pix = pix;
1181 1184
1182 1185
1183 keys[row].append(key); 1186 keys[row].append(key);
1184} 1187}
1185 1188
1186// Keys::~Keys {{{2 1189// Keys::~Keys {{{2
1187Keys::~Keys() { 1190Keys::~Keys() {
1188 1191
1189 for (int i = 1; i <= 5; i++) 1192 for (int i = 1; i <= 5; i++)
1190 for (unsigned int j = 0; j < keys[i].count(); j++) 1193 for (unsigned int j = 0; j < keys[i].count(); j++)
1191 delete keys[i].at(j); 1194 delete keys[i].at(j);
1192 1195
1193} 1196}
1194 1197
1195// Keys:: other functions {{{2 1198// Keys:: other functions {{{2
1196int Keys::width(const int row, const int col) { 1199int Keys::width(const int row, const int col) {
1197 1200
1198 return keys[row].at(col)->width; 1201 return keys[row].at(col)->width;
1199 1202
1200} 1203}
1201ushort Keys::uni(const int row, const int col) { 1204ushort Keys::uni(const int row, const int col) {
1202 1205
1203 return keys[row].at(col)->unicode; 1206 return keys[row].at(col)->unicode;
1204 1207
1205} 1208}
1206 1209
1207int Keys::qcode(const int row, const int col) { 1210int Keys::qcode(const int row, const int col) {
1208 1211
1209 return keys[row].at(col)->qcode; 1212 return keys[row].at(col)->qcode;
1210} 1213}
1211 1214
1212QPixmap *Keys::pix(const int row, const int col) { 1215QPixmap *Keys::pix(const int row, const int col) {
1213 1216
1214 return keys[row].at(col)->pix; 1217 return keys[row].at(col)->pix;
1215 1218
1216} 1219}
1217bool Keys::pressed(const int row, const int col) { 1220bool Keys::pressed(const int row, const int col) {
1218 1221
1219 return *(keys[row].at(col)->pressed); 1222 return *(keys[row].at(col)->pressed);
1220} 1223}
1221 1224
1222int Keys::numKeys(const int row) { 1225int Keys::numKeys(const int row) {
1223 1226
1224 return keys[row].count(); 1227 return keys[row].count();
1225} 1228}
1226 1229
1227void Keys::setPressed(const int row, const int col, const bool pressed) { 1230void Keys::setPressed(const int row, const int col, const bool pressed) {
1228 1231
1229 *(keys[row].at(col)->pressed) = pressed; 1232 *(keys[row].at(col)->pressed) = pressed;
1230} 1233}
1231 1234
1232ushort Keys::shift(const ushort uni) { 1235ushort Keys::shift(const ushort uni) {
1233 1236
1234 if (shiftMap[uni]) { 1237 if (shiftMap[uni]) {
1235 1238
1236 return shiftMap[uni]; 1239 return shiftMap[uni];
1237 } 1240 }
1238 else 1241 else
1239 return 0; 1242 return 0;