C语言中简单的NCURSES鼠标处理

C语言中简单的NCURSES鼠标处理,c,mouseevent,mouse,ncurses,C,Mouseevent,Mouse,Ncurses,我有以下代码: #include <ncurses.h> #include <string.h> int main() { int ch; initscr(); noecho(); cbreak(); refresh(); while(1) { ch = getch(); addch(ch); }; return 0; } #包括 #包括 int main()

我有以下代码:

#include <ncurses.h>
#include <string.h>

int
main()
{
    int ch;

    initscr();
    noecho();
    cbreak();
    refresh();

    while(1)
    {
        ch = getch();
        addch(ch);
    };

    return 0;
}
#包括
#包括
int
main()
{
int-ch;
initscr();
noecho();
cbreak();
刷新();
而(1)
{
ch=getch();
addch(ch);
};
返回0;
}
当按下鼠标按钮时,它应该在屏幕上输出一些东西,但它没有

我尝试了一些技巧,但没有成功


同样,当我在同一终端上运行htop时,鼠标点击也会起作用。htop似乎没有什么不同,是吗

我添加了mousemask,现在可以用了

#include <ncurses.h>
#include <string.h>

int
main()
{
    int ch;

    initscr();
    noecho();
    cbreak();
    refresh();
    mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);

    while(1)
    {
        ch = getch();
        addch(ch);
    };

    return 0;
}
#包括
#包括
int
main()
{
int-ch;
initscr();
noecho();
cbreak();
刷新();
鼠标掩码(所有鼠标事件报告鼠标位置,空);
而(1)
{
ch=getch();
addch(ch);
};
返回0;
}