使用示例 ncurses 代码,但需要说明
Using example ncurses code, but need clarification
我正在 gcc 和 Fedora 下使用 ncurses 库编译一些 c 代码。代码完全复制自 http://techlister.com/linux/creating-menu-with-ncurses-in-c/1293/
它编译得很好,但在我操作代码时,我想了解 ncurses 的一些微妙之处——特别是它的屏幕刷新方案。我在多个地方(本网站和其他地方)读过这样的陈述:
The refresh and wrefresh routines (or wnoutrefresh and doupdate) must be called to get actual output to the terminal, as other routines merely manipulate data structures.
我将其解释为如果我调用 mvwprintw() 之类的东西,我只是在操纵相当于虚拟 window 的东西,要让我的更改实际出现,我需要调用 wrefresh() .然而,我复制的代码仅在顶部附近调用 wrefresh() 一次,并且似乎根据需要重新绘制屏幕。
问题:有人可以阐明什么时候需要调用 refresh() 或 wrefresh() 吗?
谢谢。
另一个wrefresh
发生在这一行
while(( ch = wgetch(w)) != 'q'){
因为(如 wgetch
manual page 中所述):
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.
我正在 gcc 和 Fedora 下使用 ncurses 库编译一些 c 代码。代码完全复制自 http://techlister.com/linux/creating-menu-with-ncurses-in-c/1293/
它编译得很好,但在我操作代码时,我想了解 ncurses 的一些微妙之处——特别是它的屏幕刷新方案。我在多个地方(本网站和其他地方)读过这样的陈述:
The refresh and wrefresh routines (or wnoutrefresh and doupdate) must be called to get actual output to the terminal, as other routines merely manipulate data structures.
我将其解释为如果我调用 mvwprintw() 之类的东西,我只是在操纵相当于虚拟 window 的东西,要让我的更改实际出现,我需要调用 wrefresh() .然而,我复制的代码仅在顶部附近调用 wrefresh() 一次,并且似乎根据需要重新绘制屏幕。
问题:有人可以阐明什么时候需要调用 refresh() 或 wrefresh() 吗?
谢谢。
另一个wrefresh
发生在这一行
while(( ch = wgetch(w)) != 'q'){
因为(如 wgetch
manual page 中所述):
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.