使用 ncurses - 试图理解 wgetch()

Using ncurses - trying to understand wgetch()

我使用 ncurses 创建了一个单一的 window 菜单方案并让它运行起来。 当我添加第二个 window 时,我无法再触发我的 wgetch 调用(或者看起来是这样)。

函数原型让我有些困惑:

int wgetch(WINDOW *win);

wgetch 不知何故取决于 window 但我不明白其中的关系 - "the window" 有什么关系?如果有,而且我有不止一个 window,我应该使用哪一个?另外,https://linux.die.net/man/3/wgetch 说 "There is just one input queue for all windows." 告诉我 "the window" 是 "don't care".

谁能解释一下?

谢谢。

window很重要因为wgetch刷新了 window 读字符前。在 wgetch 手册页中:

If the window is not a pad, and it has been moved or modified since the last call to wrefresh, wrefresh will be called before another character is read.

每个 window(包括 stdscr)可能自上次调用 wrefresh。如果您在一个 window 中进行更改而不刷新它,然后在另一个 window 中调用 wgetch,则对第一个 [=40= 的更改] 不会自动显示。您可以使用 wnoutrefresh 组合刷新,例如,将其用于第一个 window,然后使用 wrefresh 自动完成第二个 window 刷新两者。