'Strip from the right, taking ANSI markers into account.'

def rstrip(self, chars=None):

    clean = self._clean_string
    raw = self._raw_string
    nlen = len(clean)
    nrstripped = (nlen - len(clean.rstrip(chars)))
    rstripped = ''
    (ic, ir2) = ((nlen - 1), (len(raw) - 1))
    while nrstripped:
        if ((nlen - ic) > nrstripped):
            break
        elif (raw[ir2] != clean[ic]):
            rstripped += raw[ir2]
        else:
            ic -= 1
        ir2 -= 1
    rstripped = rstripped[::(-1)]
    return ANSIString((raw[:(ir2 + 1)] + rstripped))
