def write_color(self, text, attr=None):
        '''write text at current cursor position and interpret color escapes.

        return the number of characters written.
        '''
        log('write_color("%s", %s)' % (text, attr))
        chunks = self.terminal_escape.split(text)
        log('chunks=%s' % repr(chunks))
        bg = self.savebg
        n = 0 # count the characters we actually write, omitting the escapes
        if attr is None:#use attribute from initial console
            attr = self.attr
        try:
            fg = self.trtable[(0x000f&attr)]
            bg = self.trtable[(0x00f0&attr)>>4]
        except __HOLE__:
            fg = attr
            
        for chunk in chunks:
            m = self.escape_parts.match(chunk)
            if m:
                log(m.group(1))
                attr = ansicolor.get(m.group(1), self.attr)
            n += len(chunk)
            System.Console.ForegroundColor = fg
            System.Console.BackgroundColor = bg
            System.Console.Write(chunk)
        return n
dataset/ETHPy150Open Ali-Razmjoo/OWASP-ZSC/module/readline_windows/pyreadline/console/ironpython_console.py/Console.write_color