如何阻止白色光标在 C++ 的 curses 控制台中移动

How to stop white cursor from moving in curses console in c++

我目前正在尝试使用安装在 Ubuntu 发行版上的 curses 库开发一个简单的角色扮演游戏。我 运行 遇到的问题是,即使库已初始化,我的屏幕上仍然有一个白色光标在闪烁。当我按下键时,光标会向下移动一行,有时会随机移动两行。有什么办法可以防止这种情况发生吗?

您可以尝试使用类似的东西:

system("setterm -cursor off");

cstdlib图书馆

使用curs_set隐藏光标:

The curs_set routine sets the cursor state to invisible, normal, or very visible for visibility equal to 0, 1, or 2 respectively. If the terminal supports the visibility requested, the previous cursor state is returned; otherwise, ERR is returned.

当您的程序调用 endwin 时,ncurses 会自动恢复光标可见性。

关于光标移动"randomly",没有看到你的(小)示例程序,没有人能回答这个问题。