forked from extern/Unexpected-Keyboard
Capitalize the first letter of custom keys
This is more useful than turning the entire string full caps.
This commit is contained in:
parent
92a8db5e93
commit
44e2e86f19
@ -122,7 +122,8 @@ class KeyModifier
|
|||||||
c = Character.toUpperCase(kc);
|
c = Character.toUpperCase(kc);
|
||||||
return (kc == c) ? k : k.withChar(c);
|
return (kc == c) ? k : k.withChar(c);
|
||||||
case String:
|
case String:
|
||||||
return KeyValue.makeStringKey(k.getString().toUpperCase(), k.getFlags());
|
String s = Utils.capitalize_string(k.getString());
|
||||||
|
return KeyValue.makeStringKey(s, k.getFlags());
|
||||||
default: return k;
|
default: return k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
srcs/juloo.keyboard2/StringUtils.java
Normal file
12
srcs/juloo.keyboard2/StringUtils.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package juloo.keyboard2;
|
||||||
|
|
||||||
|
final class Utils
|
||||||
|
{
|
||||||
|
/** Turn the first letter of a string uppercase. */
|
||||||
|
public static String capitalize_string(String s)
|
||||||
|
{
|
||||||
|
// Make sure not to cut a code point in half
|
||||||
|
int i = s.offsetByCodePoints(0, 1);
|
||||||
|
return s.substring(0, i).toUpperCase() + s.substring(i);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user