Index: /trunk/FACT++/src/tools.cc
===================================================================
--- /trunk/FACT++/src/tools.cc	(revision 18875)
+++ /trunk/FACT++/src/tools.cc	(revision 18876)
@@ -302,2 +302,48 @@
     return charPos<1 ? "" : opt.substr(0, opt[charPos-1]=='#' ? charPos-1 : charPos);
 }
+
+// --------------------------------------------------------------------------
+//
+//! Wraps a given text into a vector of strings with not more than
+//! max size lines
+//!
+vector<string> Tools::WordWrap(string text, const uint16_t &max)
+{
+    if (text.size()<max)
+        return { text };
+
+    vector<string> rc;
+    while (1)
+    {
+        // Remove trailing white spaces
+        const size_t st = text.find_first_not_of(' ');
+        if (st==string::npos)
+            break;
+
+        text.erase(0, st);
+        if (text.size()<max)
+        {
+            rc.push_back(text);
+            break;
+        }
+
+        // Last white space - position to break
+        const size_t ws = text.find_last_of(' ', max);
+        if (ws==string::npos)
+        {
+            rc.push_back(text.substr(0, max));
+            text.erase(0, max);
+            continue;
+        }
+
+        // Previous non-whitespace, last position to keep
+        const size_t ch = text.find_last_not_of(' ', ws);
+        if (ch==string::npos) // found only white spaces
+            continue;
+
+        rc.push_back(text.substr(0, ch+1));
+        text.erase(0, ws);
+    }
+
+    return rc;
+}
Index: /trunk/FACT++/src/tools.h
===================================================================
--- /trunk/FACT++/src/tools.h	(revision 18875)
+++ /trunk/FACT++/src/tools.h	(revision 18876)
@@ -18,4 +18,6 @@
     std::vector<std::string> Split(const std::string &, const std::string &);
     std::string Uncomment(const std::string &opt);
+
+    std::vector<std::string> WordWrap(std::string, const uint16_t & = 80);
 
     template<typename T>
