From cce90a0ecd76048970d387c561a9de1523f578e2 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 29 Sep 2024 13:19:07 +0200 Subject: [PATCH] Fix `color ansi` output, it listed the wrong indices of colors. Also updated docs. Resolve #3616 --- CHANGELOG.md | 2 + docs/source/Concepts/Colors.md | 68 ++++++++++++++--------------- evennia/commands/default/account.py | 7 ++- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ff374afd..46aaa3721f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ did not add it to the handler's object (Griatch) - [Fix][issue3615]: Using `print()` in `py` caused an infinite loop (Griatch) - [Fix][issue3620]: Better handle TaskHandler running against an attribute that was removed since last reload (Griatch) +- [Fix][issue3616]: The `color ansi` command output was broken (Griatch) - [Docs][issue3591]: Fix of NPC reaction tutorial code (Griatch) - Docs: Tutorial fixes (Griatch, aMiss-aWry, feyrkh) @@ -49,6 +50,7 @@ did not add it to the handler's object (Griatch) [issue3624]: https://github.com/evennia/evennia/issues/3624 [issue3615]: https://github.com/evennia/evennia/issues/3615 [issue3620]: https://github.com/evennia/evennia/issues/3620 +[issue3616]: https://github.com/evennia/evennia/issues/3616 [pull3595]: https://github.com/evennia/evennia/pull/3595 [pull3533]: https://github.com/evennia/evennia/pull/3533 [pull3594]: https://github.com/evennia/evennia/pull/3594 diff --git a/docs/source/Concepts/Colors.md b/docs/source/Concepts/Colors.md index d50eda3aea..96a9f8b810 100644 --- a/docs/source/Concepts/Colors.md +++ b/docs/source/Concepts/Colors.md @@ -25,7 +25,7 @@ To see which colours your client support, use the default `color` command. This available colours for ANSI and Xterm256 along with the codes you use for them. The central ansi/xterm256 parser is located in [evennia/utils/ansi.py](evennia.utils.ansi). -## ANSI colours +## ANSI colours and symbols Evennia supports the `ANSI` standard for text. This is by far the most supported MUD-color standard, available in all but the most ancient mud clients. @@ -35,39 +35,39 @@ will see the text in the specified colour, otherwise the tags will be stripped ( For the webclient, Evennia will translate the codes to CSS tags. -| Tag | Effect | -| ---- | ----- | -| \|n | end all color formatting, including background colors. | -|\|r | bright red foreground color | -|\|g | bright green foreground color | -|\|y | bright yellow foreground color | -|\|b | bright blue foreground color | -|\|m | bright magentaforeground color | -|\|c | bright cyan foreground color | -|\|w | bright white foreground color | -|\|x | bright black (dark grey) foreground color | -|\|R | normal red foreground color | -|\|G | normal green foreground color | -|\|Y | normal yellow foreground color | -|\|B | normal blue foreground color | -|\|M | normal magentaforeground color | -|\|C | normal cyan foreground color | -|\|W | normal white (light grey) foreground color | -|\|X | normal black foreground color | -| \|\[# | background colours, e.g. \|\[c for bright cyan background and \|\[C a normal cyan background. | -| \|!# | foreground color that inherits brightness from previous tags. Always uppcase, like \|!R | -| \|h | make any following foreground ANSI colors bright (for Xterm256/true color makes the font bold if client supports it). Use with \|!#. Technically, \|h\|G == \|g. | -| \|H | negates the effects of \|h | -| \|u | underline font if client supports it | -| \|U | negates the effects of \|u | -| \|i | italic font if client supports it | -| \|I | negates the effects of \|i | -| \|s | strikethrough font if client supports it | -| \|S | negates the effects of \|s | -| \|/ | line break. Use instead of Python \\n when adding strings from in-game. | -| \|- | tab character when adding strings in-game. Can vay per client, so usually better with spaces. | -| \|_ | a space. Only needed to avoid auto-cropping at the end of a in-game input | -| \|* | invert the current text/background colours, like a marker. See note below. | +| Tag | Effect | | +| ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | +| \|n | end all color formatting, including background colors. | | +| \|r | bright red foreground color | | +| \|g | bright green foreground color | | +| \|y | bright yellow foreground color | | +| \|b | bright blue foreground color | | +| \|m | bright magentaforeground color | | +| \|c | bright cyan foreground color | | +| \|w | bright white foreground color | | +| \|x | bright black (dark grey) foreground color | | +| \|R | normal red foreground color | | +| \|G | normal green foreground color | | +| \|Y | normal yellow foreground color | | +| \|B | normal blue foreground color | | +| \|M | normal magentaforeground color | | +| \|C | normal cyan foreground color | | +| \|W | normal white (light grey) foreground color | | +| \|X | normal black foreground color | | +| \|\[# | background colours, e.g. \|\[c for bright cyan background and \|\[C a normal cyan background. | | +| \|!# | foreground color that inherits brightness from previous tags. Always uppcase, like \|!R | | +| \|h | make any following foreground ANSI colors bright (for Xterm256/true color makes the font bold if client supports it). Use with \|!#. Technically, \|h\|G == \|g. | | +| \|H | negates the effects of \|h | | +| \|u | underline font (not supported in Evennia webclient) | | +| \|U | negates the effects of \|u | | +| \|i | italic font (not supported in Evennia webclient) | | +| \|I | negates the effects of \|i | | +| \|s | strikethrough font (not supported in Evennia webclient) | | +| \|S | negates the effects of \|s | | +| \|/ | line break. Use instead of Python \\n when adding strings from in-game. | | +| \|- | tab character when adding strings in-game. Can vay per client, so usually better with spaces. | | +| \|_ | a space. Only needed to avoid auto-cropping at the end of a in-game input | | +| \|* | invert the current text/background colours, like a marker. See note below. | | Here is an example of the tags in action: diff --git a/evennia/commands/default/account.py b/evennia/commands/default/account.py index c0296a43dc..93c8e17e92 100644 --- a/evennia/commands/default/account.py +++ b/evennia/commands/default/account.py @@ -22,9 +22,8 @@ method. Otherwise all text will be returned to all connected sessions. import time from codecs import lookup as codecs_lookup -from django.conf import settings - import evennia +from django.conf import settings from evennia.utils import create, logger, search, utils COMMAND_DEFAULT_CLASS = utils.class_from_module(settings.COMMAND_DEFAULT_CLASS) @@ -814,8 +813,8 @@ class CmdColorTest(COMMAND_DEFAULT_CLASS): # the slices of the ANSI_PARSER lists to use for retrieving the # relevant color tags to display. Replace if using another schema. # This command can only show one set of markup. - slice_bright_fg = slice(7, 15) # from ANSI_PARSER.ansi_map - slice_dark_fg = slice(15, 23) # from ANSI_PARSER.ansi_map + slice_bright_fg = slice(13, 21) # from ANSI_PARSER.ansi_map + slice_dark_fg = slice(21, 29) # from ANSI_PARSER.ansi_map slice_dark_bg = slice(-8, None) # from ANSI_PARSER.ansi_map slice_bright_bg = slice(None, None) # from ANSI_PARSER.ansi_xterm256_bright_bg_map