Ticket #9744: keymap.cpp.patch
File keymap.cpp.patch, 8.6 KB (added by , 12 years ago) |
---|
-
haiku/src/kits/shared/Keymap.cpp
old new 1 1 /* 2 * Copyright 2004-201 2, Haiku, Inc. All Rights Reserved.2 * Copyright 2004-2013, Haiku, Inc. All Rights Reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 5 * Authors: 6 6 * Jérôme Duval 7 7 * Axel Dörfler, axeld@pinc-software.de. 8 8 * John Scipione, jscipione@gmail.com. 9 * Hristos Maretsikos, chrisgrelec@sch.gr. 9 10 */ 10 11 11 12 … … 30 31 // implementation in the future 31 32 enum dead_key_index { 32 33 kDeadKeyAcute = 1, 34 kDeadKeyAcuteSmooth, 35 kDeadKeyAcuteRough, 36 kDeadKeyAcuteDiaeresis, 37 kDeadKeyAcuteSubscript, 38 kDeadKeyAcuteSmoothSubscript, 39 kDeadKeyAcuteRoughSubscript, 33 40 kDeadKeyGrave, 41 kDeadKeyGraveSmooth, 42 kDeadKeyGraveRough, 43 kDeadKeyGraveDiaeresis, 44 kDeadKeyGraveSubscript, 45 kDeadKeyGraveSmoothSubscript, 46 kDeadKeyGraveRoughSubscript, 47 kDeadKeySmooth, 48 kDeadKeySmoothCircumflex, 49 kDeadKeySmoothSubscript, 50 kDeadKeySmoothCircumflexSubscript, 51 kDeadKeyRough, 52 kDeadKeyRoughCircumflex, 53 kDeadKeyRoughSubscript, 54 kDeadKeyRoughCircumflexSubscript, 34 55 kDeadKeyCircumflex, 56 kDeadKeyCircumflexDiaeresis, 57 kDeadKeyCircumflexSubscript, 35 58 kDeadKeyDiaeresis, 36 kDeadKeyTilde 59 kDeadKeyDiaeresisAccent, 60 kDeadKeyTilde, 61 kDeadKeyAccent, 62 kDeadKeyMacron, 63 kDeadKeyBreve, 64 kDeadKeySubscript 37 65 }; 38 66 39 67 … … BKeymap::DeadKey(uint32 keyCode, uint32 275 303 if (deadKeyIndex > 0 && _isEnabled != NULL) { 276 304 uint32 deadTables[] = { 277 305 fKeys.acute_tables, 306 fKeys.acutesmooth_tables, 307 fKeys.acuterough_tables, 308 fKeys.acutediaeresis_tables, 309 fKeys.acutesubscript_tables, 310 fKeys.acutesmoothsubscript_tables, 311 fKeys.acuteroughsubscript_tables, 278 312 fKeys.grave_tables, 313 fKeys.gravesmooth_tables, 314 fKeys.graverough_tables, 315 fKeys.gravediaeresis_tables, 316 fKeys.gravesubscript_tables, 317 fKeys.gravesmoothsubscript_tables, 318 fKeys.graveroughsubscript_tables, 319 fKeys.smooth_tables, 320 fKeys.smoothcircumflex_tables, 321 fKeys.smoothsubscript_tables, 322 fKeys.smoothcircumflexsubscript_tables, 323 fKeys.rough_tables, 324 fKeys.roughcircumflex_tables, 325 fKeys.roughsubscript_tables, 326 fKeys.roughcircumflexsubscript_tables, 279 327 fKeys.circumflex_tables, 328 fKeys.circumflexdiaeresis_tables, 329 fKeys.circumflexsubscript_tables, 280 330 fKeys.dieresis_tables, 281 fKeys.tilde_tables 331 fKeys.diaeresisaccent_tables, 332 fKeys.tilde_tables, 333 fKeys.accent_tables, 334 fKeys.macron_tables, 335 fKeys.breve_tables, 336 fKeys.subscript_tables 282 337 }; 283 338 *_isEnabled = (deadTables[deadKeyIndex - 1] & tableMask) != 0; 284 339 } … … BKeymap::IsDeadSecondKey(uint32 keyCode, 305 360 306 361 const int32* deadOffsets[] = { 307 362 fKeys.acute_dead_key, 363 fKeys.acutesmooth_dead_key, 364 fKeys.acuterough_dead_key, 365 fKeys.acutediaeresis_dead_key, 366 fKeys.acutesubscript_dead_key, 367 fKeys.acutesmoothsubscript_dead_key, 368 fKeys.acuteroughsubscript_dead_key, 308 369 fKeys.grave_dead_key, 370 fKeys.gravesmooth_dead_key, 371 fKeys.graverough_dead_key, 372 fKeys.gravediaeresis_dead_key, 373 fKeys.gravesubscript_dead_key, 374 fKeys.gravesmoothsubscript_dead_key, 375 fKeys.graveroughsubscript_dead_key, 376 fKeys.smooth_dead_key, 377 fKeys.smoothcircumflex_dead_key, 378 fKeys.smoothsubscript_dead_key, 379 fKeys.smoothcircumflexsubscript_dead_key, 380 fKeys.rough_dead_key, 381 fKeys.roughcircumflex_dead_key, 382 fKeys.roughsubscript_dead_key, 383 fKeys.roughcircumflexsubscript_dead_key, 309 384 fKeys.circumflex_dead_key, 385 fKeys.circumflexdiaeresis_dead_key, 386 fKeys.circumflexsubscript_dead_key, 310 387 fKeys.dieresis_dead_key, 311 fKeys.tilde_dead_key 388 fKeys.diaeresisaccent_dead_key, 389 fKeys.tilde_dead_key, 390 fKeys.accent_dead_key, 391 fKeys.macron_dead_key, 392 fKeys.breve_dead_key, 393 fKeys.subscript_dead_key 312 394 }; 313 395 314 396 const int32* deadOffset = deadOffsets[activeDeadKey - 1]; 315 397 316 for (int32 i = 0; i < 3 2; i++) {398 for (int32 i = 0; i < 38; i++) { 317 399 if (offset == deadOffset[i]) 318 400 return true; 319 401 … … BKeymap::GetChars(uint32 keyCode, uint32 386 468 case kDeadKeyAcute: 387 469 deadKey = fKeys.acute_dead_key; 388 470 break; 471 case kDeadKeyAcuteSmooth: 472 deadKey = fKeys.acutesmooth_dead_key; 473 break; 474 case kDeadKeyAcuteRough: 475 deadKey = fKeys.acuterough_dead_key; 476 break; 477 case kDeadKeyAcuteDiaeresis: 478 deadKey = fKeys.acutediaeresis_dead_key; 479 break; 480 case kDeadKeyAcuteSubscript: 481 deadKey = fKeys.acutesubscript_dead_key; 482 break; 483 case kDeadKeyAcuteSmoothSubscript: 484 deadKey = fKeys.acutesmoothsubscript_dead_key; 485 break; 486 case kDeadKeyAcuteRoughSubscript: 487 deadKey = fKeys.acuteroughsubscript_dead_key; 488 break; 389 489 case kDeadKeyGrave: 390 490 deadKey = fKeys.grave_dead_key; 391 491 break; 492 case kDeadKeyGraveSmooth: 493 deadKey = fKeys.gravesmooth_dead_key; 494 break; 495 case kDeadKeyGraveRough: 496 deadKey = fKeys.graverough_dead_key; 497 break; 498 case kDeadKeyGraveDiaeresis: 499 deadKey = fKeys.gravediaeresis_dead_key; 500 break; 501 case kDeadKeyGraveSubscript: 502 deadKey = fKeys.gravesubscript_dead_key; 503 break; 504 case kDeadKeyGraveSmoothSubscript: 505 deadKey = fKeys.gravesmoothsubscript_dead_key; 506 break; 507 case kDeadKeyGraveRoughSubscript: 508 deadKey = fKeys.graveroughsubscript_dead_key; 509 break; 510 case kDeadKeySmooth: 511 deadKey = fKeys.smooth_dead_key; 512 break; 513 case kDeadKeySmoothCircumflex: 514 deadKey = fKeys.smoothcircumflex_dead_key; 515 break; 516 case kDeadKeySmoothSubscript: 517 deadKey = fKeys.smoothsubscript_dead_key; 518 break; 519 case kDeadKeySmoothCircumflexSubscript: 520 deadKey = fKeys.smoothcircumflexsubscript_dead_key; 521 break; 522 case kDeadKeyRough: 523 deadKey = fKeys.rough_dead_key; 524 break; 525 case kDeadKeyRoughCircumflex: 526 deadKey = fKeys.roughcircumflex_dead_key; 527 break; 528 case kDeadKeyRoughSubscript: 529 deadKey = fKeys.roughsubscript_dead_key; 530 break; 531 case kDeadKeyRoughCircumflexSubscript: 532 deadKey = fKeys.roughcircumflexsubscript_dead_key; 533 break; 392 534 case kDeadKeyCircumflex: 393 535 deadKey = fKeys.circumflex_dead_key; 394 536 break; 537 case kDeadKeyCircumflexDiaeresis: 538 deadKey = fKeys.circumflexdiaeresis_dead_key; 539 break; 540 case kDeadKeyCircumflexSubscript: 541 deadKey = fKeys.circumflexsubscript_dead_key; 542 break; 395 543 case kDeadKeyDiaeresis: 396 544 deadKey = fKeys.dieresis_dead_key; 397 545 break; 546 case kDeadKeyDiaeresisAccent: 547 deadKey = fKeys.diaeresisaccent_dead_key; 548 break; 398 549 case kDeadKeyTilde: 399 550 deadKey = fKeys.tilde_dead_key; 400 551 break; 552 case kDeadKeyAccent: 553 deadKey = fKeys.accent_dead_key; 554 break; 555 case kDeadKeyMacron: 556 deadKey = fKeys.macron_dead_key; 557 break; 558 case kDeadKeyBreve: 559 deadKey = fKeys.breve_dead_key; 560 break; 561 case kDeadKeySubscript: 562 deadKey = fKeys.subscript_dead_key; 563 break; 401 564 default: 402 565 { 403 566 // if not dead, we copy and return the char … … BKeymap::GetChars(uint32 keyCode, uint32 410 573 411 574 // if dead key, we search for our current offset char in the dead key 412 575 // offset table string comparison is needed 413 for (int32 i = 0; i < 3 2; i++) {576 for (int32 i = 0; i < 38; i++) { 414 577 if (strncmp(&fChars[offset + 1], &fChars[deadKey[i] + 1], *numBytes) 415 578 == 0) { 416 579 *numBytes = fChars[deadKey[i + 1]]; … … BKeymap::DeadKeyIndex(int32 offset) cons 539 702 if (!numBytes || numBytes > 4) 540 703 return 0; 541 704 542 char chars[ 5];705 char chars[32]; 543 706 strncpy(chars, &fChars[offset + 1], numBytes); 544 707 chars[numBytes] = 0; 545 708 546 709 const int32 deadOffsets[] = { 547 710 fKeys.acute_dead_key[1], 711 fKeys.acutesmooth_dead_key[1], 712 fKeys.acuterough_dead_key[1], 713 fKeys.acutediaeresis_dead_key[1], 714 fKeys.acutesubscript_dead_key[1], 715 fKeys.acutesmoothsubscript_dead_key[1], 716 fKeys.acuteroughsubscript_dead_key[1], 548 717 fKeys.grave_dead_key[1], 718 fKeys.gravesmooth_dead_key[1], 719 fKeys.graverough_dead_key[1], 720 fKeys.gravediaeresis_dead_key[1], 721 fKeys.gravesubscript_dead_key[1], 722 fKeys.gravesmoothsubscript_dead_key[1], 723 fKeys.graveroughsubscript_dead_key[1], 724 fKeys.smooth_dead_key[1], 725 fKeys.smoothcircumflex_dead_key[1], 726 fKeys.smoothsubscript_dead_key[1], 727 fKeys.smoothcircumflexsubscript_dead_key[1], 728 fKeys.rough_dead_key[1], 729 fKeys.roughcircumflex_dead_key[1], 730 fKeys.roughsubscript_dead_key[1], 731 fKeys.roughcircumflexsubscript_dead_key[1], 549 732 fKeys.circumflex_dead_key[1], 733 fKeys.circumflexdiaeresis_dead_key[1], 734 fKeys.circumflexsubscript_dead_key[1], 550 735 fKeys.dieresis_dead_key[1], 551 fKeys.tilde_dead_key[1] 736 fKeys.diaeresisaccent_dead_key[1], 737 fKeys.tilde_dead_key[1], 738 fKeys.accent_dead_key[1], 739 fKeys.macron_dead_key[1], 740 fKeys.breve_dead_key[1], 741 fKeys.subscript_dead_key[1] 552 742 }; 553 743 554 744 uint8 result = 0; 555 for (int32 i = 0; i < 5; i++) {745 for (int32 i = 0; i < 32; i++) { 556 746 if (offset == deadOffsets[i]) 557 747 return i + 1; 558 748