I'm facing a problem with getting a U+2588 █ character from the screen by using the winch()
.
Let's assume I have a window called win
and it looks like this:
###████###
I want to redraw all # characters with new attributes applied on them and ignore the █ characters. Somehow I can't do that because if (winch(win) == ACS_BLOCK)
check fails constantly.
For anyone looking for the full code, here it is:
void highlight_tile(const Program *program, const int row, const int col) {
wmove(program->board->win, TILE_HEIGHT * row + 1, TILE_WIDTH * col + 1);
for (int i = 0; i < TILE_HEIGHT; i++) {
for (int j = 0; j < TILE_WIDTH; j++) {
if (winch(program->board->win) != ACS_BLOCK) {
if ((row + col) % 2 == 0) {
wattron(program->board->win, SELECTION);
wprintw(program->board->win, "#");
wattroff(program->board->win, SELECTION);
} else {
wattron(program->board->win, SELECTION);
wprintw(program->board->win, "~");
wattroff(program->board->win, SELECTION);
}
}
}
wmove(program->board->win, getcury(program->board->win) + 1, getcurx(program->board->win) - TILE_WIDTH);
}
}
I've tried changing the condition like this:
if (winch(win) == L'\u2588')
if (winch(win) == '█')
if ((winch(win) & A_CHARTEXT) == L'\u2588')
if ((winch(win) & A_CHARTEXT) == '█')
None of them worked properly.
winch
uses only one byte of the character.
Use win_wch
for Unicode (wide-characters), along with getcchar