首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何设置菜单光标位置?

如何设置菜单光标位置?
EN

Stack Overflow用户
提问于 2015-12-26 19:46:44
回答 1查看 393关注 0票数 1

菜单在ncurses中的标准位置是0,0。我能换一下吗?如果是,怎么做?我尝试了move()wmove(),但是结果没有改变。提前谢谢。

PS:我尝试的是:

代码语言:javascript
复制
#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;
}

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-28 19:52:59

我找到了一个功能很好的函数set_menu_sub(my_menu, derwin(stdscr, 0, 0, 10, 20));

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34474656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档