Don't ignore the contents of override blocks when counting characters for selection preserving

This commit is contained in:
Thomas Goyne 2014-05-05 06:27:37 -07:00
parent 3983719e3f
commit f261688b11
4 changed files with 7 additions and 3 deletions

View File

@ -86,6 +86,9 @@ int ignore_mask_to_icu_mask(int mask) {
namespace agi { namespace agi {
size_t CharacterCount(std::string::const_iterator begin, std::string::const_iterator end, int mask) { size_t CharacterCount(std::string::const_iterator begin, std::string::const_iterator end, int mask) {
mask = ignore_mask_to_icu_mask(mask); mask = ignore_mask_to_icu_mask(mask);
if ((mask & agi::IGNORE_BLOCKS) == 0)
return count_in_range(begin, end, mask);
size_t characters = 0; size_t characters = 0;
auto pos = begin; auto pos = begin;
do { do {

View File

@ -20,7 +20,8 @@ namespace agi {
enum { enum {
IGNORE_NONE = 0, IGNORE_NONE = 0,
IGNORE_WHITESPACE = 1, IGNORE_WHITESPACE = 1,
IGNORE_PUNCTUATION = 2 IGNORE_PUNCTUATION = 2,
IGNORE_BLOCKS = 4
}; };
/// Get the length in characters of the longest line in the given text /// Get the length in characters of the longest line in the given text

View File

@ -271,7 +271,7 @@ public:
if (duration <= 100 || text.size() > static_cast<size_t>(duration)) if (duration <= 100 || text.size() > static_cast<size_t>(duration))
return -1; return -1;
int ignore = agi::IGNORE_NONE; int ignore = agi::IGNORE_BLOCKS;
if (ignore_whitespace->GetBool()) if (ignore_whitespace->GetBool())
ignore |= agi::IGNORE_WHITESPACE; ignore |= agi::IGNORE_WHITESPACE;
if (ignore_punctuation->GetBool()) if (ignore_punctuation->GetBool())

View File

@ -609,7 +609,7 @@ void SubsEditBox::CallCommand(const char *cmd_name) {
} }
void SubsEditBox::UpdateCharacterCount(std::string const& text) { void SubsEditBox::UpdateCharacterCount(std::string const& text) {
int ignore = agi::IGNORE_NONE; int ignore = agi::IGNORE_BLOCKS;
if (OPT_GET("Subtitle/Character Counter/Ignore Whitespace")->GetBool()) if (OPT_GET("Subtitle/Character Counter/Ignore Whitespace")->GetBool())
ignore |= agi::IGNORE_WHITESPACE; ignore |= agi::IGNORE_WHITESPACE;
if (OPT_GET("Subtitle/Character Counter/Ignore Punctuation")->GetBool()) if (OPT_GET("Subtitle/Character Counter/Ignore Punctuation")->GetBool())