1
0
Fork 0

Auto space improvements (#613)

* space is added at the end of a line, when this is not the last line

* space is added after digit+currency

* space is no longer added after digit+colon making it easier to type time
This commit is contained in:
Dimo Karaivanov 2024-08-31 16:43:12 +03:00
parent 266bed96db
commit 40b48bba52
2 changed files with 5 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package io.github.sspanak.tt9.ime.modes.helpers;
import io.github.sspanak.tt9.hacks.InputType;
import io.github.sspanak.tt9.ime.helpers.TextField;
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
import io.github.sspanak.tt9.util.Characters;
import io.github.sspanak.tt9.util.Text;
public class AutoSpace {
@ -66,6 +67,7 @@ public class AutoSpace {
* because we are not using a QWERTY keyboard here).
*/
private boolean shouldAddAfterPunctuation(String previousChars, Text nextChars, int nextKey) {
char penultimateChar = previousChars.length() < 2 ? 0 : previousChars.charAt(previousChars.length() - 2);
char previousChar = previousChars.isEmpty() ? 0 : previousChars.charAt(previousChars.length() - 1);
return
@ -76,7 +78,7 @@ public class AutoSpace {
previousChar == '.'
|| previousChar == ','
|| previousChar == ';'
|| previousChar == ':'
|| (previousChar == ':' && !Character.isDigit(penultimateChar))
|| previousChar == '!'
|| previousChar == '?'
|| previousChar == ')'
@ -87,6 +89,7 @@ public class AutoSpace {
|| previousChar == '“'
|| previousChars.endsWith(" -")
|| previousChars.endsWith(" /")
|| (Character.isDigit(penultimateChar) && Characters.Currency.contains(previousChar + ""))
);
}

View file

@ -125,7 +125,7 @@ public class Text extends TextTools {
public boolean startsWithWhitespace() {
return text != null && !text.isEmpty() && Character.isWhitespace(text.charAt(0));
return text != null && !text.isEmpty() && Character.isWhitespace(text.charAt(0)) && !text.startsWith("\n");
}
public boolean startsWithNumber() {