endwin() 会取消初始化 ncurses 吗?

发布于 2024-08-16 16:56:12 字数 293 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

endwin 之前使用 def_prog_mode 来保存状态。
返回后,执行:reset_prog_mode,然后refresh
将显示您的原始屏幕。

是的,使用 printf 后你必须执行:fflush(stdout)。

Use def_prog_mode prior to endwin to save state.
After returning, do: reset_prog_mode and then refresh.
Your original screen will be shown.

Yes, after using printf you have to do: fflush(stdout).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文