gpt4 book ai didi

c - 如何设置菜单光标位置?

转载 作者:太空宇宙 更新时间:2023-11-04 04:32:21 28 4
gpt4 key购买 nike

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

没有主要功能,我认为它是另一个程序的库。

最佳答案

我找到了一个函数 set_menu_sub(my_menu, derwin(stdscr, 0, 0, 10, 20));,它工作得很好!

关于c - 如何设置菜单光标位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34474656/

28 4 0