Define the Fn modifier using the compose mechanism

This removes 100Kb from the app.
This commit is contained in:
Jules Aguillon 2024-09-10 22:43:40 +02:00
parent e734d1d0e2
commit b600332595
3 changed files with 185 additions and 188 deletions

182
srcs/compose/fn.json Normal file
View File

@ -0,0 +1,182 @@
{
"1": "f1",
"2": "f2",
"3": "f3",
"4": "f4",
"5": "f5",
"6": "f6",
"7": "f7",
"8": "f8",
"9": "f9",
"0": "f10",
"<": "«",
">": "»",
"{": "",
"}": "",
"[": "",
"]": "",
"(": "“",
")": "”",
"'": "",
"\"": "„",
"-": "",
"_": "—",
"^": "¬",
"%": "‰",
"=": "≈",
"u": "µ",
"a": "æ",
"o": "œ",
"*": "°",
".": "…",
",": "·",
"!": "¡",
"?": "¿",
"|": "¦",
"§": "¶",
"†": "‡",
"×": "∙",
" ": "nbsp",
// arrows
"↖": "⇖",
"↑": "⇑",
"↗": "⇗",
"←": "⇐",
"→": "⇒",
"↙": "⇙",
"↓": "⇓",
"↘": "⇘",
"↔": "⇔",
"↕": "⇕",
// Currency symbols
"e": "€",
"l": "£",
"r": "₹",
"y": "¥",
"c": "¢",
"p": "₽",
"b": "₱",
"h": "₴",
"z": "₿",
// avoid showing these twice
"€": "removed",
"£": "removed",
// alternative greek letters
"π": "ϖ",
"θ": "ϑ",
"Θ": "ϴ",
"ε": "ϵ",
"β": "ϐ",
"ρ": "ϱ",
"σ": "ς",
"γ": "ɣ",
"φ": "ϕ",
"υ": "ϒ",
"κ": "ϰ",
// alternative math characters
"": "",
"∩": "⋂",
"∃": "∄",
"∈": "∉",
"∫": "∮",
"Π": "∏",
"Σ": "∑",
"": "",
"∧": "⋀",
"⊷": "⊶",
"⊂": "⊆",
"⊃": "⊇",
"±": "∓",
// hebrew niqqud
"ק": "qamats", // kamatz
"ר": "hataf_qamats", // reduced kamatz
"ו": "holam",
"ם": "rafe",
"פ": "patah", // patach
"ש": "sheva",
"ד": "dagesh", // or mapiq
"ח": "hiriq",
"ף": "hataf_patah", // reduced patach
"ז": "qubuts", // kubuts
"ס": "segol",
"ב": "hataf_segol", // reduced segol
"צ": "tsere",
// Devanagari symbols
"ए": "ऍ",
"े": "ॅ",
"ऐ": "ऎ",
"ै": "ॆ",
"ऋ": "ॠ",
"ृ": "ॄ",
"ळ": "ऴ",
"र": "ऱ",
"क": "क़",
"ख": "ख़",
"ग": "ग़",
"घ": "ॻ",
"ढ": "ढ़",
"न": "ऩ",
"ड": "ड़",
"ट": "ॸ",
"ण": "ॾ",
"फ": "फ़",
"ऌ": "ॡ",
"ॢ": "ॣ",
"औ": "ॵ",
"ौ": "ॏ",
"ओ": "ऒ",
"ो": "ॊ",
"च": "ॼ",
"ज": "ज़",
"ब": "ॿ",
"व": "ॺ",
"य": "य़",
"अ": "ॲ",
"आ": "ऑ",
"ा": "ॉ",
"झ": "ॹ",
"ई": "ॴ",
"ी": "ऻ",
"इ": "ॳ",
"ि": "ऺ",
"उ": "ॶ",
"ऊ": "ॷ",
"ु": "ऄ",
"ष": "क्ष",
"थ": "त्र",
"द": "द्र",
"प": "प्र",
"श": "श्र",
"छ": "श्च",
"ँ": "ऀ",
"₹": "₨",
"ॖ": "ॗ",
"॓": "॔",
"॰": "ॱ",
"।": "॥",
"ं": "ॕ",
"़": "ॎ",
"ऽ": "",
// Persian numbers
"۱": "f1",
"۲": "f2",
"۳": "f3",
"۴": "f4",
"۵": "f5",
"۶": "f6",
"۷": "f7",
"۸": "f8",
"۹": "f9",
// Arabic numbers
"۰": "f10",
"١": "f1",
"٢": "f2",
"٣": "f3",
"٤": "f4",
"٥": "f5",
"٦": "f6",
"٧": "f7",
"٨": "f8",
"٩": "f9",
"٠": "f10"
}

