diff --git a/evennia/commands/default/player.py b/evennia/commands/default/player.py index 560da106b5..ad2748e000 100644 --- a/evennia/commands/default/player.py +++ b/evennia/commands/default/player.py @@ -580,8 +580,8 @@ class CmdColorTest(MuxPlayerCommand): ap = ansi.ANSI_PARSER # ansi colors # show all ansi color-related codes - col1 = ["%s%s|n" % (code, code.replace("|", "||")) for code, _ in ap.ext_ansi_map[6:14]] - col2 = ["%s%s|n" % (code, code.replace("|", "||")) for code, _ in ap.ext_ansi_map[14:22]] + 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:]] col2.extend(["" for i in range(len(col1)-len(col2))]) table = utils.format_table([col1, col2, col3]) @@ -601,8 +601,8 @@ class CmdColorTest(MuxPlayerCommand): # foreground table table[ir].append("|%i%i%i%s|n" % (ir, ig, ib, "||%i%i%i" % (ir, ig, ib))) # background table - table[6+ir].append("|[%i%i%i|%i%i%i%s|n" % (ir, ig, ib, - 5 - ir, 5 - ig, 5 - 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):" diff --git a/evennia/utils/ansi.py b/evennia/utils/ansi.py index 54cc1431ed..11c0539d03 100644 --- a/evennia/utils/ansi.py +++ b/evennia/utils/ansi.py @@ -107,7 +107,7 @@ class ANSIParser(object): """ return self.ansi_bright_bgs.get(ansimatch.group(), "") - def sub_xterm256(self, rgbmatch, convert=False): + def sub_xterm256(self, rgbmatch, use_xterm256=False): """ This is a replacer method called by `re.sub` with the matched tag. It must return the correct ansi sequence. @@ -117,7 +117,7 @@ class ANSIParser(object): Args: rgbmatch (re.matchobject): The match. - convert (bool, optional): Convert 256-colors to 16. + use_xterm256 (bool, optional): Don't convert 256-colors to 16. Returns: processed (str): The processed match string. @@ -135,19 +135,20 @@ class ANSIParser(object): else: red, green, blue = int(rgbtag[0]), int(rgbtag[1]), int(rgbtag[2]) - if convert: + if use_xterm256: colval = 16 + (red * 36) + (green * 6) + blue return "\033[%s8;5;%s%s%sm" % (3 + int(background), colval // 100, (colval % 100) // 10, colval%10) + #return "\033[%s8;5;%sm" % (3 + int(background), colval) else: # xterm256 not supported, convert the rgb value to ansi instead - if red == green and red == blue and red < 2: + if red == green == blue and red < 3: if background: return ANSI_BACK_BLACK elif red >= 1: return ANSI_HILITE + ANSI_BLACK else: return ANSI_NORMAL + ANSI_BLACK - elif red == green and red == blue: + elif red == green == blue: if background: return ANSI_BACK_WHITE elif red >= 4: