Follow-up to e3ef90941f - next improvements for get_wraped_wxString

This commit is contained in:
YuSanka 2022-01-31 14:37:38 +01:00
parent f368de9a2d
commit ba82cfa9e3

View File

@ -303,28 +303,32 @@ wxString get_wraped_wxString(const wxString& text_in, size_t line_len /*=80*/)
wxString text = text_in; wxString text = text_in;
int idx = -1; size_t idx = 0;
size_t cur_len = 0; size_t cur_len = 0;
size_t text_len = text.size(); size_t text_len = text.size();
for (size_t i = 0; i < text_len; ++ i) { for (size_t i = 0; i < text_len; ++ i) {
if (text[i] == new_line) { if (text[i] == new_line) {
idx = -1; idx = i;
cur_len = 0; cur_len = 0;
} else { } else {
++ cur_len; ++ cur_len;
if (text[i] == space || text[i] == slash) if (text[i] == space || text[i] == slash)
idx = i; idx = i;
if (cur_len >= line_len && idx >= 0) { if (cur_len >= line_len) {
if (text[idx] == slash) { cur_len = i - idx;
text.insert(static_cast<size_t>(++ idx), 1, new_line); if (cur_len >= line_len) {
++ text_len; text.insert(++i, 1, new_line);
++ i; idx = i;
cur_len = 0;
}
else if (text[idx] == slash) {
text.insert(++idx, 1, new_line);
++text_len;
++i;
} }
else // space else // space
text[idx] = new_line; text[idx] = new_line;
cur_len = i - static_cast<size_t>(idx);
idx = -1;
} }
} }
} }