Search code examples
cncurses

Color one cell ncurses


I wonder, is that possible to kind of "bake" one cell color using ncurses? I mean, i want to set one cell color and then, when i use mvprintw with some other color in attron() i want the cell to still be this "baked" color.

//default color
mvprintw(0, 0, my_game_board);
bake(2,4,cell_color); 
mvprintw(0, 0, my_game_board); //update game board, and then ONLY 2,4 cell should be cell_color.

.

Its like i want to set color for cell, not for content. (when content change, color shoud be same)


Solution

  • Just using mvpwintw, etc., as illustrated, you cannot. That ultimately resolves into waddch calls (see source), which pay attention to

    • the window background (see bkgd),
    • the window attributes (see attr_on) and
    • the character attributes (see last paragraph in addch).

    You could use the panel library to manage the unchanging cell as a separate layer (in its own window), but probably would find it too complicated to use for multiple unchanging cells.