From: Wolfgang Bangerth Date: Thu, 8 Sep 2005 23:56:34 +0000 (+0000) Subject: Use the has_documentation flag. X-Git-Tag: v8.0.0~13214 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee202da34ad0b93589120868a29d0e795bbd3e33;p=dealii.git Use the has_documentation flag. git-svn-id: https://svn.dealii.org/trunk@11375 0785d39b-7218-0410-832d-ea1e28bc413d --- 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; + }