tartley / colorama

Simple cross-platform colored terminal text in Python
BSD 3-Clause "New" or "Revised" License
3.49k stars 248 forks source link

Style.ITALIC #122

Open arsari opened 7 years ago

arsari commented 7 years ago

Does colorama.py have italic style? Does it considered to be added?

wiggin15 commented 7 years ago

Hi there. colorama is meant to work on both Linux and Windows and convert supported ANSI styles to Windows code where possible. While it is possible to produce italic style on some Unix terminals like this:

print '\x1b[3mThis is in italic!\x1b[0m'

Windows doesn't have a matching console attribute to produce a similar effect (MSDN). Therefore there are no plans to add this style to colorama. If you want to support Unix terminals only, you can always manually add the ANSI codes like above. See also the issue about other possible ANSI styles that we could not add: https://github.com/tartley/colorama/issues/38#issuecomment-128834060

rspencer01 commented 6 years ago

According to the README, Windows doesn't support DIM either, yet that is included in colorama. I think this is reasonable to ask to include this, just with a silent fail for Windows.

wiggin15 commented 6 years ago

You're right about DIM being in the code but not supported. I'm still not sure about adding all the other styles though. There are a lot:

    DIM           = 2   # not supported on Windows
    ITALIC        = 3   # not supported on Windows
    UNDERLINE     = 4   # not supported on Windows
    BLINK         = 5   # slow blink. not supported on Windows and not widely supported on Linux
    RBLINK        = 6   # rapid blink. not supported on Windows and not widely supported on Linux
    REVERSEVID    = 7   # not supported on Windows
    CONCEAL       = 8   # not supported on Windows and not widely supported on Linux
    STRIKETHROUGH = 9   # not supported on Windows and not widely supported on Linux
    FRAKTUR       = 20  # not supported on Windows and not widely supported on Linux

Adding or not adding the codes is really @tartley's call. Note that adding the definitions will not really have an effect except for letting users write code like this:

print(colorama.Style.ITALIC)

instead of printing the codes directly without colorama's help, like this:

print('\x1b[3m')

or maybe even like this

ITALIC = 3
print colorama.ansi.code_to_chars(ITALIC)

In the past, @tartley mentioned that if you only want to have convenience definition for the different ANSI codes, you should look at other packages like termcolor or ansicolors.

tartley commented 6 years ago

It is my opinion that Colorama shouldn't try to (badly) duplicate all the functionality that is already available very thoroughly and elegantly in packages like termcolor or the amazing blessings. To be honest, I regret including all of the colors and styles that are already built into colorama - users could have very easily used those other packages to achieve the same (and often much better) effects. I wish we could just do one thing (Windows compatibility) and do it well. If it makes for less code and fewer issues in the future, so much the better.

Having said that - I consider myself retired from the project. I no longer use Windows for anything but gaming, and want to empower @wiggin15 and the other contributors to take the project in the direction they view as wisest, with my blessing, because it's them who will have to live with the consequences of the decision, not me.

alexraju91 commented 4 years ago

When using a package like colorma, users will normally expect it to handle all the basic text formatting like bold, italics etc. :(

tartley commented 4 years ago

@alexforever86 Not if the docs prominently say "Don't use this package for text formatting, just call colorama.init() and use "blessings" instead, it's much better!"