summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-05-11 08:45:10 (GMT)
committerTobias Markmann <tm@ayena.de>2016-06-23 14:55:10 (GMT)
commite5d57519f573ef3718ec207c6f81006b4a0e0244 (patch)
treee42ff13628a63b67a2c08c5f96312bbc3033a869 /SwifTools/HunspellChecker.h
parent7f0fe603be200c09c74cf9cc295a972f3c3dbdfd (diff)
downloadswift-e5d57519f573ef3718ec207c6f81006b4a0e0244.zip
swift-e5d57519f573ef3718ec207c6f81006b4a0e0244.tar.bz2
Improve Linux spell checking UX and enable it by default
This removes support for user dictionaries for now. The new UI shows a list human readable languages (in their native spelling) where the user can select one to use for spell checking. Updated our InstallSwiftDependencies.sh based on the package names in their repositories. Test-Information: Tested on Ubuntu 16.04 with Hunspell and tested it still builds on OS X 10.11.4. Did not test InstallSwiftDependencies.sh. Change-Id: I24fc705b1495f7c39a8da149cbd7116e41609998
Diffstat (limited to 'SwifTools/HunspellChecker.h')
-rw-r--r--SwifTools/HunspellChecker.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/SwifTools/HunspellChecker.h b/SwifTools/HunspellChecker.h
index 076b468..2d4831e 100644
--- a/SwifTools/HunspellChecker.h
+++ b/SwifTools/HunspellChecker.h
@@ -12,10 +12,13 @@
#pragma once
+#include <memory>
+#include <string>
+#include <unordered_map>
#include <vector>
#include <boost/algorithm/string.hpp>
-#include <boost/tuple/tuple.hpp>
+#include <boost/optional.hpp>
#include <SwifTools/SpellChecker.h>
@@ -24,12 +27,31 @@ class Hunspell;
namespace Swift {
class HunspellChecker : public SpellChecker {
public:
- HunspellChecker(const char* affix_path, const char* dict_path);
+ HunspellChecker();
virtual ~HunspellChecker();
+
+ virtual bool isAutomaticallyDetectingLanguage();
+
+ virtual void setActiveLanguage(const std::string& language);
+ virtual std::string activeLanguage() const;
+ virtual std::vector<std::string> supportedLanguages() const;
+
virtual bool isCorrect(const std::string& word);
virtual void getSuggestions(const std::string& word, std::vector<std::string>& list);
virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions);
+
private:
- Hunspell* speller_;
+ struct Dictionary {
+ std::string dicPath;
+ std::string affPath;
+ };
+
+ std::unordered_map<std::string, Dictionary> detectedDictionaries() const;
+ std::vector<std::string> hunspellDictionaryPaths() const;
+
+ private:
+ std::unique_ptr<Hunspell> speller_;
+ boost::optional<std::string> activeLangauge_;
+
};
}