Define the Shift modifier using the compose mechanism

This commit is contained in:
Jules Aguillon 2024-09-10 22:50:39 +02:00
parent b600332595
commit a8e331c322
3 changed files with 56 additions and 61 deletions

52
srcs/compose/shift.json Normal file
View File

@ -0,0 +1,52 @@
{
"↙": "⇙",
"↓": "⇓",
"↘": "⇘",
"←": "⇐",
"→": "⇒",
"↖": "⇖",
"↑": "⇑",
"↗": "⇗",
"└": "╚",
"┴": "╩",
"┘": "╝",
"├": "╠",
"┼": "╬",
"┤": "╣",
"┌": "╔",
"┬": "╦",
"┐": "╗",
"─": "═",
"│": "║",
"ß": "ẞ",
// In Turkish, upper case of 'iı' is 'İI' but Java's toUpperCase will
// return 'II'. To make 'İ' accessible, make it the shift of 'ı'. This
// has the inconvenient of swapping i and ı on the keyboard.
"ı": "İ",
"₹": "₨",
// Gujarati alternate characters
"અ": "આ",
"ઇ": "ઈ",
"િ": "ી",
"ઉ": "ઊ",
"ુ": "ૂ",
"એ": "ઐ",
"ે": "ૈ",
"ઓ": "ઔ",
"ો": "ૌ",
"ક": "ખ",
"ગ": "ઘ",
"ચ": "છ",
"જ": "ઝ",
"ટ": "ઠ",
"ડ": "ઢ",
"ન": "ણ",
"ત": "થ",
"દ": "ધ",
"પ": "ફ",
"બ": "ભ",
"મ": "ં",
"લ": "ળ",
"સ": "શ",
"હ": ""
}

View File

@ -182,9 +182,10 @@ public final class KeyModifier
{
case Char:
char kc = k.getChar();
char c = map_char_shift(kc);
if (kc == c)
c = Character.toUpperCase(kc);
KeyValue r = ComposeKey.apply(ComposeKeyData.shift, kc);
if (r != null)
return r;
char c = Character.toUpperCase(kc);
return (kc == c) ? k : k.withChar(c);
case String:
String s = Utils.capitalize_string(k.getString());
@ -366,64 +367,6 @@ public final class KeyModifier
public String apply(char _c) { return null; }
};
private static char map_char_shift(char c)
{
switch (c)
{
case '↙': return '⇙';
case '↓': return '⇓';
case '↘': return '⇘';
case '←': return '⇐';
case '→': return '⇒';
case '↖': return '⇖';
case '↑': return '⇑';
case '↗': return '⇗';
case '└': return '╚';
case '┴': return '╩';
case '┘': return '╝';
case '├': return '╠';
case '┼': return '╬';
case '┤': return '╣';
case '┌': return '╔';
case '┬': return '╦';
case '┐': return '╗';
case '─': return '═';
case '│': return '║';
case 'ß': return 'ẞ';
/* In Turkish, upper case of 'iı' is 'İI' but Java's toUpperCase will
return 'II'. To make 'İ' accessible, make it the shift of 'ı'. This
has the inconvenient of swapping i and ı on the keyboard. */
case 'ı': return 'İ';
case '₹': return '₨';
// Gujarati alternate characters
case 'અ': return 'આ';
case 'ઇ': return 'ઈ';
case 'િ': return 'ી';
case 'ઉ': return 'ઊ';
case 'ુ': return 'ૂ';
case 'એ': return 'ઐ';
case 'ે': return 'ૈ';
case 'ઓ': return 'ઔ';
case 'ો': return 'ૌ';
case 'ક': return 'ખ';
case 'ગ': return 'ઘ';
case 'ચ': return 'છ';
case 'જ': return 'ઝ';
case 'ટ': return 'ઠ';
case 'ડ': return 'ઢ';
case 'ન': return 'ણ';
case 'ત': return 'થ';
case 'દ': return 'ધ';
case 'પ': return 'ફ';
case 'બ': return 'ભ';
case 'મ': return 'ં';
case 'લ': return 'ળ';
case 'સ': return 'શ';
case 'હ': return '';
default: return c;
}
}
private static final Map_char map_char_arrow_right =
new Map_char() {
public String apply(char c)