'Show color tables'

def func(self):

    if self.args.startswith('a'):
        from evennia.utils import ansi
        ap = ansi.ANSI_PARSER
        col1 = [('%s%s|n' % (code, code.replace('|', '||'))) for (code, _) in ap.ext_ansi_map[48:56]]
        col2 = [('%s%s|n' % (code, code.replace('|', '||'))) for (code, _) in ap.ext_ansi_map[56:64]]
        col3 = [('%s%s|n' % (code.replace('\\', ''), code.replace('|', '||').replace('\\', ''))) for (code, _) in ap.ext_ansi_map[(-8):]]
        col4 = [('%s%s|n' % (code.replace('\\', ''), code.replace('|', '||').replace('\\', ''))) for (code, _) in ap.ansi_bright_bgs[(-8):]]
        col2.extend(['' for _ in range((len(col1) - len(col2)))])
        table = utils.format_table([col1, col2, col4, col3])
        string = 'ANSI    colors:'
        for row in table:
            string += ('\n    ' + '    '.join(row))
        self.msg(string)
        self.msg('||X    :    black.    ||/    :    return,    ||-    :    tab,    ||_    :    space,    ||*    :    invert,    ||u    :    underline\nTo    combine    background    and    foreground,    add    background    marker    last,    e.g.    ||r||[B.\nNote:    bright    backgrounds    like    ||[r    requires    your    client    handling    Xterm256    colors.')
    elif self.args.startswith('x'):
        table = [[], [], [], [], [], [], [], [], [], [], [], []]
        for ir in range(6):
            for ig in range(6):
                for ib in range(6):
                    table[ir].append(('|%i%i%i%s|n' % (ir, ig, ib, ('||%i%i%i' % (ir, ig, ib)))))
                    table[(6 + ir)].append(('|%i%i%i|[%i%i%i%s|n' % ((5 - ir), (5 - ig), (5 - ib), ir, ig, ib, ('||[%i%i%i' % (ir, ig, ib)))))
        table = self.table_format(table)
        string = 'Xterm256    colors    (if    not    all    hues    show,    your    client    might    not    report    that    it    can    handle    xterm256):'
        string += ('\n' + '\n'.join((''.join(row) for row in table)))
        table = [[], [], [], [], [], [], [], [], [], [], [], []]
        for ibatch in range(4):
            for igray in range(6):
                letter = chr((97 + ((ibatch * 6) + igray)))
                inverse = chr((122 - ((ibatch * 6) + igray)))
                table[(0 + igray)].append(('|=%s%s    |n' % (letter, ('||=%s' % letter))))
                table[(6 + igray)].append(('|=%s|[=%s%s    |n' % (inverse, letter, ('||[=%s' % letter))))
        for igray in range(6):
            if (igray < 2):
                letter = chr((121 + igray))
                inverse = chr((98 - igray))
                fg = ('|=%s%s    |n' % (letter, ('||=%s' % letter)))
                bg = ('|=%s|[=%s%s    |n' % (inverse, letter, ('||[=%s' % letter)))
            else:
                (fg, bg) = ('    ', '    ')
            table[(0 + igray)].append(fg)
            table[(6 + igray)].append(bg)
        table = self.table_format(table)
        string += ('\n' + '\n'.join((''.join(row) for row in table)))
        self.msg(string)
    else:
        self.msg('Usage:    @color    ansi||xterm256')
