1
0
Fork 0

automatic text case improvement: lowercase is now enforced, when the cursor is next to or in the middle of a word (#272)

This commit is contained in:
Dimo Karaivanov 2023-06-05 15:50:08 +03:00 committed by GitHub
parent de964e8b0f
commit 4aa11b9501
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import io.github.sspanak.tt9.languages.Language;
import io.github.sspanak.tt9.preferences.SettingsStore; import io.github.sspanak.tt9.preferences.SettingsStore;
public class AutoTextCase { public class AutoTextCase {
private final Pattern nextToWordRegex = Pattern.compile("\\b$");
private final Pattern startOfSentenceRegex = Pattern.compile("(?<!\\.)(^|[.?!¿¡])\\s*$"); private final Pattern startOfSentenceRegex = Pattern.compile("(?<!\\.)(^|[.?!¿¡])\\s*$");
private final SettingsStore settings; private final SettingsStore settings;
@ -71,6 +72,10 @@ public class AutoTextCase {
return InputMode.CASE_CAPITALIZE; return InputMode.CASE_CAPITALIZE;
} }
if (nextToWordRegex.matcher(textBeforeCursor).find()) {
return InputMode.CASE_LOWER;
}
return InputMode.CASE_DICTIONARY; return InputMode.CASE_DICTIONARY;
} }
} }