summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-05-09 20:52:09 +0200
committerTao Bao <tbao@google.com>2018-05-09 21:32:27 +0200
commit452b487f31df6457fc5eccd805b044e54c02b097 (patch)
tree30377e26ac631aaedbb1c6b66b03c278fd524e58 /screen_ui.cpp
parentMerge "updater_sample: update tools" (diff)
downloadandroid_bootable_recovery-452b487f31df6457fc5eccd805b044e54c02b097.tar
android_bootable_recovery-452b487f31df6457fc5eccd805b044e54c02b097.tar.gz
android_bootable_recovery-452b487f31df6457fc5eccd805b044e54c02b097.tar.bz2
android_bootable_recovery-452b487f31df6457fc5eccd805b044e54c02b097.tar.lz
android_bootable_recovery-452b487f31df6457fc5eccd805b044e54c02b097.tar.xz
android_bootable_recovery-452b487f31df6457fc5eccd805b044e54c02b097.tar.zst
android_bootable_recovery-452b487f31df6457fc5eccd805b044e54c02b097.zip
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 90e0e30af..c0fb2cfba 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -468,20 +468,22 @@ int ScreenRecoveryUI::DrawTextLines(int x, int y, const std::vector<std::string>
int ScreenRecoveryUI::DrawWrappedTextLines(int x, int y,
const std::vector<std::string>& lines) const {
+ // Keep symmetrical margins based on the given offset (i.e. x).
+ size_t text_cols = (ScreenWidth() - x * 2) / char_width_;
int offset = 0;
for (const auto& line : lines) {
size_t next_start = 0;
while (next_start < line.size()) {
- std::string sub = line.substr(next_start, text_cols_ + 1);
- if (sub.size() <= text_cols_) {
+ std::string sub = line.substr(next_start, text_cols + 1);
+ if (sub.size() <= text_cols) {
next_start += sub.size();
} else {
- // Line too long and must be wrapped to text_cols_ columns.
+ // Line too long and must be wrapped to text_cols columns.
size_t last_space = sub.find_last_of(" \t\n");
if (last_space == std::string::npos) {
// No space found, just draw as much as we can.
- sub.resize(text_cols_);
- next_start += text_cols_;
+ sub.resize(text_cols);
+ next_start += text_cols;
} else {
sub.resize(last_space);
next_start += last_space + 1;