简体   繁体   中英

Curses for python. Convert ansi color codes from stdin to curses output

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM