[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Python
. . -> [Subject]  Getting the ansi color data.

Getting the ansi color data.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Smorly   (31 posts)  [Biography] bio
Date Sat 09 Feb 2013 08:50 PM (UTC)
Message
So when using GetStyleInfo() to get colour information, we get an RGB colour.

How do I convert that into an ANSI escape sequence, given that Ansi() takes the ansi escape number?

Is the RGB colour the one that is displayed? That is, if a user changes blue to green-blue, will RGBColourToName return blue or green-blue?
[Go to top] top

Posted by Smorly   (31 posts)  [Biography] bio
Date Reply #1 on Sat 09 Feb 2013 09:37 PM (UTC)
Message
If there's nothing built-in, I have the solution already.

Will post code if anyone wants it.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sat 09 Feb 2013 11:35 PM (UTC)
Message
The colour returned should be what is displayed. ANSI colours are usually looked up, and converted into RGB at the last moment. Not every RGB colour will necessarily have an ANSI equivalent.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Smorly   (31 posts)  [Biography] bio
Date Reply #3 on Sun 10 Feb 2013 12:25 AM (UTC)
Message
I was able to translate the displayed colour to ANSI using world.NormalColour and .BoldColour
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sun 10 Feb 2013 08:31 PM (UTC)
Message
If you are just redisplaying in another window (or a miniwindow) then the RGB codes should be all you need.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Smorly   (31 posts)  [Biography] bio
Date Reply #5 on Sun 10 Feb 2013 09:09 PM (UTC)

Amended on Sun 10 Feb 2013 09:19 PM (UTC) by Smorly

Message
Unless a user expects the parameters that he configures under ANSI Color Data to work properly in the target window.

Also, I need the ANSI data to compose colour messages back to the server.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


18,089 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]