From 69fc2c3be81c0770efc2d6ee3cd01f32a2863e06 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 13 Jun 2011 00:57:04 -0400 Subject: [PATCH] View - Modified layout algorithm to not attempt to distribute negative overage. - Modified wrapText to enforce a minimum wrap width of 1. --- src/ViewTask.cpp | 4 ++-- src/ViewText.cpp | 4 ++-- src/text.cpp | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ViewTask.cpp b/src/ViewTask.cpp index 31164f768..b87add4df 100644 --- a/src/ViewTask.cpp +++ b/src/ViewTask.cpp @@ -162,10 +162,10 @@ std::string ViewTask::render (std::vector & data, std::vector & seque std::vector widths; if (_width == 0 || sum_ideal <= overage) widths = ideal; - else if (sum_minimal > overage) + else if (sum_minimal > overage || overage < 0) // throw std::string ("There is not enough horizontal width to display the results."); widths = minimal; - else + else if (overage > 0) { widths = minimal; overage -= sum_minimal; diff --git a/src/ViewText.cpp b/src/ViewText.cpp index ea588fa80..287942b3b 100644 --- a/src/ViewText.cpp +++ b/src/ViewText.cpp @@ -151,10 +151,10 @@ std::string ViewText::render () std::vector widths; if (sum_ideal <= overage) widths = ideal; - else if (sum_minimal > overage) + else if (sum_minimal > overage || overage < 0) // throw std::string ("There is not enough horizontal width to display the results."); widths = minimal; - else + else if (overage > 0) { widths = minimal; overage -= sum_minimal; diff --git a/src/text.cpp b/src/text.cpp index b2f4e9e81..6041a3fab 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -57,9 +57,11 @@ void wrapText ( std::string copy = text; std::string line; + int modified_width = width > 0 ? width : 1; + while (copy.length ()) // Used as Boolean, therefore UTF8 safe. { - extractLine (copy, line, width); + extractLine (copy, line, modified_width); lines.push_back (line); } }