Subwindows with ncurses

2020-07-23 03:27发布

I'm trying to put a smaller window within the main window using the ncurses library. I'm wanting it to look sort of like the final fantasy battle screen where your main map and character will be on the main window and a subwindow will be at the bottom showing your options for battle.

I'm attempting to do it using "WINDOW * subWin = newwin(nlines, ncols, y0, x0);" but when I run it I don't see any secondary window or subwindow. Would anyone know if what I'm using is incorrect or why I'm not able to actually see the subwindow?

Thanks!

1条回答
何必那么认真
2楼-- · 2020-07-23 04:22

Here is an example showing the main window with a subwindow:

#include <curses.h>

int main(int argc, char** argv)
{
  initscr();

  printw("Main window");

  WINDOW* subwindow = newwin(10,20,5,15);

  refresh();

  box(subwindow,0,0);
  mvwprintw(subwindow, 1, 1, "subwindow");


  refresh();
  wrefresh(subwindow);

  getch();
  delwin(subwindow);

  endwin();
  return 0;
}
查看更多
登录 后发表回答