forked from extern/Unexpected-Keyboard
Compare commits
3 Commits
master
...
combining_
Author | SHA1 | Date | |
---|---|---|---|
|
3591881b14 | ||
|
4c0c1fa13b | ||
|
9a44ecf4e2 |
@ -11,15 +11,5 @@
|
||||
"u": "ú",
|
||||
"y": "ý",
|
||||
"z": "ź",
|
||||
"ü": "ǘ",
|
||||
"j": "j\u0301",
|
||||
"у": "у\u0301",
|
||||
"е": "е\u0301",
|
||||
"а": "а\u0301",
|
||||
"о": "о\u0301",
|
||||
"и": "и\u0301",
|
||||
"ы": "ы\u0301",
|
||||
"э": "э\u0301",
|
||||
"ю": "ю\u0301",
|
||||
"я": "я\u0301"
|
||||
"ü": "ǘ"
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
{
|
||||
"o": "ő",
|
||||
"u": "ű",
|
||||
" ": "˝",
|
||||
"a": "a\u030b",
|
||||
"e": "e\u030b",
|
||||
"i": "i\u030b",
|
||||
"m": "m\u030b",
|
||||
"y": "y\u030b"
|
||||
" ": "˝"
|
||||
}
|
||||
|
Binary file not shown.
@ -2,6 +2,7 @@ package juloo.keyboard2;
|
||||
|
||||
import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class KeyModifier
|
||||
@ -58,7 +59,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');
|
||||
@ -69,7 +70,7 @@ public final class KeyModifier
|
||||
case OGONEK: return apply_compose_or_dead_char(k, ComposeKeyData.accent_ogonek, '\u02DB');
|
||||
case DOT_ABOVE: return apply_compose_or_dead_char(k, ComposeKeyData.accent_dot_above, '\u02D9');
|
||||
case BREVE: return apply_dead_char(k, '\u02D8');
|
||||
case DOUBLE_AIGU: return apply_compose(k, ComposeKeyData.accent_double_aigu);
|
||||
case DOUBLE_AIGU: return apply_diacritics(k, ComposeKeyData.accent_double_aigu, '\0', '\u030b');
|
||||
case ORDINAL: return apply_compose(k, ComposeKeyData.accent_ordinal);
|
||||
case SUPERSCRIPT: return apply_compose(k, ComposeKeyData.accent_superscript);
|
||||
case SUBSCRIPT: return apply_compose(k, ComposeKeyData.accent_subscript);
|
||||
@ -131,43 +132,51 @@ 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'].
|
||||
This is not done if the initial key matches [combining_disabled]. */
|
||||
private static KeyValue apply_diacritics(KeyValue k, int state, char dead_char, char combining)
|
||||
{
|
||||
switch (k.getKind())
|
||||
{
|
||||
case Char:
|
||||
char c = k.getChar();
|
||||
KeyValue r = ComposeKey.apply(state, c);
|
||||
if (r != null)
|
||||
return r;
|
||||
if (state != 0)
|
||||
{
|
||||
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' && !combining_disabled(c))
|
||||
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)
|
||||
{
|
||||
switch (k.getKind())
|
||||
{
|
||||
case Char:
|
||||
KeyValue r = ComposeKey.apply(state, k.getChar());
|
||||
if (r != null)
|
||||
return r;
|
||||
}
|
||||
return k;
|
||||
return apply_diacritics(k, state, '\0', '\0');
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
return k;
|
||||
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)
|
||||
@ -806,4 +815,18 @@ public final class KeyModifier
|
||||
}
|
||||
return KeyValue.makeHangulFinal(precomposed, final_idx);
|
||||
}
|
||||
|
||||
/** Characters for which combining diacritics should not be appeneded. */
|
||||
private static final char[] combining_disabled_chars =
|
||||
"0123456789@`!\"#$%&'()*:+;[{,<\\|-=]}.>^~/?_ \t\n¡¿«»‹›‘’“”‚„–—¬‰≈°…·¦¶‡∙€£₹¥¢₽₱₴₿".toCharArray();
|
||||
|
||||
static
|
||||
{
|
||||
Arrays.sort(combining_disabled_chars);
|
||||
}
|
||||
|
||||
private static boolean combining_disabled(char c)
|
||||
{
|
||||
return (Arrays.binarySearch(combining_disabled_chars, c) >= 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user