mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Make user-configurable shortcuts case insensitive
This commit is contained in:
@@ -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);
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user