forked from extern/Unexpected-Keyboard
Apply combining diacritic for accent aigu
Any characters that were not affected by the compose or the dead char mappings are now outputted with a combining diacritic when enabling the accent aigu.
This commit is contained in:
parent
db3b021bfc
commit
9a44ecf4e2
@ -11,15 +11,5 @@
|
||||
"u": "ú",
|
||||
"y": "ý",
|
||||
"z": "ź",
|
||||
"ü": "ǘ",
|
||||
"j": "j\u0301",
|
||||
"у": "у\u0301",
|
||||
"е": "е\u0301",
|
||||
"а": "а\u0301",
|
||||
"о": "о\u0301",
|
||||
"и": "и\u0301",
|
||||
"ы": "ы\u0301",
|
||||
"э": "э\u0301",
|
||||
"ю": "ю\u0301",
|
||||
"я": "я\u0301"
|
||||
"ü": "ǘ"
|
||||
}
|
||||
|
Binary file not shown.
@ -58,7 +58,7 @@ public final class KeyModifier
|
||||
case GESTURE: return apply_gesture(k);
|
||||
case SHIFT: return apply_shift(k);
|
||||
case GRAVE: return apply_compose_or_dead_char(k, ComposeKeyData.accent_grave, '\u02CB');
|
||||
case AIGU: return apply_compose_or_dead_char(k, ComposeKeyData.accent_aigu, '\u00B4');
|
||||
case AIGU: return apply_diacritics(k, ComposeKeyData.accent_aigu, '\u00B4', '\u0301');
|
||||
case CIRCONFLEXE: return apply_compose_or_dead_char(k, ComposeKeyData.accent_circonflexe, '\u02C6');
|
||||
case TILDE: return apply_compose_or_dead_char(k, ComposeKeyData.accent_tilde, '\u02DC');
|
||||
case CEDILLE: return apply_compose_or_dead_char(k, ComposeKeyData.accent_cedille, '\u00B8');
|
||||
@ -131,45 +131,52 @@ public final class KeyModifier
|
||||
return k;
|
||||
}
|
||||
|
||||
/** Apply the given compose state or fallback to the dead_char. */
|
||||
private static KeyValue apply_compose_or_dead_char(KeyValue k, int state, char dead_char)
|
||||
/** Apply the following mapping, in this order, and stop at the first that
|
||||
changes the key.
|
||||
|
||||
- The compose state, unless it is [0].
|
||||
- The dead char, unless it is ['\0'].
|
||||
- The combining diacritic, unless it is ['\0']. */
|
||||
private static KeyValue apply_diacritics(KeyValue k, int state, char dead_char, char combining)
|
||||
{
|
||||
switch (k.getKind())
|
||||
{
|
||||
case Char:
|
||||
char c = k.getChar();
|
||||
if (state != 0)
|
||||
{
|
||||
KeyValue r = ComposeKey.apply(state, c);
|
||||
if (r != null)
|
||||
return r;
|
||||
}
|
||||
return apply_dead_char(k, dead_char);
|
||||
}
|
||||
|
||||
private static KeyValue apply_compose(KeyValue k, int state)
|
||||
if (dead_char != '\0')
|
||||
{
|
||||
switch (k.getKind())
|
||||
{
|
||||
case Char:
|
||||
KeyValue r = ComposeKey.apply(state, k.getChar());
|
||||
if (r != null)
|
||||
return r;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
private static KeyValue apply_dead_char(KeyValue k, char dead_char)
|
||||
{
|
||||
switch (k.getKind())
|
||||
{
|
||||
case Char:
|
||||
char c = k.getChar();
|
||||
char modified = (char)KeyCharacterMap.getDeadChar(dead_char, c);
|
||||
if (modified != 0 && modified != c)
|
||||
return KeyValue.makeStringKey(String.valueOf(modified));
|
||||
}
|
||||
if (combining != '\0')
|
||||
return KeyValue.makeStringKey(new String(new char[]{ c, combining }));
|
||||
break;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
private static KeyValue apply_compose(KeyValue k, int state)
|
||||
{
|
||||
return apply_diacritics(k, state, '\0', '\0');
|
||||
}
|
||||
|
||||
private static KeyValue apply_dead_char(KeyValue k, char dead_char)
|
||||
{
|
||||
return apply_diacritics(k, 0, dead_char, '\0');
|
||||
}
|
||||
|
||||
private static KeyValue apply_compose_or_dead_char(KeyValue k, int state, char dead_char)
|
||||
{
|
||||
return apply_diacritics(k, state, dead_char, '\0');
|
||||
}
|
||||
|
||||
private static KeyValue apply_shift(KeyValue k)
|
||||
{
|
||||
if (_modmap != null)
|
||||
|
Loading…
Reference in New Issue
Block a user