endwin() 会取消初始化 ncurses 吗?
我正在使用 ncurses 库在屏幕上显示一些有趣的输出,但在程序中间我需要暂时退出 ncurses 模式。我调用 endwin()
,之后我的程序应该能够使用 printf()
向用户显示菜单。不幸的是,我的程序无法显示菜单。我尝试在printf()
之后使用fflush()
,然后才能够在屏幕上显示菜单。
谁能告诉我为什么在我调用endwin()
之后,终端无法恢复正常并且我无法使用printf()
?
I am using the ncurses
library to show some funny output on the screen, but in the middle of the program I need to temporarily exit ncurses
mode. I call endwin()
, after which my program should be able to use printf()
to show a menu to the user. Unluckily, my program was unable to show the menu. I tried using fflush()
after printf()
, and only then is it able to show the menu on the screen.
Can anyone tell me why, after I call endwin()
, the terminal can't return to normal and I'm unable to use printf()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
endwin
之前使用def_prog_mode
来保存状态。返回后,执行:
reset_prog_mode
,然后refresh
。将显示您的原始屏幕。
是的,使用 printf 后你必须执行:fflush(stdout)。
Use
def_prog_mode
prior toendwin
to save state.After returning, do:
reset_prog_mode
and thenrefresh
.Your original screen will be shown.
Yes, after using printf you have to do: fflush(stdout).