From 2dda39f453854a9e9e139131039d57d7c79e26cb Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 2 Apr 2022 10:42:40 -0400 Subject: [PATCH] `Arrows` and `Box` system (#114) * Add `Arrows` and `Box` accent system --- res/xml/numeric.xml | 16 +++---- res/xml/settings.xml | 1 + srcs/juloo.keyboard2/Config.java | 3 +- srcs/juloo.keyboard2/KeyModifier.java | 68 +++++++++++++++++++++++++++ srcs/juloo.keyboard2/KeyValue.java | 7 ++- 5 files changed, 85 insertions(+), 10 deletions(-) diff --git a/res/xml/numeric.xml b/res/xml/numeric.xml index 348ada1..2ded41c 100644 --- a/res/xml/numeric.xml +++ b/res/xml/numeric.xml @@ -3,26 +3,26 @@ - - - + + + - + - + - - - + + + diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 6a76486..a3d4957 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -17,6 +17,7 @@ + diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index ab2d13a..3c436c3 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -126,7 +126,8 @@ final class Config | (prefs.getBoolean("lockable_fn", false) ? KeyValue.FLAG_FN : 0) | (prefs.getBoolean("lockable_meta", false) ? KeyValue.FLAG_META : 0) | (prefs.getBoolean("lockable_sup", false) ? KeyValue.FLAG_ACCENT_SUPERSCRIPT : 0) - | (prefs.getBoolean("lockable_sub", false) ? KeyValue.FLAG_ACCENT_SUBSCRIPT : 0); + | (prefs.getBoolean("lockable_sub", false) ? KeyValue.FLAG_ACCENT_SUBSCRIPT : 0) + | (prefs.getBoolean("lockable_box", false) ? KeyValue.FLAG_ACCENT_BOX : 0); characterSize = prefs.getFloat("character_size", characterSize); accents = Integer.valueOf(prefs.getString("accents", "1")); theme = getThemeId(res, prefs.getString("theme", "")); diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 58355c1..dc81195 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -139,6 +139,74 @@ class KeyModifier case 'o': return 'ₒ'; default: return c; } + case KeyValue.FLAG_ACCENT_ARROWS: + if ((flags & KeyValue.FLAG_SHIFT) == 0) + { + switch (c) + { + case '1': return '↙'; + case '2': return '↓'; + case '3': return '↘'; + case '4': return '←'; + case '6': return '→'; + case '7': return '↖'; + case '8': return '↑'; + case '9': return '↗'; + default: return c; + } + } + else + { + switch (c) + { + case '1': return '⇙'; + case '2': return '⇓'; + case '3': return '⇘'; + case '4': return '⇐'; + case '6': return '⇒'; + case '7': return '⇖'; + case '8': return '⇑'; + case '9': return '⇗'; + default: return c; + } + } + case KeyValue.FLAG_ACCENT_BOX: + if ((flags & KeyValue.FLAG_SHIFT) == 0) + { + switch (c) + { + case '1': return '└'; + case '2': return '┴'; + case '3': return '┘'; + case '4': return '├'; + case '5': return '┼'; + case '6': return '┤'; + case '7': return '┌'; + case '8': return '┬'; + case '9': return '┐'; + case '0': return '─'; + case '.': return '│'; + default: return c; + } + } + else + { + switch (c) + { + case '1': return '╚'; + case '2': return '╩'; + case '3': return '╝'; + case '4': return '╠'; + case '5': return '╬'; + case '6': return '╣'; + case '7': return '╔'; + case '8': return '╦'; + case '9': return '╗'; + case '0': return '═'; + case '.': return '║'; + default: return c; + } + } default: return c; // Can't happen } } diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 74d21aa..2b632e5 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -50,11 +50,14 @@ class KeyValue public static final int FLAG_ACCENT_CARON = (1 << 26); public static final int FLAG_ACCENT_MACRON = (1 << 27); public static final int FLAG_ACCENT_ORDINAL = (1 << 28); + public static final int FLAG_ACCENT_ARROWS = (1 << 29); + public static final int FLAG_ACCENT_BOX = (1 << 30); public static final int FLAGS_ACCENTS = FLAG_ACCENT1 | FLAG_ACCENT2 | FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6 | FLAG_ACCENT_CARON | FLAG_ACCENT_MACRON | FLAG_ACCENT_SUPERSCRIPT | - FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_ORDINAL | FLAG_ACCENT_RING; + FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_ORDINAL | FLAG_ACCENT_ARROWS | + FLAG_ACCENT_BOX | FLAG_ACCENT_RING; // Language specific keys that are removed from the keyboard by default public static final int FLAG_LOCALIZED = (1 << 25); @@ -168,6 +171,8 @@ class KeyValue addModifierKey("superscript", "Sup", FLAG_ACCENT_SUPERSCRIPT | FLAG_SMALLER_FONT); addModifierKey("subscript", "Sub", FLAG_ACCENT_SUBSCRIPT | FLAG_SMALLER_FONT); addModifierKey("ordinal", "Ord", FLAG_ACCENT_ORDINAL | FLAG_SMALLER_FONT); + addModifierKey("arrows", "Arr", FLAG_ACCENT_ARROWS | FLAG_SMALLER_FONT); + addModifierKey("box", "Box", FLAG_ACCENT_BOX | FLAG_SMALLER_FONT); addModifierKey("fn", "Fn", FLAG_FN | FLAG_SMALLER_FONT); addModifierKey("meta", "◆", FLAG_META);