def str_fmt_width(string,pad,width):
    """
        util function for breaking a string on spaces
        while trying to keep lines less than width.
        pad, when non zero inserts that number of spaces
        on the left side of the formated string.
    """

    base = "\n"
    if pad > 1:
        base = "\n" +" "*pad +":"
    words = string.split()
    out = ""
    temp = base
    for word in words:
        test = temp + " " + word
        if len(test)>width-pad:
            out += test
            temp = base
        else:
            temp = test
    if temp != base:
        out += temp
    return out