3

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!

Darcendsun
  • 77
  • 2
  • 7

1 Answers1

2

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;
}
parkydr
  • 7,596
  • 3
  • 32
  • 42
  • No problem - and I got a hat :) – parkydr Dec 25 '14 at 10:05
  • 7
    This isn't a subwindow. You have just the one window in stdscr. –  Oct 18 '19 at 04:40
  • @OS2 Yes..and the OP mentioned *`newwin`* not *`subwin`*. In some implementations the man page says 'The subwindow functions (subwin, derwin, mvderwin, wsyncup, wsyncdown, wcursyncup, syncok) are flaky, incompletely implemented, and not well tested.' under BUGS. It creates a region however in the answer here and that's the idea unless I'm much mistaken (and since it was accepted as the answer...). – Pryftan Jan 28 '20 at 19:13
  • The OP is talking about making a sub-window (window in a window) not the subwindow functions – parkydr Mar 08 '20 at 08:24