Output “█” with ncursesw in C

橙三吉。 提交于 2019-12-11 06:16:45

问题


I'm making a tetris game in C to run on an embedded system, but I'd like to have a mock up interface made using Block characters such as "█" (UNICODE 0x2588).

I'm already using ncursesw and have heard mentions of using wprintw() instead of prints().

printw("%i %i %i %i %i %i %i %i %i\n",board[0][i],board[1][i],board[2][i],board[3][i],board[4][i],board[5][i],board[6][i],board[7][i], piece);

What should this line be in order to output "█"?


回答1:


The are no print functions, just the addwstr functions:

addwstr, addnwstr, waddwstr, waddnwstr, mvaddwstr, mvaddnwstr, mvwaddwstr, mvwaddnwstr 
- add a string of wide characters to a curses window and advance cursor

and add_wch functions:

add_wch, wadd_wch, mvadd_wch, mvwadd_wch, echo_wchar, wecho_wchar 
- add a complex character and rendition to a curses window, then advance the cursor

Some of the characters have macros e.g. WACS_BLOCK for a block.

For your code you would have to make the wchar_t string and then use addwstr



来源:https://stackoverflow.com/questions/16973052/output-with-ncursesw-in-c

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