Changeset 14017 in josm for trunk


Ignore:
Timestamp:
2018-07-08T15:11:49+02:00 (6 years ago)
Author:
Don-vip
Message:

see #16453 - support dead keys. Drop ancient Polish keyboards not used anymore

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/KeyboardUtils.java

    r14016 r14017  
    181181                } else if (!"LU".equals(l.getCountry())) {
    182182                    // France and Belgium, https://en.wikipedia.org/wiki/AZERTY
    183                     result.add('²'); // 10000B2
     183                    result.add('²');
    184184                }
    185185                // BÉPO, https://en.wikipedia.org/wiki/Keyboard_layout#B%C3%89PO
     
    202202            case "de": // German
    203203                // https://en.wikipedia.org/wiki/German_keyboard_layout
    204                 result.add('^');
     204                result.add((char) KeyEvent.VK_DEAD_CIRCUMFLEX);
    205205                break;
    206206            case "cs": // Czech
     
    213213                // Hungary, https://en.wikipedia.org/wiki/QWERTZ#Hungary
    214214                result.add('0');
    215                 break;
    216             case "pl": // Polish
    217                 // Poland, https://en.wikipedia.org/wiki/QWERTZ#Poland
    218                 result.add('µ');
    219                 result.add('^');
    220                 result.add('˛'); // https://en.wikipedia.org/wiki/Ogonek
    221215                break;
    222216            case "bs": // Bosnian
     
    243237            case "et": // Estonian
    244238                // https://en.wikipedia.org/wiki/QWERTY#Estonian
    245                 result.add('ˇ'); // https://en.wikipedia.org/wiki/Caron
     239                result.add((char) KeyEvent.VK_DEAD_CARON); // https://en.wikipedia.org/wiki/Caron
    246240                break;
    247241            case "is": // Icelandic
    248242                // https://en.wikipedia.org/wiki/Icelandic_keyboard_layout
    249243                result.add('°'); // https://en.wikipedia.org/wiki/Ring_(diacritic)
     244                // FIXME It doesn't work with Java 8: [KEY_PRESSED,keyCode=0,keyChar=Undefined keyChar,extendedKeyCode=0x0]
    250245                break;
    251246            case "es": // Spanish
     
    290285                // https://en.wikipedia.org/wiki/QWERTY#Spain,_also_known_as_Spanish_(International_sort)
    291286                result.add('º'); // https://en.wikipedia.org/wiki/Ordinal_indicator
     287                // FIXME It doesn't work with Java 8: [KEY_PRESSED,keyCode=0,keyChar=Undefined keyChar,extendedKeyCode=0x0]
    292288                break;
    293289            default:
     
    303299            // Add default US QWERTY keys, https://en.wikipedia.org/wiki/QWERTY
    304300            // Works also for Dvorak, https://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard
    305             result.add('`');
    306             result.add('~');
     301            result.add('`'); // On US QWERTY, this is not a dead key
     302            result.add((char) KeyEvent.VK_DEAD_GRAVE); // On International QWERTY, this is a dead key
    307303            return result;
    308304        }
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r14013 r14017  
    462462                    new StringBuilder(shortText).append(" (").append(i).append(')').toString(), longText,
    463463                    // Add extended keyCode if not a regular one
    464                     regularKeyCodes.containsKey(code) ? regularKeyCodes.get(code) : c | KeyboardUtils.EXTENDED_KEYCODE_FLAG,
     464                    regularKeyCodes.containsKey(code) ? regularKeyCodes.get(code) :
     465                        isDeadKey(code) ? code : c | KeyboardUtils.EXTENDED_KEYCODE_FLAG,
    465466                    requestedGroup));
    466467            i++;
    467468        }
    468469        return result;
     470    }
     471
     472    static boolean isDeadKey(int keyCode) {
     473        return KeyEvent.VK_DEAD_GRAVE <= keyCode && keyCode <= KeyEvent.VK_DEAD_SEMIVOICED_SOUND;
    469474    }
    470475
  • trunk/test/unit/org/openstreetmap/josm/tools/KeyboardUtilsTest.java

    r14012 r14017  
    44import static org.junit.Assert.assertEquals;
    55
     6import java.awt.event.KeyEvent;
    67import java.util.Arrays;
    78import java.util.LinkedHashMap;
     
    5354    @Test
    5455    public void testgetCharactersForKeyE00() {
    55         testgetCharactersForKeyE00("ar", 'ذ', '>', '`', '~');
    56         testgetCharactersForKeyE00("fr_FR", '²', '$', '`', '~');
    57         testgetCharactersForKeyE00("fr_CA", '#', '$', '/', '`', '~');
    58         testgetCharactersForKeyE00("sq", '\\', '`', '~');
    59         testgetCharactersForKeyE00("it", '\\', '`', '~');
    60         testgetCharactersForKeyE00("pt", '\\', '`', '~');
    61         testgetCharactersForKeyE00("pt_BR", '\'', '`', '~');
    62         testgetCharactersForKeyE00("de", '^', '`', '~');
    63         testgetCharactersForKeyE00("cs", ';', '`', '~');
    64         testgetCharactersForKeyE00("he", '`', '~');
    65         testgetCharactersForKeyE00("hu", '0', '`', '~');
    66         testgetCharactersForKeyE00("pl", 'µ', '^', '˛', '`', '~');
    67         testgetCharactersForKeyE00("bs", '¸', '`', '~');
    68         testgetCharactersForKeyE00("hr", '¸', '`', '~');
    69         testgetCharactersForKeyE00("sl", '¸', '`', '~');
    70         testgetCharactersForKeyE00("sr", '¸', '`', '~');
    71         testgetCharactersForKeyE00("ro", ']', '`', '~');
    72         testgetCharactersForKeyE00("da", '½', '`', '~');
    73         testgetCharactersForKeyE00("fo", '½', '`', '~');
    74         testgetCharactersForKeyE00("nl", '@', '`', '~');
    75         testgetCharactersForKeyE00("et", 'ˇ', '`', '~');
    76         testgetCharactersForKeyE00("is", '°', '`', '~');
    77         testgetCharactersForKeyE00("es", '|', '`', '~');
    78         testgetCharactersForKeyE00("es_ES", 'º', '`', '~');
    79         testgetCharactersForKeyE00("tr", '"', '*', '`', '~');
    80         testgetCharactersForKeyE00("de_LU", '^', '²', '§', '`', '~');
    81         testgetCharactersForKeyE00("fr_LU", '$', '²', '§', '`', '~');
    82         testgetCharactersForKeyE00("de_CH", '^', '§', '`', '~');
    83         testgetCharactersForKeyE00("fr_CH", '²', '$', '§', '`', '~');
    84         testgetCharactersForKeyE00("de_LI", '^', '§', '`', '~');
    85         testgetCharactersForKeyE00("fi_FI", '§', '`', '~');
    86         testgetCharactersForKeyE00("sv_SE", '§', '`', '~');
    87         testgetCharactersForKeyE00("no_NO", '|', '`', '~');
    88         testgetCharactersForKeyE00("sv_NO", '|', '`', '~');
     56        char deadCircumflex = (char) KeyEvent.VK_DEAD_CIRCUMFLEX;
     57        char deadGrave = (char) KeyEvent.VK_DEAD_GRAVE;
     58        char deadCaron = (char) KeyEvent.VK_DEAD_CARON;
     59        testgetCharactersForKeyE00("ar", 'ذ', '>', '`', deadGrave);
     60        testgetCharactersForKeyE00("fr_FR", '²', '$', '`', deadGrave);
     61        testgetCharactersForKeyE00("fr_CA", '#', '$', '/', '`', deadGrave);
     62        testgetCharactersForKeyE00("sq", '\\', '`', deadGrave);
     63        testgetCharactersForKeyE00("it", '\\', '`', deadGrave);
     64        testgetCharactersForKeyE00("pt", '\\', '`', deadGrave);
     65        testgetCharactersForKeyE00("pt_BR", '\'', '`', deadGrave);
     66        testgetCharactersForKeyE00("de", deadCircumflex, '`', deadGrave);
     67        testgetCharactersForKeyE00("cs", ';', '`', deadGrave);
     68        testgetCharactersForKeyE00("he", '`', deadGrave);
     69        testgetCharactersForKeyE00("hu", '0', '`', deadGrave);
     70        testgetCharactersForKeyE00("pl", '`', deadGrave);
     71        testgetCharactersForKeyE00("bs", '¸', '`', deadGrave);
     72        testgetCharactersForKeyE00("hr", '¸', '`', deadGrave);
     73        testgetCharactersForKeyE00("sl", '¸', '`', deadGrave);
     74        testgetCharactersForKeyE00("sr", '¸', '`', deadGrave);
     75        testgetCharactersForKeyE00("ro", ']', '`', deadGrave);
     76        testgetCharactersForKeyE00("da", '½', '`', deadGrave);
     77        testgetCharactersForKeyE00("fo", '½', '`', deadGrave);
     78        testgetCharactersForKeyE00("nl", '@', '`', deadGrave);
     79        testgetCharactersForKeyE00("et", deadCaron, '`', deadGrave);
     80        testgetCharactersForKeyE00("is", '°', '`', deadGrave);
     81        testgetCharactersForKeyE00("es", '|', '`', deadGrave);
     82        testgetCharactersForKeyE00("es_ES", 'º', '`', deadGrave);
     83        testgetCharactersForKeyE00("tr", '"', '*', '`', deadGrave);
     84        testgetCharactersForKeyE00("de_LU", deadCircumflex, '²', '§', '`', deadGrave);
     85        testgetCharactersForKeyE00("fr_LU", '$', '²', '§', '`', deadGrave);
     86        testgetCharactersForKeyE00("fr_CH", '²', '$', '§', '`', deadGrave);
     87        testgetCharactersForKeyE00("de_CH", deadCircumflex, '§', '`', deadGrave);
     88        testgetCharactersForKeyE00("de_LI", deadCircumflex, '§', '`', deadGrave);
     89        testgetCharactersForKeyE00("fi_FI", '§', '`', deadGrave);
     90        testgetCharactersForKeyE00("sv_SE", '§', '`', deadGrave);
     91        testgetCharactersForKeyE00("no_NO", '|', '`', deadGrave);
     92        testgetCharactersForKeyE00("sv_NO", '|', '`', deadGrave);
    8993    }
    9094
Note: See TracChangeset for help on using the changeset viewer.