Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subwindows with ncurses

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!

like image 235
Darcendsun Avatar asked Oct 20 '25 18:10

Darcendsun


1 Answers

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;
}
like image 68
parkydr Avatar answered Oct 22 '25 07:10

parkydr