View File

@ -204,7 +204,9 @@ public final class KeyModifier
String name = null;
switch (k.getKind())
{
case Char: name = apply_fn_char(k.getChar()); break;
case Char:
KeyValue r = ComposeKey.apply(ComposeKeyData.fn, k.getChar());
return (r != null) ? r : k;
case Keyevent: name = apply_fn_keyevent(k.getKeyevent()); break;
case Event: name = apply_fn_event(k.getEvent()); break;
case Placeholder: name = apply_fn_placeholder(k.getPlaceholder()); break;
@ -264,193 +266,6 @@ public final class KeyModifier
}
}
/** Return the name of modified key, or [null]. */
private static String apply_fn_char(char c)
{
switch (c)
{
case '1': return "f1";
case '2': return "f2";
case '3': return "f3";
case '4': return "f4";
case '5': return "f5";
case '6': return "f6";
case '7': return "f7";
case '8': return "f8";
case '9': return "f9";
case '0': return "f10";
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 'u': return "µ";
case 'a': return "æ";
case 'o': return "œ";
case '*': return "°";
case '.': return "";
case ',': return "·";
case '!': return "¡";
case '?': return "¿";
case '|': return "¦";
case '§': return "";
case '†': return "";
case '×': return "";
case ' ': return "nbsp";
// arrows
case '↖': return "";
case '↑': return "";
case '↗': return "";
case '←': return "";
case '→': return "";
case '↙': return "";
case '↓': return "";
case '↘': return "";
case '↔': return "";
case '↕': return "";
// Currency symbols
case 'e': return "";
case 'l': return "£";
case 'r': return "";
case 'y': return "¥";
case 'c': return "¢";
case 'p': return "";
case 'b': return "";
case 'h': return "";
case 'z': return "";
case '€': case '£': return "removed"; // Avoid showing these twice
// alternating greek letters
case 'π': return "ϖ";
case 'θ': return "ϑ";
case 'Θ': return "ϴ";
case 'ε': return "ϵ";
case 'β': return "ϐ";
case 'ρ': return "ϱ";
case 'σ': return "ς";
case 'γ': return "ɣ";
case 'φ': return "ϕ";
case 'υ': return "ϒ";
case 'κ': return "ϰ";
// alternating math 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 "";
// hebrew niqqud
case 'ק': return "qamats"; // kamatz
case 'ר': return "hataf_qamats"; // reduced kamatz
case 'ו': return "holam";
case 'ם': return "rafe";
case 'פ': return "patah"; // patach
case 'ש': return "sheva";
case 'ד': return "dagesh"; // or mapiq
case 'ח': return "hiriq";
case 'ף': return "hataf_patah"; // reduced patach
case 'ז': return "qubuts"; // kubuts
case 'ס': return "segol";
case 'ב': return "hataf_segol"; // reduced segol
case 'צ': return "tsere";
// Devanagari symbols
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 "";
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 "";
case 'ॖ': return "";
case '॓': return "";
case '॰': return "";
case '।': return "";
case 'ं': return "";
case '़': return "";
case 'ऽ': return "";
// Persian numbers
case '۱': return "f1";
case '۲': return "f2";
case '۳': return "f3";
case '۴': return "f4";
case '۵': return "f5";
case '۶': return "f6";
case '۷': return "f7";
case '۸': return "f8";
case '۹': return "f9";
case '۰': return "f10";
// Arabic numbers
case '١': return "f1";
case '٢': return "f2";
case '٣': return "f3";
case '٤': return "f4";
case '٥': return "f5";
case '٦': return "f6";
case '٧': return "f7";
case '٨': return "f8";
case '٩': return "f9";
case '٠': return "f10";
default: return null;
}
}
private static KeyValue apply_ctrl(KeyValue k)
{
if (_modmap != null)