Output “█” with ncursesw in C

2019-08-12 19:08发布

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条回答
ゆ 、 Hurt°
2楼-- · 2019-08-12 19:22

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

查看更多
登录 后发表回答