mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
simplified handling of punctuation is spellchecker, now checks for stand alone punctuation and double spaces.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1275 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+11
-4
@@ -122,15 +122,22 @@ String strip_last_word(const String& s) {
|
||||
}
|
||||
}
|
||||
|
||||
const String word_start = String(_("[({\"\'")) + LEFT_SINGLE_QUOTE + LEFT_DOUBLE_QUOTE;
|
||||
const String word_end = String(_("])}.,;:?!\"\'")) + RIGHT_SINGLE_QUOTE + RIGHT_DOUBLE_QUOTE;
|
||||
const String word_start_chars = String(_("[({\"\'")) + LEFT_SINGLE_QUOTE + LEFT_DOUBLE_QUOTE;
|
||||
const String word_end_chars = String(_("])}.,;:?!\"\'")) + RIGHT_SINGLE_QUOTE + RIGHT_DOUBLE_QUOTE;
|
||||
|
||||
void trim_punctuation(const String& str, size_t& start, size_t& end) {
|
||||
start = str.find_first_not_of(word_start, start);
|
||||
end = str.find_last_not_of(word_end, min(end,str.size()-1)) + 1;
|
||||
start = str.find_first_not_of(word_start_chars, start);
|
||||
end = str.find_last_not_of(word_end_chars, min(end,str.size()-1)) + 1;
|
||||
if (start >= end) start = end;
|
||||
}
|
||||
|
||||
bool is_word_start_punctuation(Char c) {
|
||||
return word_start_chars.find_first_of(c) != String::npos;
|
||||
}
|
||||
bool is_word_end_punctuation(Char c) {
|
||||
return word_end_chars.find_first_of(c) != String::npos;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Caseing
|
||||
|
||||
/// Quick check to see if the substring starting at the given iterator is equal to some given string
|
||||
|
||||
@@ -139,6 +139,9 @@ String strip_last_word(const String&);
|
||||
/// Trim punctuation at the start/end of a word in the range [start..end)
|
||||
void trim_punctuation(const String&, size_t& start, size_t& end);
|
||||
|
||||
bool is_word_start_punctuation(Char c);
|
||||
bool is_word_end_punctuation(Char c);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Caseing
|
||||
|
||||
/// Make each word in a string start with an upper case character.
|
||||
|
||||
Reference in New Issue
Block a user