mirror of
https://github.com/evennia/evennia.git
synced 2026-04-06 07:57:16 +02:00
Added {-type coding for backgrounds. First removal of mentions of the %c syntax from @color command (%c style syntax is still working though)
This commit is contained in:
parent
d69f4dc674
commit
5c41adf7d0
2 changed files with 46 additions and 23 deletions
|
|
@ -542,12 +542,14 @@ class CmdColorTest(MuxPlayerCommand):
|
|||
Usage:
|
||||
@color ansi|xterm256
|
||||
|
||||
Print a color map along with in-mud color codes, while testing what is
|
||||
supported in your client. Choices are 16-color ansi (supported in most
|
||||
muds) or the 256-color xterm256 standard. No checking is done to determine
|
||||
your client supports color - if not you will see rubbish appear.
|
||||
Prints a color map along with in-mud color codes to use to produce
|
||||
them. It also tests what is supported in your client. Choices are
|
||||
16-color ansi (supported in most muds) or the 256-color xterm256
|
||||
standard. No checking is done to determine your client supports
|
||||
color - if not you will see rubbish appear.
|
||||
"""
|
||||
key = "@color"
|
||||
aliases = "color"
|
||||
locks = "cmd:all()"
|
||||
help_category = "General"
|
||||
|
||||
|
|
@ -576,17 +578,21 @@ 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[:-1]]
|
||||
hi = "%ch"
|
||||
col2 = ["%s%s{n" % (code, code.replace("%", "%%")) for code, _ in ap.mux_ansi_map[3:-2]]
|
||||
col3 = ["%s%s{n" % (hi + code, (hi + code).replace("%", "%%")) for code, _ in ap.mux_ansi_map[3:-2]]
|
||||
table = utils.format_table([col1, col2, col3], extra_space=1)
|
||||
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]]
|
||||
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))])
|
||||
#hi = "%ch"
|
||||
#col2 = ["%s%s{n" % (code, code.replace("%", "%%")) for code, _ in ap.mux_ansi_map[6:]]
|
||||
#col3 = ["%s%s{n" % (hi + code, (hi + code).replace("%", "%%")) for code, _ in ap.mux_ansi_map[3:-2]]
|
||||
table = utils.format_table([col1, col2, col3])
|
||||
string = "ANSI colors:"
|
||||
for row in table:
|
||||
string += "\n" + "".join(row)
|
||||
string += "\n " + " ".join(row)
|
||||
#print string
|
||||
self.msg(string)
|
||||
self.msg("({{X and %%cx are black-on-black\n %%r - return, %%t - tab, %%b - space)")
|
||||
self.msg("{{X : black. {{\ : return, {{- : tab, {{_ : space, {{* : invert")
|
||||
self.msg("To combine background and foreground, add background marker last, e.g. {{r{{[b.")
|
||||
|
||||
elif self.args.startswith("x"):
|
||||
# show xterm256 table
|
||||
|
|
@ -605,7 +611,7 @@ class CmdColorTest(MuxPlayerCommand):
|
|||
for row in table:
|
||||
string += "\n" + "".join(row)
|
||||
self.msg(string)
|
||||
self.msg("(e.g. %%123 and %%[123 also work)")
|
||||
#self.msg("(e.g. %%123 and %%[123 also work)")
|
||||
else:
|
||||
# malformed input
|
||||
self.msg("Usage: @color ansi|xterm256")
|
||||
|
|
|
|||
|
|
@ -201,6 +201,8 @@ class ANSIParser(object):
|
|||
mux_ansi_map = [
|
||||
# commented out by default; they (especially blink) are
|
||||
# potentially annoying
|
||||
(r'%cn', ANSI_NORMAL),
|
||||
(r'%ch', ANSI_HILITE),
|
||||
(r'%r', ANSI_RETURN),
|
||||
(r'%t', ANSI_TAB),
|
||||
(r'%b', ANSI_SPACE),
|
||||
|
|
@ -221,33 +223,48 @@ class ANSIParser(object):
|
|||
(r'%cw', ANSI_WHITE),
|
||||
(r'%cW', ANSI_BACK_WHITE),
|
||||
(r'%cx', ANSI_BLACK),
|
||||
(r'%cX', ANSI_BACK_BLACK),
|
||||
(r'%ch', ANSI_HILITE),
|
||||
(r'%cn', ANSI_NORMAL),
|
||||
(r'%cX', ANSI_BACK_BLACK)
|
||||
]
|
||||
|
||||
# Expanded mapping {r {n etc
|
||||
|
||||
hilite = ANSI_HILITE
|
||||
normal = ANSI_NORMAL
|
||||
|
||||
ext_ansi_map = [
|
||||
(r'{n', normal), # reset
|
||||
(r'{/', ANSI_RETURN), # line break
|
||||
(r'{-', ANSI_TAB), # tab
|
||||
(r'{_', ANSI_SPACE), # space
|
||||
(r'{\*', ANSI_INVERSE), # invert
|
||||
(r'{\^', ANSI_BLINK), # blinking text (very annoying and not supported by all clients)
|
||||
|
||||
(r'{r', hilite + ANSI_RED),
|
||||
(r'{R', normal + ANSI_RED),
|
||||
(r'{g', hilite + ANSI_GREEN),
|
||||
(r'{G', normal + ANSI_GREEN),
|
||||
(r'{y', hilite + ANSI_YELLOW),
|
||||
(r'{Y', normal + ANSI_YELLOW),
|
||||
(r'{b', hilite + ANSI_BLUE),
|
||||
(r'{B', normal + ANSI_BLUE),
|
||||
(r'{m', hilite + ANSI_MAGENTA),
|
||||
(r'{M', normal + ANSI_MAGENTA),
|
||||
(r'{c', hilite + ANSI_CYAN),
|
||||
(r'{C', normal + ANSI_CYAN),
|
||||
(r'{w', hilite + ANSI_WHITE), # pure white
|
||||
(r'{W', normal + ANSI_WHITE), # light grey
|
||||
(r'{x', hilite + ANSI_BLACK), # dark grey
|
||||
|
||||
(r'{R', normal + ANSI_RED),
|
||||
(r'{G', normal + ANSI_GREEN),
|
||||
(r'{Y', normal + ANSI_YELLOW),
|
||||
(r'{B', normal + ANSI_BLUE),
|
||||
(r'{M', normal + ANSI_MAGENTA),
|
||||
(r'{C', normal + ANSI_CYAN),
|
||||
(r'{W', normal + ANSI_WHITE), # light grey
|
||||
(r'{X', normal + ANSI_BLACK), # pure black
|
||||
(r'{n', normal) # reset
|
||||
|
||||
(r'{\[r', ANSI_BACK_RED),
|
||||
(r'{\[g', ANSI_BACK_GREEN),
|
||||
(r'{\[y', ANSI_BACK_YELLOW),
|
||||
(r'{\[b', ANSI_BACK_BLUE),
|
||||
(r'{\[m', ANSI_BACK_MAGENTA),
|
||||
(r'{\[c', ANSI_BACK_CYAN),
|
||||
(r'{\[w', ANSI_BACK_WHITE), # light grey background
|
||||
(r'{\[x', ANSI_BACK_BLACK) # pure black background
|
||||
]
|
||||
|
||||
# xterm256 {123, %c134,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue