minchin/text.py
def centered(mystring, linewidth=None, fill=" "):
    '''Takes a string, centres it, and pads it on both sides'''
    if linewidth is None:
        linewidth = get_terminal_size().columns - 1
    sides = (linewidth - length_no_ansi(mystring))//2
    extra = (linewidth - length_no_ansi(mystring)) % 2
    fill = fill[:1]
    sidestring = fill*sides
    extrastring = fill*extra
    newstring = sidestring + mystring + sidestring + extrastring
    return newstring
def centered(mystring, linewidth=None, fill=" "):
    '''Takes a string, centres it, and pads it on both sides'''
    if linewidth is None:
        linewidth = get_terminal_size().columns - 1
    sides = (linewidth - length_no_ansi(mystring))//2
    extra = (linewidth - length_no_ansi(mystring)) % 2
    fill = fill[:1]
    sidestring = fill*sides
    extrastring = fill*extra
    newstring = sidestring + mystring + sidestring + extrastring
    return newstring
def centered ( mystring , linewidth = None , fill = " " ) : if linewidth is None : linewidth = get_terminal_size ( ) . columns - 1 sides = ( linewidth - length_no_ansi ( mystring ) ) // 2 extra = ( linewidth - length_no_ansi ( mystring ) ) % 2 fill = fill [ : 1 ] sidestring = fill * sides extrastring = fill * extra newstring = sidestring + mystring + sidestring + extrastring return newstring
Takes a string, centres it, and pads it on both sides
Takes a string centres it and pads it on both sides