Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle escape sequences with ncurses? Does printf handle escape sequences?

My program read some text data from network, something like: Hello \033[1;34mworld\033[0m and bla bla bla!!!\n". When program output this string using prinf, the word "world" is blue. But when I'm using ncurses interface with wprintw or addch, I see the original string with escape sequences. Does it mean that printf handle escape sequences or not? What is the best way handle escape sequences with ncurses?

like image 913
van Avatar asked Dec 02 '25 19:12

van


1 Answers

No, your terminal handles the escape sequences. The phenomenon you're seeing comes from the fact that ncurses' whole purpose is to keep track of the intended terminal contents and be able to repaint it, and as part of doing this it strips any escape sequences. It might provide an alternative function to interpret them and apply them to its own image of what the terminal should contain, but otherwise you'll have to do this job yourself...

like image 147
R.. GitHub STOP HELPING ICE Avatar answered Dec 05 '25 09:12

R.. GitHub STOP HELPING ICE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!