def METHOD_NAME(msg, max_len, indent):
  def rfind_any(chars, s, start, end):
    last = -1
    for c in chars:
      r = s.rfind(c, start, end)
      if r > last:
        last = r
        start = r
    return last
  def find_any(chars, s, start, end):
    first = end + 1
    for c in chars:
      r = s.find(c, start, end)
      if r < first:
        first = r
        end = r
    if first == end + 1:
      return -1
    else:
      return first
  indent_str = ' ' * indent
  out = []
  iStart = 0
  sEnd = len(msg) - max_len
  while iStart < sEnd:
    iEnd = iStart + max_len
    # Go to the end of a line and walk backwards until we find a char we can split on
    i = rfind_any(LINE_WRAP_CHARS, msg, iStart, iEnd)
    # If the line cannot be split (e.g. VERY long preset name), go forwards until we can split
    if i == -1:
      i = find_any(LINE_WRAP_CHARS, msg, iEnd, len(msg))
    # We STILL didn't find a split char. Just call it done.
    if i == -1:
      i = len(msg) - 1
    # We found a char to split at, but we want to split AFTER it  
    i += 1
    out.append(msg[iStart:i] + '\n' + indent_str)
    # And move over to the next part of the message
    iStart = i
    #msg = msg[i:]
  out.append(msg[iStart:])
  return ''.join(out)