def add_dots(text, width, xref=0):
    """
    Create a new dotted text if the text length exceeds the width.

    :param text: Text to be shortened.
    :param width: Terminal width.
    :param xref: X coordinate where the text will begin.
    """
    # Terminal width is "None" when there is no active terminal is found, so...
    if width is not None:
        if (xref + len(str(text))) > width:
            return str(text[:width - xref - len("...")]) + "..."
    return str(text)