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": "ú",
|
"u": "ú",
|
||||||
"y": "ý",
|
"y": "ý",
|
||||||
"z": "ź",
|
"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 GESTURE: return apply_gesture(k);
|
||||||
case SHIFT: return apply_shift(k);
|
case SHIFT: return apply_shift(k);
|
||||||
case GRAVE: return apply_compose_or_dead_char(k, ComposeKeyData.accent_grave, '\u02CB');
|
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 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 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');
|
case CEDILLE: return apply_compose_or_dead_char(k, ComposeKeyData.accent_cedille, '\u00B8');
|
||||||
@ -131,43 +131,50 @@ public final class KeyModifier
|
|||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Apply the given compose state or fallback to the dead_char. */
|
/** Apply the following mapping, in this order, and stop at the first that
|
||||||
private static KeyValue apply_compose_or_dead_char(KeyValue k, int state, char dead_char)
|
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())
|
switch (k.getKind())
|
||||||
{
|
{
|
||||||
case Char:
|
case Char:
|
||||||
char c = k.getChar();
|
char c = k.getChar();
|
||||||
KeyValue r = ComposeKey.apply(state, c);
|
if (state != 0)
|
||||||
if (r != null)
|
{
|
||||||
return r;
|
KeyValue r = ComposeKey.apply(state, c);
|
||||||
|
if (r != null)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
if (dead_char != '\0')
|
||||||
|
{
|
||||||
|
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 apply_dead_char(k, dead_char);
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KeyValue apply_compose(KeyValue k, int state)
|
private static KeyValue apply_compose(KeyValue k, int state)
|
||||||
{
|
{
|
||||||
switch (k.getKind())
|
return apply_diacritics(k, state, '\0', '\0');
|
||||||
{
|
|
||||||
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)
|
private static KeyValue apply_dead_char(KeyValue k, char dead_char)
|
||||||
{
|
{
|
||||||
switch (k.getKind())
|
return apply_diacritics(k, 0, dead_char, '\0');
|
||||||
{
|
}
|
||||||
case Char:
|
|
||||||
char c = k.getChar();
|
private static KeyValue apply_compose_or_dead_char(KeyValue k, int state, char dead_char)
|
||||||
char modified = (char)KeyCharacterMap.getDeadChar(dead_char, c);
|
{
|
||||||
if (modified != 0 && modified != c)
|
return apply_diacritics(k, state, dead_char, '\0');
|
||||||
return KeyValue.makeStringKey(String.valueOf(modified));
|
|
||||||
}
|
|
||||||
return k;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KeyValue apply_shift(KeyValue k)
|
private static KeyValue apply_shift(KeyValue k)
|
||||||
|
Loading…
Reference in New Issue
Block a user