c++ - Make a 1x8 cell in ncurses without border -


i want make 1x8 cell in ncurses without border. first thing did making window

window*win = newwin(height, width, 0, 0); 

with height 24 , width 80. want make column header , row header.in column want strings 'a' 'i' , in rowheader want strings '1' '23'. means cells height 1 , width 8 , there on position (0,0) empty cell. want every cell in header property standout. wrote function drawcell(). tried

void drawcell(int x , int y, const char* ch){    clear();    wattron(win, a_standout);    mvwprintw(win, x,y,ch);    wrefresh(win);    getchar();     endwin(); }//drawcell 

the problem function display string 'ch' in standout. cant figure out how place string in cell height 1 , width 8.

given description, sounds if want like

#define cell_wide 8 #define cell_high 1  void drawcell(int col , int row, const char* ch) {    int y = row * cell_high;    int x = col * cell_wide;    wattron(win, a_standout);    wmove(win, y, x);                 // tidier separate...    wprintw("%*s", " ");              // fill cell blanks    wprintw("%.*s", cell_wide, ch);   // write new text in cell    wrefresh(win); #if 0    getchar();     endwin(); #endif }//drawcell 

because have translate cell's row , column position x , y coordinates.

a few notes:

  • i ifdef'd out call getchar because appears used debugging.

  • if drawing lot of cells, should move wrefresh(win) out of function, e.g., refresh whole window.

  • to avoid clearing window, should use wgetch(win) rather getch(), since latter refreshes stdscr, , may overwrite window.

addressing comment, if function changed to

void drawcell(int col , int row, const char* ch) {    int y = row * cell_high;    int x = col * cell_wide;    wmove(win, y, x);                 // tidier separate...    wprintw("%*s", " ");              // fill cell blanks    wattron(win, a_standout);    wprintw("%.*s", cell_wide, ch);   // write new text in cell    wattroff(win, a_standout);    wrefresh(win); #if 0    getchar();     endwin(); #endif }//drawcell 

then text of cell shown in standout mode.


Comments