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:
parent
266bed96db
commit
40b48bba52
2 changed files with 5 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ package io.github.sspanak.tt9.ime.modes.helpers;
|
||||||
import io.github.sspanak.tt9.hacks.InputType;
|
import io.github.sspanak.tt9.hacks.InputType;
|
||||||
import io.github.sspanak.tt9.ime.helpers.TextField;
|
import io.github.sspanak.tt9.ime.helpers.TextField;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
import io.github.sspanak.tt9.util.Characters;
|
||||||
import io.github.sspanak.tt9.util.Text;
|
import io.github.sspanak.tt9.util.Text;
|
||||||
|
|
||||||
public class AutoSpace {
|
public class AutoSpace {
|
||||||
|
|
@ -66,6 +67,7 @@ public class AutoSpace {
|
||||||
* because we are not using a QWERTY keyboard here).
|
* because we are not using a QWERTY keyboard here).
|
||||||
*/
|
*/
|
||||||
private boolean shouldAddAfterPunctuation(String previousChars, Text nextChars, int nextKey) {
|
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);
|
char previousChar = previousChars.isEmpty() ? 0 : previousChars.charAt(previousChars.length() - 1);
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -76,7 +78,7 @@ public class AutoSpace {
|
||||||
previousChar == '.'
|
previousChar == '.'
|
||||||
|| previousChar == ','
|
|| previousChar == ','
|
||||||
|| previousChar == ';'
|
|| previousChar == ';'
|
||||||
|| previousChar == ':'
|
|| (previousChar == ':' && !Character.isDigit(penultimateChar))
|
||||||
|| previousChar == '!'
|
|| previousChar == '!'
|
||||||
|| previousChar == '?'
|
|| previousChar == '?'
|
||||||
|| previousChar == ')'
|
|| previousChar == ')'
|
||||||
|
|
@ -87,6 +89,7 @@ public class AutoSpace {
|
||||||
|| previousChar == '“'
|
|| previousChar == '“'
|
||||||
|| previousChars.endsWith(" -")
|
|| previousChars.endsWith(" -")
|
||||||
|| previousChars.endsWith(" /")
|
|| previousChars.endsWith(" /")
|
||||||
|
|| (Character.isDigit(penultimateChar) && Characters.Currency.contains(previousChar + ""))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ public class Text extends TextTools {
|
||||||
|
|
||||||
|
|
||||||
public boolean startsWithWhitespace() {
|
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() {
|
public boolean startsWithNumber() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue