Ncurses: Difference between doupdate() and refresh() for panels

梦想与她 提交于 2019-12-10 19:26:36

问题


What is the difference between doupdate() and refresh()?

It appears that refresh () can be substituted for doupdate(), however text does not appear unless refresh() is called.

Also, does refresh() refresh all the windows, or should refresh() be called for every window, that is inside a panel?


回答1:


From Dan Gookin's Programmer's Guide to NCurses (page 513):

The refresh operation in NCurses consists of two parts:

  • First, NCurses takes those portions of a window that have been changed or touched and writes those portions from the window data
    structure to a virtual screen in memory.
  • Second, the contents of the virtual screen touched since the last refresh are displayed on the terminal.

The copying of information from a window data structure to the virtual screen is carried out by the wnoutrefresh() function. The updating of the virtual screen to the terminal is handled by another function, doupdate(). Together they form the two components of a refresh() or wrefresh() call.

The advantage of using wnoutrefresh() comes when updating multiple windows. In that case, repeated calls to wnoutrefresh() followed by a sin- gle doupdate() call is more efficient than a series of wrefresh() calls, plus it results in less flicker.

As far as panels are concerned, they are sort of wrappers to windows (so each panel has exactly one window). It should be enough to call update_panels() (which writes the windows to the virtual screen in the correct stacking order given by the panels) and then doupdate() to output virtual screen to the terminal.

If you want to further divide your panels, consider using subwindows.



来源:https://stackoverflow.com/questions/14899708/ncurses-difference-between-doupdate-and-refresh-for-panels

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!