spangey / miniboa

Automatically exported from code.google.com/p/miniboa
Apache License 2.0
0 stars 0 forks source link

Color codes are not chosen very happily #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
For example
^rblue

Should be blue written in red or lue on red background?
I suggest to make all color codes two characters length.
So red become ^rc and blue ^bc. 

Another problem is when you want to enter '^' character. For example I
wanted to print ^a, where a should be red, so string looks like that
"^^ra", which is interpreted as 'reset colors'ra. I found work around by
adding null character, so it looks like that "^\0^ra" and seems to work right.

Best regards
Michal

Original issue reported on code.google.com by mich.mierzwa@gmail.com on 26 Jan 2010 at 11:57

GoogleCodeExporter commented 8 years ago
Sounds like a good suggestion.  Would you prefer ^^ to insert a single ^ much 
like
'\\' works in Python?

Original comment by jimstorch@gmail.com on 27 Jan 2010 at 4:59

GoogleCodeExporter commented 8 years ago
I have written mud client via www. When I have "^rboots" it is confusing. It is 
interpreted as 'oots' written on red background while it ought to be just 
'boots' in 
red color. Thus adding c to all colors as a second filling character would be 
great.
You can write ^rcboots then and everything is clear.
And it would be better I think if "^^" indeed works like \\ so it become single 
^. 
And for resetting colors (like ^^ now does) you could use ^xx for instance.

I hope that you are able to see my idea despite of my weak english.

PS: Thanks for sharing such a great piece of code.

Original comment by mich.mierzwa@gmail.com on 28 Jan 2010 at 7:19

GoogleCodeExporter commented 8 years ago
I've decided to change everything to use two-character codes.

Background colors will be set by ^[0-6] like so;

    ( '^0', '\x1b[40m' ),          # black background
    ( '^1', '\x1b[41m' ),          # red background
    ( '^2', '\x1b[42m' ),          # green background
    ( '^3', '\x1b[43m' ),          # yellow background
    ( '^4', '\x1b[44m' ),          # blue background
    ( '^5', '\x1b[45m' ),          # magenta background
    ( '^6', '\x1b[46m' ),          # cyan background

Bold on and off will be ^! and ^. instead of ^! and ^1.
Underline on and off will be ^U and ^u.
Inverse on and off will be ^I and ^i.
Reset will be ^~
and ^^ will escape a caret.

I apologize if this causes anyone a lot of string editing. 

Original comment by jimstorch@gmail.com on 31 Jan 2010 at 6:58

GoogleCodeExporter commented 8 years ago
Thanks a lot, that is great.
By the way. 
It is up to you but slightly better would be use another "replace" character, 
for
example that way:
    if ansi:
        text = text.replace('^^', '\0')        
        for token, code in _ANSI_CODES:
            text = text.replace(token, code)
        text = text.replace('\0', '^')
    else:
        text = strip_caret_codes(text)
    return text

as '___^___' could possibly happen as a valid and expected sequence.

Original comment by mich.mierzwa@gmail.com on 1 Feb 2010 at 12:05

GoogleCodeExporter commented 8 years ago
I like your suggestion.  Is there any chance that NULL (0x00) might be used for 
an
extended character sequence in UTF?

Original comment by jimstorch@gmail.com on 2 Feb 2010 at 12:57

GoogleCodeExporter commented 8 years ago
I am afraid that I do not understand. Null is null, both in ASCI and UTF. I do 
not 
think it could become a problem, but... I am only amateur, I do not guarantee. 
:)

Original comment by mich.mierzwa@gmail.com on 3 Feb 2010 at 7:23

GoogleCodeExporter commented 8 years ago
I wasn't sure if NULL held a special meaning in UTF-8 but looking at: 
http://en.wikipedia.org/wiki/UTF-8

It doesn't appear so.  I'm putting in the NULL substitution.  We can always fix 
it if
causes problems.

Original comment by jimstorch@gmail.com on 3 Feb 2010 at 1:17