Skip to content

Commit

Permalink
fix windows compat and remove no-color warning
Browse files Browse the repository at this point in the history
We're going to assume that anyone interested in this program will have
some level of color support, so we default to 16 color support if curses
can't detect another.

This also fixes a spurious "no color support" warning on Windows when it
should work (term color support works different on windows). So this
also fixes that issue.
  • Loading branch information
eikenb authored Feb 5, 2022
1 parent b880d0c commit c219bd0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions terminal-colors
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,7 @@ def _terminal():
"""
curses.setupterm()
num_colors = curses.tigetnum('colors')
if num_colors > 0:
return {16:term16, 88:term88, 256:term256}.get(num_colors, term16)
return {16:term16, 88:term88, 256:term256}.get(num_colors, term16)

def main():
if options.test:
Expand All @@ -572,14 +571,11 @@ def main():
print(convert88to256(options.expand))
else:
term = _terminal()
if term is None:
print("Your terminal reports that it has no color support.")
if options.ansicodes:
print(getdoc(term16.ansicodes_display))
term16.ansicodes_display()
else:
if options.ansicodes:
print(getdoc(term16.ansicodes_display))
term16.ansicodes_display()
else:
term.display()
term.display()

if __name__ == "__main__":
main()

0 comments on commit c219bd0

Please sign in to comment.