问题
I created decrypt.py two days ago. It's quite a funny program. It reads from stdin and prints the contents garbled to the screen using curses. However, when there are special characters like ansi color codes or tabs present in the input, they don't get displayed properly.
Is there a good way to map these characters to the way curses handles tabs and colors on the terminal window?
Your help is much appreciated.
回答1:
This is a pretty niche function, so I'm not surprised there's been no answer. Given the 3 year silence, I don't think you'll find any ready-made code to handle this.
The closest I think you'll get is the ansi to win32 mapping in colorama. You would have to write a similar Regex parser and then use it to convert to curses calls instead.
来源:https://stackoverflow.com/questions/11877851/curses-for-python-convert-ansi-color-codes-from-stdin-to-curses-output