How to use ANSI escape codes inside mvwprintw in ncurses?

前端 未结 1 1684
生来不讨喜
生来不讨喜 2020-12-06 20:56

Is there a way to use ANSI escape codes inside mvwprintw?

mvwprintw(window, 0, 0,\"%c[%dmCOLORED_TEXT!\\n\         


        
相关标签:
1条回答
  • 2020-12-06 21:35

    No. The only way to make that work would be to parse the string yourself, turning escape codes back into the appropriate curses commands, to issue along with your output.

    One thing you should realize is that those codes, although widely implemented, are not universal. One of the major purposes of curses is to translate its standard commands into series of terminal-specific control codes. So, passing through codes that may or may not correspond to the current terminal type doesn't really fit the curses model. Even more fundamentally, the codes would change the terminal state in a way that curses wouldn't be able to keep track of, so that the contents of its window structures no longer matched what was on screen.

    0 讨论(0)
提交回复
热议问题