2012-10-30 16:59:47 +01:00
|
|
|
// Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
|
2008-03-07 03:32:29 +01:00
|
|
|
//
|
2012-10-30 16:59:47 +01:00
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
2008-03-07 03:32:29 +01:00
|
|
|
//
|
2012-10-30 16:59:47 +01:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2008-03-07 03:32:29 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file spellchecker_hunspell.h
|
|
|
|
/// @see spellchecker_hunspell.cpp
|
|
|
|
/// @ingroup spelling
|
|
|
|
///
|
2008-03-07 03:32:29 +01:00
|
|
|
|
|
|
|
#ifdef WITH_HUNSPELL
|
2012-10-30 16:59:47 +01:00
|
|
|
#include <libaegisub/spellchecker.h>
|
2012-01-31 01:43:49 +01:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
#include <libaegisub/fs_fwd.h>
|
2012-01-31 01:43:49 +01:00
|
|
|
#include <libaegisub/signal.h>
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include <memory>
|
2012-12-22 00:59:25 +01:00
|
|
|
#include <set>
|
|
|
|
|
2012-10-30 16:59:47 +01:00
|
|
|
namespace agi { namespace charset { class IconvWrapper; } }
|
2012-01-31 01:43:49 +01:00
|
|
|
class Hunspell;
|
2008-03-07 03:32:29 +01:00
|
|
|
|
2012-10-30 16:59:47 +01:00
|
|
|
/// @brief Hunspell-based spell checker implementation
|
2014-03-13 02:39:07 +01:00
|
|
|
class HunspellSpellChecker final : public agi::SpellChecker {
|
2009-08-01 06:37:29 +02:00
|
|
|
/// Hunspell instance
|
2013-01-04 16:01:50 +01:00
|
|
|
std::unique_ptr<Hunspell> hunspell;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-11-18 04:00:08 +01:00
|
|
|
/// Conversions between the dictionary charset and utf-8
|
2013-01-04 16:01:50 +01:00
|
|
|
std::unique_ptr<agi::charset::IconvWrapper> conv;
|
|
|
|
std::unique_ptr<agi::charset::IconvWrapper> rconv;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-11-18 04:00:08 +01:00
|
|
|
/// Languages which we have dictionaries for
|
2012-10-30 16:59:47 +01:00
|
|
|
std::vector<std::string> languages;
|
2010-11-18 04:00:08 +01:00
|
|
|
|
2009-08-01 06:37:29 +02:00
|
|
|
/// Path to user-local dictionary.
|
2013-01-04 16:01:50 +01:00
|
|
|
agi::fs::path userDicPath;
|
2008-03-07 03:32:29 +01:00
|
|
|
|
2012-12-22 00:59:25 +01:00
|
|
|
/// Words in the custom user dictionary
|
|
|
|
std::set<std::string> customWords;
|
|
|
|
|
2012-01-31 01:43:49 +01:00
|
|
|
/// Dictionary language change connection
|
|
|
|
agi::signal::Connection lang_listener;
|
|
|
|
/// Dictionary language change handler
|
|
|
|
void OnLanguageChanged();
|
|
|
|
|
|
|
|
/// Dictionary path change connection
|
|
|
|
agi::signal::Connection dict_path_listener;
|
|
|
|
/// Dictionary path change handler
|
|
|
|
void OnPathChanged();
|
|
|
|
|
2012-12-18 17:54:53 +01:00
|
|
|
/// Load words from custom dictionary
|
2012-12-22 00:59:25 +01:00
|
|
|
void ReadUserDictionary();
|
2012-12-18 17:54:53 +01:00
|
|
|
/// Save words to custom dictionary
|
2012-12-22 00:59:25 +01:00
|
|
|
void WriteUserDictionary();
|
2012-12-18 17:54:53 +01:00
|
|
|
|
2008-03-07 03:32:29 +01:00
|
|
|
public:
|
|
|
|
HunspellSpellChecker();
|
|
|
|
~HunspellSpellChecker();
|
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
void AddWord(std::string const& word) override;
|
|
|
|
void RemoveWord(std::string const& word) override;
|
|
|
|
bool CanAddWord(std::string const& word) override;
|
|
|
|
bool CanRemoveWord(std::string const& word) override;
|
|
|
|
bool CheckWord(std::string const& word) override;
|
|
|
|
std::vector<std::string> GetSuggestions(std::string const& word) override;
|
|
|
|
std::vector<std::string> GetLanguageList() override;
|
2008-03-07 03:32:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|