Make user-configurable shortcuts case insensitive

This commit is contained in:
Fredrik Fornwall
2016-08-04 18:11:50 +02:00
parent b95d84fe13
commit dfb22e6050
2 changed files with 4 additions and 3 deletions

View File

@@ -250,9 +250,10 @@ public final class TermuxKeyListener implements TerminalKeyListener {
List<TermuxPreferences.KeyboardShortcut> shortcuts = mActivity.mSettings.shortcuts; List<TermuxPreferences.KeyboardShortcut> shortcuts = mActivity.mSettings.shortcuts;
if (!shortcuts.isEmpty()) { if (!shortcuts.isEmpty()) {
int codePointLowerCase = Character.toLowerCase(codePoint);
for (int i = shortcuts.size() - 1; i >= 0; i--) { for (int i = shortcuts.size() - 1; i >= 0; i--) {
TermuxPreferences.KeyboardShortcut shortcut = shortcuts.get(i); TermuxPreferences.KeyboardShortcut shortcut = shortcuts.get(i);
if (codePoint == shortcut.codePoint) { if (codePointLowerCase == shortcut.codePoint) {
switch (shortcut.shortcutAction) { switch (shortcut.shortcutAction) {
case TermuxPreferences.SHORTCUT_ACTION_CREATE_SESSION: case TermuxPreferences.SHORTCUT_ACTION_CREATE_SESSION:
mActivity.addNewSession(false, null); mActivity.addNewSession(false, null);

View File

@@ -184,9 +184,9 @@ final class TermuxPreferences {
private void parseAction(String name, int shortcutAction, Properties props) { private void parseAction(String name, int shortcutAction, Properties props) {
String value = props.getProperty(name); String value = props.getProperty(name);
if (value == null) return; if (value == null) return;
String[] parts = value.trim().split("\\+"); String[] parts = value.toLowerCase().trim().split("\\+");
String input = parts.length == 2 ? parts[1].trim() : null; String input = parts.length == 2 ? parts[1].trim() : null;
if (!(parts.length == 2 && parts[0].trim().equalsIgnoreCase("ctrl")) || input.isEmpty() || input.length() > 2) { if (!(parts.length == 2 && parts[0].trim().equals("ctrl")) || input.isEmpty() || input.length() > 2) {
Log.e("termux", "Keyboard shortcut '" + name + "' is not Ctrl+<something>"); Log.e("termux", "Keyboard shortcut '" + name + "' is not Ctrl+<something>");
return; return;
} }