mirror of https://github.com/odrling/Aegisub
Update the character count asynchronously
This commit is contained in:
parent
40a7a452a2
commit
777649a551
|
@ -55,6 +55,7 @@
|
||||||
#include "validators.h"
|
#include "validators.h"
|
||||||
#include "video_context.h"
|
#include "video_context.h"
|
||||||
|
|
||||||
|
#include <libaegisub/dispatch.h>
|
||||||
#include <libaegisub/of_type_adaptor.h>
|
#include <libaegisub/of_type_adaptor.h>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
@ -575,11 +576,15 @@ void SubsEditBox::CallCommand(const char *cmd_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::UpdateCharacterCount(std::string const& text) {
|
void SubsEditBox::UpdateCharacterCount(std::string const& text) {
|
||||||
|
agi::dispatch::Background().Async([=]{
|
||||||
size_t length = MaxLineLength(text);
|
size_t length = MaxLineLength(text);
|
||||||
|
agi::dispatch::Main().Async([=]{
|
||||||
char_count->SetValue(wxString::Format("%lu", (unsigned long)length));
|
char_count->SetValue(wxString::Format("%lu", (unsigned long)length));
|
||||||
size_t limit = (size_t)OPT_GET("Subtitle/Character Limit")->GetInt();
|
size_t limit = (size_t)OPT_GET("Subtitle/Character Limit")->GetInt();
|
||||||
if (limit && length > limit)
|
if (limit && length > limit)
|
||||||
char_count->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle/Syntax/Background/Error")->GetColor()));
|
char_count->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle/Syntax/Background/Error")->GetColor()));
|
||||||
else
|
else
|
||||||
char_count->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
char_count->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue