From df0f61e3999f210332003b10cce81668f7bfb2e4 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 8 Sep 2005 23:56:34 +0000 Subject: [PATCH] Use the has_documentation flag. git-svn-id: https://svn.dealii.org/trunk@11375 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/source/utilities.cc | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/deal.II/base/source/utilities.cc b/deal.II/base/source/utilities.cc index 1f3a98b25a..feafbb211e 100644 --- a/deal.II/base/source/utilities.cc +++ b/deal.II/base/source/utilities.cc @@ -176,6 +176,65 @@ namespace Utilities return split_list; } + + + + std::vector + break_text_into_lines (const std::string &original_text, + const unsigned int width) + { + std::string text = original_text; + std::vector lines; + + // remove trailing spaces + while ((text.length() != 0) && (text[text.length()-1] == ' ')) + text.erase(text.length()-1,1); + + // then split the text into lines + while (text.length() != 0) + { + // in each iteration, first remove + // leading spaces + while ((text.length() != 0) && (text[0] == ' ')) + text.erase(0, 1); + + // if we can fit everything into one + // line, then do so. otherwise, we have + // to keep breaking + if (text.length() < width) + { + lines.push_back (text); + text = ""; + } + else + { + // starting at position width, find the + // location of the previous space, so + // that we can break around there + int location = std::min(width,text.length()-1); + for (; location>=0; --location) + if (text[location] == ' ') + break; + + // if there are no spaces, then try if + // there are spaces coming up + if (location == 0) + for (location = std::min(width,text.length()-1); + location(text.length()); + ++location) + if (text[location] == ' ') + break; + + // now take the text up to the found + // location and put it into a single + // line, and remove it from 'text' + lines.push_back (std::string (text, 0, location)); + text.erase (0, location); + } + } + + return lines; + } -- 2.39.5