summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
Unidiff
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 7ddfd3e..f8cafd5 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1284,198 +1284,198 @@ ushort Keyboard::parseKoreanInput (ushort c) {
1284 return combineKoreanChars(schar, mchar, 0); 1284 return combineKoreanChars(schar, mchar, 0);
1285 1285
1286 } 1286 }
1287 else { 1287 else {
1288 schar = 0; mchar = 0; echar = 0; 1288 schar = 0; mchar = 0; echar = 0;
1289 return c; 1289 return c;
1290 } 1290 }
1291 1291
1292 } 1292 }
1293 else /*if (c == ' ')*/ return c; 1293 else /*if (c == ' ')*/ return c;
1294 1294
1295 1295
1296 // and now... finally delete previous char, and return new char 1296 // and now... finally delete previous char, and return new char
1297 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1297 emit key( 8, Qt::Key_Backspace, 0, true, false );
1298 1298
1299 1299
1300 return combineKoreanChars( schar, mchar, echar); 1300 return combineKoreanChars( schar, mchar, echar);
1301 1301
1302} 1302}
1303 1303
1304ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 1304ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
1305 1305
1306 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 1306 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
1307 1307
1308} 1308}
1309 1309
1310ushort Keyboard::constoe(const ushort c) { 1310ushort Keyboard::constoe(const ushort c) {
1311 1311
1312 // converts schars to echars if possible 1312 // converts schars to echars if possible
1313 1313
1314 if (0x1100 <= c && c <= 0x1112) { // schar to echar 1314 if (0x1100 <= c && c <= 0x1112) { // schar to echar
1315 1315
1316 switch (c) { 1316 switch (c) {
1317 case 0x1100: return 0x11a8; 1317 case 0x1100: return 0x11a8;
1318 case 0x1101: return 0x11a9; 1318 case 0x1101: return 0x11a9;
1319 case 0x1102: return 0x11ab; 1319 case 0x1102: return 0x11ab;
1320 case 0x1103: return 0x11ae; 1320 case 0x1103: return 0x11ae;
1321 case 0x1105: return 0x11af; 1321 case 0x1105: return 0x11af;
1322 case 0x1106: return 0x11b7; 1322 case 0x1106: return 0x11b7;
1323 case 0x1107: return 0x11b8; 1323 case 0x1107: return 0x11b8;
1324 case 0x1109: return 0x11ba; 1324 case 0x1109: return 0x11ba;
1325 case 0x110a: return 0x11bb; 1325 case 0x110a: return 0x11bb;
1326 case 0x110b: return 0x11bc; 1326 case 0x110b: return 0x11bc;
1327 case 0x110c: return 0x11bd; 1327 case 0x110c: return 0x11bd;
1328 case 0x110e: return 0x11be; 1328 case 0x110e: return 0x11be;
1329 case 0x110f: return 0x11bf; 1329 case 0x110f: return 0x11bf;
1330 case 0x1110: return 0x11c0; 1330 case 0x1110: return 0x11c0;
1331 case 0x1111: return 0x11c1; 1331 case 0x1111: return 0x11c1;
1332 case 0x1112: return 0x11c2; 1332 case 0x1112: return 0x11c2;
1333 default: return 0; 1333 default: return 0;
1334 1334
1335 } 1335 }
1336 1336
1337 } else { //echar to schar 1337 } else { //echar to schar
1338 1338
1339 switch (c) { 1339 switch (c) {
1340 case 0x11a8: return 0x1100; 1340 case 0x11a8: return 0x1100;
1341 case 0x11a9: return 0x1101; 1341 case 0x11a9: return 0x1101;
1342 case 0x11ab: return 0x1102; 1342 case 0x11ab: return 0x1102;
1343 case 0x11ae: return 0x1103; 1343 case 0x11ae: return 0x1103;
1344 case 0x11af: return 0x1105; 1344 case 0x11af: return 0x1105;
1345 case 0x11b7: return 0x1106; 1345 case 0x11b7: return 0x1106;
1346 case 0x11b8: return 0x1107; 1346 case 0x11b8: return 0x1107;
1347 case 0x11ba: return 0x1109; 1347 case 0x11ba: return 0x1109;
1348 case 0x11bb: return 0x110a; 1348 case 0x11bb: return 0x110a;
1349 case 0x11bc: return 0x110b; 1349 case 0x11bc: return 0x110b;
1350 case 0x11bd: return 0x110c; 1350 case 0x11bd: return 0x110c;
1351 case 0x11be: return 0x110e; 1351 case 0x11be: return 0x110e;
1352 case 0x11bf: return 0x110f; 1352 case 0x11bf: return 0x110f;
1353 case 0x11c0: return 0x1110; 1353 case 0x11c0: return 0x1110;
1354 case 0x11c1: return 0x1111; 1354 case 0x11c1: return 0x1111;
1355 case 0x11c2: return 0x1112; 1355 case 0x11c2: return 0x1112;
1356 default: return 0; 1356 default: return 0;
1357 1357
1358 } 1358 }
1359 1359
1360 } 1360 }
1361} 1361}
1362 1362
1363 1363
1364// Keys::Keys {{{1 1364// Keys::Keys {{{1
1365 1365
1366Keys::Keys() { 1366Keys::Keys() {
1367 1367
1368 Config *config = new Config ("multikey"); 1368 Config *config = new Config ("multikey");
1369 config->setGroup( "keymaps" ); 1369 config->setGroup( "keymaps" );
1370 QString map = config->readEntry( "current" ); 1370 QString map = config->readEntry( "current" );
1371 delete config; 1371 delete config;
1372 1372
1373 if (map.isNull() || !(QFile(map).exists())) { 1373 if (map.isNull() || !(QFile(map).exists())) {
1374 1374
1375 Config *config = new Config("locale"); 1375 Config *config = new Config("locale");
1376 config->setGroup( "Language" ); 1376 config->setGroup( "Language" );
1377 QString l = config->readEntry( "Language" , "en" ); 1377 QString l = config->readEntry( "Language" , "en" );
1378 delete config; 1378 delete config;
1379 1379
1380 map = QPEApplication::qpeDir() + "/share/multikey/" 1380 map = QPEApplication::qpeDir() + "share/multikey/"
1381 + l + ".keymap"; 1381 + l + ".keymap";
1382 1382
1383 } 1383 }
1384 if (map.isNull() || !(QFile(map).exists())) { 1384 if (map.isNull() || !(QFile(map).exists())) {
1385 map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; 1385 map = QPEApplication::qpeDir() + "share/multikey/en.keymap";
1386 } 1386 }
1387 1387
1388 setKeysFromFile(map); 1388 setKeysFromFile(map);
1389} 1389}
1390 1390
1391Keys::Keys(const char * filename) { 1391Keys::Keys(const char * filename) {
1392 1392
1393 setKeysFromFile(filename); 1393 setKeysFromFile(filename);
1394} 1394}
1395 1395
1396// Keys::setKeysFromFile {{{2 1396// Keys::setKeysFromFile {{{2
1397void Keys::setKeysFromFile(const char * filename) { 1397void Keys::setKeysFromFile(const char * filename) {
1398 1398
1399 QFile f(filename); 1399 QFile f(filename);
1400 1400
1401 if (f.open(IO_ReadOnly)) { 1401 if (f.open(IO_ReadOnly)) {
1402 1402
1403 QTextStream t(&f); 1403 QTextStream t(&f);
1404 int row; 1404 int row;
1405 int qcode; 1405 int qcode;
1406 ushort unicode; 1406 ushort unicode;
1407 int width; 1407 int width;
1408 QString buf; 1408 QString buf;
1409 QString comment; 1409 QString comment;
1410 char * xpm[256]; //couldnt be larger than that... could it? 1410 char * xpm[256]; //couldnt be larger than that... could it?
1411 QImage *xpm2pix = 0; 1411 QImage *xpm2pix = 0;
1412 1412
1413 buf = t.readLine(); 1413 buf = t.readLine();
1414 while (buf) { 1414 while (buf) {
1415 1415
1416 // get rid of comments 1416 // get rid of comments
1417 buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); 1417 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1418 1418
1419 // key definition 1419 // key definition
1420 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1420 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1421 // no $1 type referencing!!! this implementation of regexp sucks 1421 // no $1 type referencing!!! this implementation of regexp sucks
1422 1422
1423 // dont know of any sscanf() type funcs in Qt lib 1423 // dont know of any sscanf() type funcs in Qt lib
1424 QTextStream tmp (buf, IO_ReadOnly); 1424 QTextStream tmp (buf, IO_ReadOnly);
1425 tmp >> row >> qcode >> unicode >> width >> comment; 1425 tmp >> row >> qcode >> unicode >> width >> comment;
1426 1426
1427 buf = t.readLine(); 1427 buf = t.readLine();
1428 int xpmLineCount = 0; 1428 int xpmLineCount = 0;
1429 xpm2pix = 0; 1429 xpm2pix = 0;
1430 1430
1431 // erase blank space 1431 // erase blank space
1432 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1432 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1433 1433
1434 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1434 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1435 1435
1436 QString xpmBuf = buf.stripWhiteSpace(); 1436 QString xpmBuf = buf.stripWhiteSpace();
1437 1437
1438 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1438 xpm[xpmLineCount] = new char [xpmBuf.length()];
1439 1439
1440 int j = 0; 1440 int j = 0;
1441 for (ushort i = 0; i < xpmBuf.length(); i++) { 1441 for (ushort i = 0; i < xpmBuf.length(); i++) {
1442 if (xpmBuf[i].latin1() != '"') { 1442 if (xpmBuf[i].latin1() != '"') {
1443 1443
1444 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1444 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1445 j++; 1445 j++;
1446 } 1446 }
1447 1447
1448 } 1448 }
1449 // have to close that facker up 1449 // have to close that facker up
1450 ((char *)xpm[xpmLineCount])[j] = '\0'; 1450 ((char *)xpm[xpmLineCount])[j] = '\0';
1451 1451
1452 xpmLineCount++; 1452 xpmLineCount++;
1453 buf = t.readLine(); 1453 buf = t.readLine();
1454 } 1454 }
1455 if (xpmLineCount) { 1455 if (xpmLineCount) {
1456 1456
1457 xpm2pix = new QImage((const char **)xpm); 1457 xpm2pix = new QImage((const char **)xpm);
1458 for (int i = 0; i < xpmLineCount; i++) 1458 for (int i = 0; i < xpmLineCount; i++)
1459 1459
1460 delete [] (xpm[i]); 1460 delete [] (xpm[i]);
1461 1461
1462 } 1462 }
1463 setKey(row, qcode, unicode, width, xpm2pix); 1463 setKey(row, qcode, unicode, width, xpm2pix);
1464 } 1464 }
1465 1465
1466 // shift map 1466 // shift map
1467 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1467 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1468 1468
1469 QTextStream tmp (buf, IO_ReadOnly); 1469 QTextStream tmp (buf, IO_ReadOnly);
1470 ushort lower, shift; 1470 ushort lower, shift;
1471 tmp >> lower >> shift; 1471 tmp >> lower >> shift;
1472 1472
1473 shiftMap.insert(lower, shift); 1473 shiftMap.insert(lower, shift);
1474 1474
1475 buf = t.readLine(); 1475 buf = t.readLine();
1476 } 1476 }
1477 1477
1478 // meta key map 1478 // meta key map
1479 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1479 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1480 1480
1481 QTextStream tmp (buf, IO_ReadOnly); 1481 QTextStream tmp (buf, IO_ReadOnly);