ncurses中菜单的标准位置是0,0。
我可以改变吗?如果是,怎么样?
我尝试了move()
和wmove()
,但结果没有改变。
提前谢谢。
PS:我尝试了什么:
#include <stdlib.h>
#include <ncurses.h>
#include <menu.h>
#define GETMIDDLEX(w) ((COLS - w)/2)
#define GETMIDDLEY(h) ((LINES - h)/2)
#define ARRAYCOUNT(a) (sizeof(a) / sizeof(a[0]))
#define ENTER 10
MENU *startMenu = (MENU *)NULL;
ITEM **startMenu_items = (ITEM **)NULL;
char *startMenu_choices[] =
{
"Play",
"Exit",
};
int startMenu_choices_N, selItem_index = 0;
int startMenu_status = TRUE;
const int menuW = 6;
const int menuH = 2;
int draw_startMenu();
int remove_startMenu();
int draw_startMenu()
{
startMenu_choices_N = ARRAYCOUNT(startMenu_choices);
startMenu_items = (ITEM **)calloc(startMenu_choices_N + 1, sizeof(ITEM *));
for(int i = 0; i < startMenu_choices_N; ++i)
{
startMenu_items[i] = new_item(startMenu_choices[i], "");
}
startMenu_items[startMenu_choices_N] = (ITEM *)NULL;
startMenu = new_menu((ITEM **)startMenu_items);
move(GETMIDDLEY(menuH), GETMIDDLEX(menuW));
post_menu(startMenu);
refresh();
}
int remove_startMenu()
{
unpost_menu(startMenu);
for(int i = 0; i < startMenu_choices_N; ++i)
{
free_item(startMenu_items[i]);
}
free_menu(startMenu);
return 0;
}
这不是主要功能,我认为它是另一个程序的库。
答案 0 :(得分:0)
我找到了一个功能set_menu_sub(my_menu, derwin(stdscr, 0, 0, 10, 20));
,效果很好!