docs: protected int findWrapPos(String text, int width, int startPos)
      {
          // the line ends before the max wrap pos or a new line char found
          int pos = text.indexOf('\n', startPos);
          if (pos != -1 && pos <= width)
          {
              return pos + 1;
          }
  
          pos = text.indexOf('\t', startPos);
          if (pos != -1 && pos <= width)
          {
              return pos + 1;
          }
  
          if (startPos + width >= text.length())
          {
              return -1;
          }
  
          // look for the last whitespace character before startPos+width
          for (pos = startPos + width; pos >= startPos; --pos)
          {
              final char c = text.charAt(pos);
              if (c == ' ' || c == '\n' || c == '\r')
              {
                  break;
              }
          }
  
          // if we found it - just return
          if (pos > startPos)
          {
              return pos;
          }
  
          // if we didn't find one, simply chop at startPos+width
          pos = startPos + width;
  
          return pos == text.length() ? -1 : pos;
      }