当我真的应该在Ruby的模块Curses中手动调用refresh
函数时?我认为在文档中不清楚。
提前致谢。
答案 0 :(得分:1)
refresh
方法指向外部函数refresh()
:
static VALUE
curses_refresh(VALUE obj)
{
curses_stdscr();
refresh();
return Qnil;
}
您可以在curs_refresh manual:
中查看该refresh()
方法的文档
The refresh and wrefresh routines (or wnoutrefresh and doupdate) must be called to get actual output to the terminal, as other routines mere‐ ly manipulate data structures. The routine wrefresh copies the named window to the physical terminal screen, taking into account what is al‐ ready there to do optimizations. The refresh routine is the same, us‐ ing stdscr as the default window. Unless leaveok has been enabled, the physical cursor of the terminal is left at the location of the cursor for that window.
在现代Linux中,您可以在/usr/include/ncurses.h
或/usr/include/curses.h
中看到该功能或宏的声明。例如:
extern NCURSES_EXPORT(int) refresh (void); /* generated */
#define refresh() wrefresh(stdscr)
这是Ruby curses.c
引用标题文件的部分:
#if defined(HAVE_NCURSES_H)
# include <ncurses.h>
#elif defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
#elif defined(HAVE_CURSES_COLR_CURSES_H)
# ifdef HAVE_STDARG_PROTOTYPES
# include <stdarg.h>
# else
# include <varargs.h>
# endif
# include <curses_colr/curses.h>
#else
# include <curses.h>
...
# endif
#endif