c++ - How do I put a subwindow within a subwindow? -


i using ncurses try , desired output: i trying put blue box inside white space

however following code:

int main(void) {      window *white_space,*red_space,*blue_box;      int maxx,maxy;       initscr();      start_color();      init_pair(1,color_white,color_blue);      init_pair(2,color_red,color_white);      init_pair(3,color_black,color_green);      init_pair(4,color_red,color_red);        white_space = subwin(stdscr,10,76,6,2);      red_space = subwin(stdscr,1,80,23,0);      getmaxyx(white_space,maxy,maxx);      blue_box = subwin(white_space,maxy-1,maxx-1,8,20);      if(white_space == null)      {      addstr("unable create subwindow\n");      endwin();      return 1;      }        bkgd(color_pair(1));      addstr("master window");      wbkgd(white_space,color_pair(2));      mvwprintw(white_space, 0, 0, "%46s", "white space");      wbkgd(blue_box,color_pair(4));      wbkgd(red_space,color_pair(3));      waddstr(red_space,"alert area");      wrefresh(white_space);      wrefresh(stdscr);        refresh();      getch();       endwin();      return 0; } 

i following output: enter image description here

is possible create subwindow within subwindow?

thanks

ncurses (any non-buggy version of curses) supports subwindows, noted in manual.

in given example, there few problems noticed:

 white_space = subwin(stdscr,10,76,6,2);  red_space = subwin(stdscr,1,80,23,0);  getmaxyx(white_space,maxy,maxx);  blue_box = subwin(white_space,maxy-1,maxx-1,8,20); 

for instance:

  • the initial size given white_space not take account actual screen-size (which narrower 80 columns)
  • the size asked blue_box smaller white_space, starts far enough right window not (in 80 columns) shown. if so, no window created.

there several programs in ncurses-examples using subwin , related derwin, may useful comparison.


Comments