Subwindows with ncurses

元气小坏坏 提交于 2020-05-27 12:16:16

问题


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:


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;
}


来源:https://stackoverflow.com/questions/27613450/subwindows-with-ncurses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!