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

瘦欲@ 提交于 2019-12-24 00:43:06

问题


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?


回答1:


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...



来源:https://stackoverflow.com/questions/10212070/handle-escape-sequences-with-ncurses-does-printf-handle-escape-sequences

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!