Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2022-01-31 16:37:38 +0300
committerYuSanka <yusanka@gmail.com>2022-01-31 16:37:53 +0300
commitba82cfa9e36700cecfdc40c52245cdb083a9c73e (patch)
treebe74aa1c7e05f4581d75f8505967c8e8443011dc
parentf368de9a2d84ad40b7ff419617f998dab4ff1579 (diff)
Follow-up to https://github.com/prusa3d/PrusaSlicer/commit/e3ef90941f0ddcc18f604b6c528aa5ea602bbc4a - next improvements for get_wraped_wxString
-rw-r--r--src/slic3r/GUI/MsgDialog.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp
index 368bc8618..dad88f14b 100644
--- a/src/slic3r/GUI/MsgDialog.cpp
+++ b/src/slic3r/GUI/MsgDialog.cpp
@@ -303,28 +303,32 @@ wxString get_wraped_wxString(const wxString& text_in, size_t line_len /*=80*/)
wxString text = text_in;
- int idx = -1;
+ size_t idx = 0;
size_t cur_len = 0;
size_t text_len = text.size();
for (size_t i = 0; i < text_len; ++ i) {
if (text[i] == new_line) {
- idx = -1;
+ idx = i;
cur_len = 0;
} else {
++ cur_len;
if (text[i] == space || text[i] == slash)
idx = i;
- if (cur_len >= line_len && idx >= 0) {
- if (text[idx] == slash) {
- text.insert(static_cast<size_t>(++ idx), 1, new_line);
- ++ text_len;
- ++ i;
+ if (cur_len >= line_len) {
+ cur_len = i - idx;
+ if (cur_len >= line_len) {
+ text.insert(++i, 1, new_line);
+ idx = i;
+ cur_len = 0;
+ }
+ else if (text[idx] == slash) {
+ text.insert(++idx, 1, new_line);
+ ++text_len;
+ ++i;
}
else // space
text[idx] = new_line;
- cur_len = i - static_cast<size_t>(idx);
- idx = -1;
}
}
}