The check_spelling function now has support for additional dictionaries and regexes to match.

The magic game uses these features.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1269 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-12-30 02:09:11 +00:00
parent 09216eca5d
commit 12f8be203e
11 changed files with 185 additions and 18 deletions
+25
View File
@@ -35,6 +35,31 @@ SpellChecker& SpellChecker::get(const String& language) {
return *speller;
}
SpellChecker& SpellChecker::get(const String& filename, const String& language) {
SpellCheckerP& speller = spellers[filename + _(".") + language];
if (!speller) {
Packaged* package = nullptr;
String prefix = package_manager.openFilenameFromPackage(package, filename) + _(".");
String local_dir = package_manager.getDictionaryDir(true);
String global_dir = package_manager.getDictionaryDir(false);
String aff_path = language + _(".aff");
String dic_path = language + _(".dic");
if (wxFileExists(prefix + aff_path) && wxFileExists(prefix + dic_path)) {
speller = SpellCheckerP(new SpellChecker((prefix + aff_path).mb_str(),
(prefix + dic_path).mb_str()));
} else if (wxFileExists(local_dir + aff_path) && wxFileExists(prefix + dic_path)) {
speller = SpellCheckerP(new SpellChecker((local_dir + aff_path).mb_str(),
(prefix + dic_path).mb_str()));
} else if (wxFileExists(global_dir + aff_path) && wxFileExists(prefix + dic_path)) {
speller = SpellCheckerP(new SpellChecker((global_dir + aff_path).mb_str(),
(prefix + dic_path).mb_str()));
} else {
throw Error(_("Dictionary '") + filename + _("' not found for language: ") + language);
}
}
return *speller;
}
SpellChecker::SpellChecker(const char* aff_path, const char* dic_path)
: Hunspell(aff_path,dic_path)
, encoding(String(get_dic_encoding(), IF_UNICODE(wxConvLibc, wxSTRING_MAXLEN)))