mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 05:57:00 -04:00
* Now a <nospellcheck>/<sym>/<atom> anywhere within a word disables the spellchecker. * Consider single quotes to be a part of a word, for things like "doesn't". TODO: this will do the wrong thing for text in single quotes
This commit is contained in:
@@ -50,6 +50,10 @@ void check_word(const String& tag, const String& input, size_t start, size_t end
|
|||||||
if (!good) { out += _("</"); out += tag; }
|
if (!good) { out += _("</"); out += tag; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isWordChar(wxUniChar c) {
|
||||||
|
return isAlpha(c) || c == '\'' || c == RIGHT_SINGLE_QUOTE;
|
||||||
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(check_spelling) {
|
SCRIPT_FUNCTION(check_spelling) {
|
||||||
SCRIPT_PARAM_C(StyleSheetP,stylesheet);
|
SCRIPT_PARAM_C(StyleSheetP,stylesheet);
|
||||||
SCRIPT_PARAM_C(String,language);
|
SCRIPT_PARAM_C(String,language);
|
||||||
@@ -82,6 +86,7 @@ SCRIPT_FUNCTION(check_spelling) {
|
|||||||
size_t word_start = String::npos; // start of the word to be checked, or npos if not inside a word
|
size_t word_start = String::npos; // start of the word to be checked, or npos if not inside a word
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
int unchecked_tag = 0;
|
int unchecked_tag = 0;
|
||||||
|
bool check_this_word = true;
|
||||||
while (pos < input.size()) {
|
while (pos < input.size()) {
|
||||||
Char c = input.GetChar(pos);
|
Char c = input.GetChar(pos);
|
||||||
if (c == _('<')) {
|
if (c == _('<')) {
|
||||||
@@ -103,21 +108,23 @@ SCRIPT_FUNCTION(check_spelling) {
|
|||||||
}
|
}
|
||||||
pos = after;
|
pos = after;
|
||||||
}
|
}
|
||||||
} else if (isAlpha(c)) {
|
} else if (isWordChar(c)) {
|
||||||
// a word character
|
// a word character
|
||||||
if (word_start == String::npos) word_start = pos;
|
if (word_start == String::npos) word_start = pos;
|
||||||
|
if (unchecked_tag > 0) check_this_word = false;
|
||||||
++pos;
|
++pos;
|
||||||
} else {
|
} else {
|
||||||
// a non-word character, punctuation or space
|
// a non-word character, punctuation or space
|
||||||
// check word, add to result
|
// check word, add to result
|
||||||
check_word(tag, input, word_start, pos, result, unchecked_tag <= 0, checkers, extra_match, ctx);
|
check_word(tag, input, word_start, pos, result, check_this_word, checkers, extra_match, ctx);
|
||||||
word_start = String::npos;
|
word_start = String::npos;
|
||||||
|
check_this_word = unchecked_tag <= 0;
|
||||||
result += c;
|
result += c;
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// last word
|
// last word
|
||||||
check_word(tag, input, word_start, input.size(), result, unchecked_tag <= 0, checkers, extra_match, ctx);
|
check_word(tag, input, word_start, input.size(), result, check_this_word, checkers, extra_match, ctx);
|
||||||
// done
|
// done
|
||||||
assert_tagged(result);
|
assert_tagged(result);
|
||||||
SCRIPT_RETURN(result);
|
SCRIPT_RETURN(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user