Fix color ansi output, it listed the wrong indices of colors. Also updated docs. Resolve #3616

This commit is contained in:
Griatch 2024-09-29 13:19:07 +02:00
parent cd86f93a54
commit cce90a0ecd
3 changed files with 39 additions and 38 deletions

View file

@ -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][issue3615]: Using `print()` in `py` caused an infinite loop (Griatch)
- [Fix][issue3620]: Better handle TaskHandler running against an attribute that - [Fix][issue3620]: Better handle TaskHandler running against an attribute that
was removed since last reload (Griatch) 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][issue3591]: Fix of NPC reaction tutorial code (Griatch)
- Docs: Tutorial fixes (Griatch, aMiss-aWry, feyrkh) - 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 [issue3624]: https://github.com/evennia/evennia/issues/3624
[issue3615]: https://github.com/evennia/evennia/issues/3615 [issue3615]: https://github.com/evennia/evennia/issues/3615
[issue3620]: https://github.com/evennia/evennia/issues/3620 [issue3620]: https://github.com/evennia/evennia/issues/3620
[issue3616]: https://github.com/evennia/evennia/issues/3616
[pull3595]: https://github.com/evennia/evennia/pull/3595 [pull3595]: https://github.com/evennia/evennia/pull/3595
[pull3533]: https://github.com/evennia/evennia/pull/3533 [pull3533]: https://github.com/evennia/evennia/pull/3533
[pull3594]: https://github.com/evennia/evennia/pull/3594 [pull3594]: https://github.com/evennia/evennia/pull/3594

View file

@ -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 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). 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. 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. For the webclient, Evennia will translate the codes to CSS tags.
| Tag | Effect | | Tag | Effect | |
| ---- | ----- | | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- |
| \|n | end all color formatting, including background colors. | | \|n | end all color formatting, including background colors. | |
|\|r | bright red foreground color | | \|r | bright red foreground color | |
|\|g | bright green foreground color | | \|g | bright green foreground color | |
|\|y | bright yellow foreground color | | \|y | bright yellow foreground color | |
|\|b | bright blue foreground color | | \|b | bright blue foreground color | |
|\|m | bright magentaforeground color | | \|m | bright magentaforeground color | |
|\|c | bright cyan foreground color | | \|c | bright cyan foreground color | |
|\|w | bright white foreground color | | \|w | bright white foreground color | |
|\|x | bright black (dark grey) foreground color | | \|x | bright black (dark grey) foreground color | |
|\|R | normal red foreground color | | \|R | normal red foreground color | |
|\|G | normal green foreground color | | \|G | normal green foreground color | |
|\|Y | normal yellow foreground color | | \|Y | normal yellow foreground color | |
|\|B | normal blue foreground color | | \|B | normal blue foreground color | |
|\|M | normal magentaforeground color | | \|M | normal magentaforeground color | |
|\|C | normal cyan foreground color | | \|C | normal cyan foreground color | |
|\|W | normal white (light grey) foreground color | | \|W | normal white (light grey) foreground color | |
|\|X | normal black foreground color | | \|X | normal black foreground color | |
| \|\[# | background colours, e.g. \|\[c for bright cyan background and \|\[C a normal cyan background. | | \|\[# | 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 | | \|!# | 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 | 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 | | \|H | negates the effects of \|h | |
| \|u | underline font if client supports it | | \|u | underline font (not supported in Evennia webclient) | |
| \|U | negates the effects of \|u | | \|U | negates the effects of \|u | |
| \|i | italic font if client supports it | | \|i | italic font (not supported in Evennia webclient) | |
| \|I | negates the effects of \|i | | \|I | negates the effects of \|i | |
| \|s | strikethrough font if client supports it | | \|s | strikethrough font (not supported in Evennia webclient) | |
| \|S | negates the effects of \|s | | \|S | negates the effects of \|s | |
| \|/ | line break. Use instead of Python \\n when adding strings from in-game. | | \|/ | 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. | | \|- | 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 | | \|_ | 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. | | \|* | invert the current text/background colours, like a marker. See note below. | |
Here is an example of the tags in action: Here is an example of the tags in action:

View file

@ -22,9 +22,8 @@ method. Otherwise all text will be returned to all connected sessions.
import time import time
from codecs import lookup as codecs_lookup from codecs import lookup as codecs_lookup
from django.conf import settings
import evennia import evennia
from django.conf import settings
from evennia.utils import create, logger, search, utils from evennia.utils import create, logger, search, utils
COMMAND_DEFAULT_CLASS = utils.class_from_module(settings.COMMAND_DEFAULT_CLASS) 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 # the slices of the ANSI_PARSER lists to use for retrieving the
# relevant color tags to display. Replace if using another schema. # relevant color tags to display. Replace if using another schema.
# This command can only show one set of markup. # This command can only show one set of markup.
slice_bright_fg = slice(7, 15) # from ANSI_PARSER.ansi_map slice_bright_fg = slice(13, 21) # from ANSI_PARSER.ansi_map
slice_dark_fg = slice(15, 23) # 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_dark_bg = slice(-8, None) # from ANSI_PARSER.ansi_map
slice_bright_bg = slice(None, None) # from ANSI_PARSER.ansi_xterm256_bright_bg_map slice_bright_bg = slice(None, None) # from ANSI_PARSER.ansi_xterm256_bright_bg_map