forked from mia/Aegisub
Load the thesaurus dictionary asynchronously
This commit is contained in:
parent
6957cd76a6
commit
dbf5af1d49
3 changed files with 13 additions and 9 deletions
|
@ -85,6 +85,7 @@ enum {
|
||||||
SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, agi::Context *context)
|
SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, agi::Context *context)
|
||||||
: ScintillaTextCtrl(parent, -1, "", wxDefaultPosition, wsize, style)
|
: ScintillaTextCtrl(parent, -1, "", wxDefaultPosition, wsize, style)
|
||||||
, spellchecker(SpellCheckerFactory::GetSpellChecker())
|
, spellchecker(SpellCheckerFactory::GetSpellChecker())
|
||||||
|
, thesaurus(agi::util::make_unique<Thesaurus>())
|
||||||
, context(context)
|
, context(context)
|
||||||
{
|
{
|
||||||
// Set properties
|
// Set properties
|
||||||
|
@ -387,9 +388,6 @@ void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) {
|
||||||
void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) {
|
void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) {
|
||||||
if (currentWord.empty()) return;
|
if (currentWord.empty()) return;
|
||||||
|
|
||||||
if (!thesaurus)
|
|
||||||
thesaurus = agi::util::make_unique<Thesaurus>();
|
|
||||||
|
|
||||||
auto results = thesaurus->Lookup(currentWord);
|
auto results = thesaurus->Lookup(currentWord);
|
||||||
|
|
||||||
thesSugs.clear();
|
thesSugs.clear();
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
#include <boost/range/algorithm.hpp>
|
#include <boost/range/algorithm.hpp>
|
||||||
|
|
||||||
|
#include <libaegisub/dispatch.h>
|
||||||
#include <libaegisub/fs.h>
|
#include <libaegisub/fs.h>
|
||||||
#include <libaegisub/log.h>
|
#include <libaegisub/log.h>
|
||||||
#include <libaegisub/path.h>
|
#include <libaegisub/path.h>
|
||||||
|
@ -99,7 +100,17 @@ void Thesaurus::OnLanguageChanged() {
|
||||||
|
|
||||||
LOG_I("thesaurus/file") << "Using thesaurus: " << dat;
|
LOG_I("thesaurus/file") << "Using thesaurus: " << dat;
|
||||||
|
|
||||||
impl = agi::util::make_unique<agi::Thesaurus>(dat, idx);
|
agi::dispatch::Background().Async([=]{
|
||||||
|
try {
|
||||||
|
auto thes = agi::util::make_unique<agi::Thesaurus>(dat, idx);
|
||||||
|
agi::dispatch::Main().Sync([&]{
|
||||||
|
impl = std::move(thes);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (agi::Exception const& e) {
|
||||||
|
LOG_E("thesaurus") << e.GetChainedMessage();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thesaurus::OnPathChanged() {
|
void Thesaurus::OnPathChanged() {
|
||||||
|
|
|
@ -14,11 +14,6 @@
|
||||||
//
|
//
|
||||||
// Aegisub Project http://www.aegisub.org/
|
// Aegisub Project http://www.aegisub.org/
|
||||||
|
|
||||||
/// @file thesaurus.h
|
|
||||||
/// @see thesaurus.cpp
|
|
||||||
/// @ingroup thesaurus
|
|
||||||
///
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
Loading…
Reference in a new issue