added rules for automatic space before parenthesis, quote marks and Spanish inverted punctuation
This commit is contained in:
parent
397ffe7391
commit
23074a3bc2
1 changed files with 21 additions and 12 deletions
|
|
@ -81,27 +81,36 @@ public class AutoSpace {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For languages that require a space before punctuation (currently only French), this determines
|
* Determines the special French rules for space before punctuation, as well as some standard ones.
|
||||||
* whether to transform: "word?" to: "word ?".
|
* For example, should we transform "word?" to "word ?", or "something(" to "something ("
|
||||||
*/
|
*/
|
||||||
public boolean shouldAddBeforePunctuation() {
|
public boolean shouldAddBeforePunctuation() {
|
||||||
String previousChars = textField.getStringBeforeCursor(2);
|
String previousChars = textField.getStringBeforeCursor(2);
|
||||||
char penultimateChar = previousChars.length() < 2 ? 0 : previousChars.charAt(previousChars.length() - 2);
|
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);
|
||||||
|
|
||||||
|
if (previousChar == '¡' || previousChar == '¿' && settings.getAutoSpace()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
isLanguageWithSpaceBetweenWords
|
isLanguageWithSpaceBetweenWords
|
||||||
&& isLanguageFrench
|
|
||||||
&& settings.getAutoSpace()
|
&& settings.getAutoSpace()
|
||||||
&& !inputType.isSpecialized()
|
&& !inputType.isSpecialized()
|
||||||
&& Character.isAlphabetic(penultimateChar)
|
&& Character.isAlphabetic(penultimateChar)
|
||||||
&& (
|
&& (
|
||||||
previousChar == ';'
|
previousChar == '('
|
||||||
|| previousChar == ':'
|
|| previousChar == '['
|
||||||
|| previousChar == '!'
|
|| previousChar == '«'
|
||||||
|| previousChar == '?'
|
|| previousChar == '„'
|
||||||
|| previousChar == ')'
|
|| isLanguageFrench && (
|
||||||
|| previousChar == '»'
|
previousChar == ';'
|
||||||
|
|| previousChar == ':'
|
||||||
|
|| previousChar == '!'
|
||||||
|
|| previousChar == '?'
|
||||||
|
|| previousChar == ')'
|
||||||
|
|| previousChar == '»'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,12 +138,12 @@ public class AutoSpace {
|
||||||
|| previousChar == ')'
|
|| previousChar == ')'
|
||||||
|| previousChar == ']'
|
|| previousChar == ']'
|
||||||
|| previousChar == '%'
|
|| previousChar == '%'
|
||||||
|| (isLanguageFrench && previousChar == '«')
|
|
||||||
|| previousChar == '»'
|
|| previousChar == '»'
|
||||||
|| previousChar == '؟'
|
|| previousChar == '؟'
|
||||||
|| previousChar == '“'
|
|| previousChar == '“'
|
||||||
|| previousChars.endsWith(" -")
|
|| (isLanguageFrench && previousChar == '«')
|
||||||
|| previousChars.endsWith(" /")
|
|| (penultimateChar == ' ' && previousChar == '-')
|
||||||
|
|| (penultimateChar == ' ' && previousChar == '/')
|
||||||
|| (Character.isDigit(penultimateChar) && Characters.Currency.contains(previousChar + ""))
|
|| (Character.isDigit(penultimateChar) && Characters.Currency.contains(previousChar + ""))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue