TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Colour Questions (Warning, BWoT)

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
atraeyu



Joined: 12 Dec 2007
Posts: 165

PostPosted: Tue Mar 04, 2014 1:09 pm    Post subject: Colour Questions (Warning, BWoT) Reply with quote

Posted here: http://tintin.sourceforge.net/board/viewtopic.php?p=8233

Disclaimer
I apologize for this giant post. I'm trying to make sure I thoroughly understand how text colourization works.
There are a couple questions in the giant wall of text, I've put em just below in a TL;DR.
Hopefully others may find this reference useful as well.

TL;DR
1. How is the <xxx> <abc> <ABC> syntax implimented? Does tintin convert these codes to ANSI escape sequences? Xterm RGB escape sequences?
2. Why does wrapping raw escape codes in a #system command not produce coloured output? I.E.: #system {echo -e "\e[31mI am red\e[0m"};
3. What kind of syntax is being used for colour inialization on the page: http://tintin.sourceforge.net/scripts/colorutils.php. Xterm RGB, with 'P' as a prefix to make TinTin play nicely?
4. Is it possible to use Xterm RGB colour codes with echo statements to produce coloured output? How is it done?
5. Is it possible to use the <000> syntax with more than 8-bit colours?

Terminal Types & Colour Modes
http://tintin.sourceforge.net/manual/colors.php

This page specifies two different "types" of colours: ANSI & Xterm.
ANSI refers to VT100.

These are different terminal standards, with Xterm being more advanced, but also having backwards compatibility for VT100.

VT100 supports 8 colours.
Xterm supports 256 colours (8-bit colours)
It also appears that some terminals RGB-based colour definitions.

I can get my terminal type in TinTin with:
Code:
#system {echo $TERM}
#OK: EXECUTING 'echo $TERM'

Quote:
> xterm-256color


And to see my colour support in TinTin I use:
Code:
#system {echo $(tput colors)}
#OK: EXECUTING 'echo $(tput colors)'

Quote:
>256


By default zsh set my term type to 'xterm', and tput colors returned 8 instead of 256. I added the following to my .zshrc and now it shows 256 when tmux is running or not:

Code:
export TERM=xterm-256color
[ -n "$TMUX" ] && export TERM=screen-256color


Reference: http://www.economyofeffort.com/2013/08/03/zsh-tmux-vim-and-256-color-madness/

Regardless of what tput colors says I support (8 or 256), I can still render this colour chart:

Screenshot: http://i.imgur.com/H6MpdPD.png
Script: https://github.com/nfarrar/TinNM/blob/master/lib/colour.tin

So even if the term type doesn't specify support for 256 colors, rendering the colors will still work.

VT100 Escape Sequences
Fundamentally, all colour support is provided through the use of escape codes, regardless of which tool your using to enable or define them.
Xterm definitions are a wrapper and superset of the VT100 standard.
All escape codes will be supported in an Xterm terminal, but only a subset will be supported in a VT100 terminal.

These links provide reference on how to use these escape sequences:

http://ascii-table.com/ansi-escape-sequences.php
http://misc.flogisoft.com/bash/tip_colors_and_formatting
http://wynnnetherland.com/journal/a-stylesheet-author-s-guide-to-terminal-colors

To display a coloured message in my terminal using a VT100 escape code, I use:
Code:
echo -e "\e[31mI am red\e[0m"


I would assume that wrapping this in a #system command would work, but that is not the case:
Code:
#system {echo -e "\e[31mI am red\e[0m"};


This doesn't work as I expected and displays an UNCOLOURED message:
Quote:
-e \e[31mI am red\e[0m


However, it does appear that I can use escape codes directly in #showme commands:
Code:
#showme {\e[31mI am red\e[0m};


This does output red text, as expected.

The color utils script uses a different escape sequence format that I'm not familiar with:
http://tintin.sourceforge.net/scripts/colorutils.php

Code:
#alias {colorinit}
{
     #showme \e]P0000000 <008>black;
     #showme \e]P1AA0000 <018>red;
     #showme \e]P200AA00 <028>green;
     #showme \e]P3AAAA00 <038>yellow;
     #showme \e]P40000AA <048>blue;
     #showme \e]P5AA00AA <058>magenta;
     #showme \e]P600AAAA <068>cyan;
     #showme \e]P7AAAAAA <078>white;
     #showme \e]P8555555 <108>light black;
     #showme \e]P9FF5555 <118>light red;
     #showme \e]PA55FF5A <128>light green;
     #showme \e]PBFFFF55 <138>light yellow;
     #showme \e]PC5555FF <148>light blue;
     #showme \e]PDFF55FF <158>light magenta;
     #showme \e]PE55FFFF <168>light cyan;
     #showme \e]PFFFFFFF <178>light white
}


After extensive googling, it looks like these are Xterm RGB escape sequences with a 'P' prefixed, perhaps to make TinTin play nicely?

Xterm Colours
The three character escape codes are part of the ECMA specification. Xterm extends this to supporting RGB codes in escape sequences.
I've tried to use these in echo statements, however they do not seem to work:

Code:
echo -e "\e]1AA0000 I am red\e[0m"

This does not produce coloured output. What am I doing wrong?

And from within TinTin:
Code:
#showme {\e]P9FF5555 I am red\e[0m};

This does not produce coloured output either?

https://gist.github.com/MicahElliott/719710
https://code.google.com/p/yjl/source/browse/Bash/ANSI_test.sh
http://en.wikipedia.org/wiki/X11_color_names
https://github.com/guns/xterm-color-table.vim

TinTin Colours
The man page for colours specifies a way to produce coloured output without using escape sequences:
http://tintin.sourceforge.net/manual/colors.php

I assume that the method used for producing these colours is implimented in TinTin itself and translated to the appropriate escape sequences.
This page defines four different syntaxes to produce coloured output:

1. <xxx>: Coloured Foreground Text
2. <XXX>: Coloured Background Text
3. <abc>: Bold, Dim, Underscore, Blinking, and Reverse text. This syntax appears to only support 8 different colour codes for foreground and background colours.

Based on this, we can produce coloured text in TinTin (but not a shell) using:

Code:
#showme {<faa>I am red.};
#showme {<faa>I am red text.};
#showme {<FAA>I have a red background.};
#showme {<119>I am bold red with the default background.};
#showme {<419>I am underlined red with the default background.};
#showme {<519>I am blinking red with the default background.};

These all produce the desired output EXCEPT the blinking text. The text does not blink. I am unsure why this isn't working.

Is there anyway to combine the <abc> syntax with the <xxx>/<XXX> syntax to add bold, underscore, or blinking characteristics to any of the 256 supported colours, rather than just 8?

RGB Colours
Using RGB with 32-bit colours, over 4 billion colours can be defined by using different combinations of red, green and blue: http://answers.yahoo.com/question/index?qid=20071211121829AAPn0Jy

Is this actually true in a terminal? Or do the colours simply get aproximated to the closest supported equivalent?
How do you print colours using RGB codes in a shell? In TinTin?
Back to top
View user's profile Send private message AIM Address
atraeyu



Joined: 12 Dec 2007
Posts: 165

PostPosted: Tue Mar 04, 2014 1:48 pm    Post subject: Reply with quote

After rereading the man page for colors, this line made sense (with what I just learned about RGB):

Quote:
For xterm 256 colors support use <aaa> to <fff> for RGB foreground colors and <AAA> to <FFF> for RGB background colors.


I think this means that the <abc>/<ABC> syntax maps RGB values using 8-bit color depth to ANSI escape sequences.
Back to top
View user's profile Send private message AIM Address
atraeyu



Joined: 12 Dec 2007
Posts: 165

PostPosted: Tue Mar 04, 2014 2:02 pm    Post subject: Reply with quote

I figured out a little more, from what I've read - there are no terminals that support more than 256 colours (this is because only 256 colors can be defined with 8 bits) - and these supported colors are defined by the X11 consortium:

http://people.csail.mit.edu/jaffer/Color/rgb.txt

So while you can define colors (still not sure of the syntax) in a terminal using RGB syntax, only the colors defined in the list referenced above will be rendered.

Edit: Here's the syntax for using RGB colours:
Code:
echo -e "\033[38;5;208mpeach\033[0;00m"


... or in tintin:
Code:
#showme {\033[38;5;208mpeach\033[0;00m};


http://stackoverflow.com/a/15712766/212343
Back to top
View user's profile Send private message AIM Address
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Tue Mar 04, 2014 8:08 pm    Post subject: Reply with quote

#system {echo -e "\e[31mI am red\e[0m"}; works for me.

Tintin indeed converts a <abc> code into an escape sequence.

The syntax used for color initialization in the script you linked is an xterm specific sequence. It's poorly documented and not supported on all terminals.

Try:

#line substitute colors #system {echo "<abc>test"}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group