ANSI colors - CMUD / Mudlet style

Posted by Dcruze on Sun 03 Jan 2021 10:02 PM — 7 posts, 30,218 views.

#0
In CMUD and Mudlet it is possible to get more than 8 background colors if you are a little tricky with the escape sequences:

For example, combining BLACK background with BOLD and INVERSE produces a dark gray background color that is different from the normal BLACK background.

This applies to all 8 colors, and makes it possible to have a full 16 background colors. I am a creator on a mud, and I like to make ANSI art using nothing but blank space with different colors, which produces a pixellated effect.

My question is, is it possible to get the same effect out of the box with plain Mushclient? I've tried various things, but haven't had any luck so far.

If not, could it be added in a future update?

Thanks in advance.

-d

I'm linking a couple of pictures to illustrate:
1) difference between MUSHclient and CMUD/Mudlet:

<redacted>

2) The difference between ANSI art with 8 colors versus 16 colors:

<redacted>
Amended on Sun 03 Jan 2021 10:10 PM by Fiendish
USA Global Moderator #1
I edited your post to remove those links for your safety because they granted access to the entire contents of your onedrive and not just those two images.

Quote:
combining BLACK background with BOLD and INVERSE

Applying bold and inverse to a black background sounds wrong since I think bold applies to the foreground and inverting swaps foreground and background. I think if you're going to use inverse then you have to have a bold black foreground and then reverse it into the background. It sounds like Mudlet and CMUD are handling your codes pleasantly wrong but that they're the bugged ones, not MUSHclient.

If you really like color, you should know that MUSHclient supports xterm 256 colors: https://www.gammon.com.au/forum/?id=7761&reply=48#reply48

The basic 16 ANSI colors are user controllable (see the ANSI colour configuration panel under Game->Configure->ANSI Colours), so your visualization may not look like what you think it will. Use the xterm 256 colors for proper control.


This code displays 16 distinct colors for me in MUSHclient:

msg=""
for i=0,1 do 
   for j=30,37 do 
      msg = msg ..ANSI(i, 7, j).." "
   end
end
AnsiNote(msg)
Amended on Sun 03 Jan 2021 10:47 PM by Fiendish
#2
Thanks, hopefully this works better:

https://imgur.com/oqvBoLb

I did figure out how to get the same functionality in MUSHclient, if you check the 'Alternative inverse/highlight display' in the Output page of settings it will work the same way as it does in CMUD/Mudlet.

It may be a quirk in our muddriver, and unintuitive, but it is what works... The people who coded it were very restrictive with escape codes, so we're lucky we have color at all.

In the image, on the penultimate line you can see the trick in effect, while for the first item on the last line I use just BLACK BG and BOLD, and it is still the same color as when it is UNBOLDED.

-d
USA Global Moderator #3
I don't know if you saw my edits, but I expanded my response.

See how my code snippet uses foreground colors which when inverted move into the background. If you set background colors and then invert, they move into the foreground, which is not what you want if your foreground character is a blank space.
Amended on Sun 03 Jan 2021 10:49 PM by Fiendish
#4
You are correct, I didn't read the code properly... It is actually set FOREGROUND + INVERSE + SET_BOLD.

How would I go about using Xterm with 256 colors? On my mud there is just a handful of escape codes that are allowed, the usual suspects - everything else gets stripped out. There is no way to use other escape codes without recompiling the driver, which is beyond my skill set currently.

-d
USA Global Moderator #5
So I will say that the order of the escape sequences matters to MUSHclient's state machine.

If you change my previous code snippet to
ANSI(j, i, 7)

instead of
ANSI(i, 7, j)

then it will not show the first set of colors because the bold-reset modifier (i=0 in this case) must come before the color number.
Amended on Sun 03 Jan 2021 11:56 PM by Fiendish
USA Global Moderator #6
As for how to use xterm 256 colors, that's just

ANSI(7, 38, 5, xterm_color_number)

Colors 0-15 are the classics, and then 16-255 are the advanced color cube.


Test in MUSHclient with

msg=""
for j=0,255 do 
   msg = msg ..ANSI(7, 38, 5, j).." "
end
AnsiNote(msg)