summaryrefslogtreecommitdiffstats
path: root/gui/scrolllist.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-07-22 19:33:59 +0200
committerEthan Yonker <dees_troy@teamw.in>2015-10-26 17:54:16 +0100
commit44925ad19051d4ffe239b3ba99ea27e7275409dc (patch)
tree5ffc3a491429c71c360553452ea4369aa268e017 /gui/scrolllist.cpp
parentAdd nulls during reading of settings and info files (diff)
downloadandroid_bootable_recovery-44925ad19051d4ffe239b3ba99ea27e7275409dc.tar
android_bootable_recovery-44925ad19051d4ffe239b3ba99ea27e7275409dc.tar.gz
android_bootable_recovery-44925ad19051d4ffe239b3ba99ea27e7275409dc.tar.bz2
android_bootable_recovery-44925ad19051d4ffe239b3ba99ea27e7275409dc.tar.lz
android_bootable_recovery-44925ad19051d4ffe239b3ba99ea27e7275409dc.tar.xz
android_bootable_recovery-44925ad19051d4ffe239b3ba99ea27e7275409dc.tar.zst
android_bootable_recovery-44925ad19051d4ffe239b3ba99ea27e7275409dc.zip
Diffstat (limited to 'gui/scrolllist.cpp')
-rw-r--r--gui/scrolllist.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp
index a033205bb..d857e06b3 100644
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -607,3 +607,43 @@ void GUIScrollList::SetPageFocus(int inFocus)
mUpdate = 1;
}
}
+
+bool GUIScrollList::AddLines(std::vector<std::string>* origText, std::vector<std::string>* origColor, size_t* lastCount, std::vector<std::string>* rText, std::vector<std::string>* rColor)
+{
+ if (*lastCount == origText->size())
+ return false; // nothing to add
+
+ size_t prevCount = *lastCount;
+ *lastCount = origText->size();
+
+ // Due to word wrap, figure out what / how the newly added text needs to be added to the render vector that is word wrapped
+ // Note, that multiple consoles on different GUI pages may be different widths or use different fonts, so the word wrapping
+ // may different in different console windows
+ for (size_t i = prevCount; i < *lastCount; i++) {
+ string curr_line = origText->at(i);
+ string curr_color;
+ if (origColor)
+ curr_color = origColor->at(i);
+ for(;;) {
+ size_t line_char_width = gr_ttf_maxExW(curr_line.c_str(), mFont->GetResource(), mRenderW);
+ if (line_char_width < curr_line.size()) {
+ //string left = curr_line.substr(0, line_char_width);
+ size_t wrap_pos = curr_line.find_last_of(" ,./:-_;", line_char_width - 1);
+ if (wrap_pos == string::npos)
+ wrap_pos = line_char_width;
+ else if (wrap_pos < line_char_width - 1)
+ wrap_pos++;
+ rText->push_back(curr_line.substr(0, wrap_pos));
+ if (origColor)
+ rColor->push_back(curr_color);
+ curr_line = curr_line.substr(wrap_pos);
+ } else {
+ rText->push_back(curr_line);
+ if (origColor)
+ rColor->push_back(curr_color);
+ break;
+ }
+ }
+ }
+ return true;
+}