C - 从 ncurses ui 到外部程序并返回

发布于 2024-09-09 16:24:52 字数 431 浏览 2 评论 0原文

我正在制作一个程序,在 ncurses 中显示一些信息,然后打开 vim (使用 system)以允许用户编辑文件。不过,退出 vim 后,ncurses 屏幕不会重绘。 refreshwrefresh 不执行任何操作,导致我漂亮的菜单完全被丢弃。

所以,我被送回命令行。当我移动到菜单项时,它们会重新绘制。稍微移动一下会得到如下所示的结果:

Tragedy

正如你所看到的,我不再处于我漂亮的 ncurses 中环境,。

我可以完全拆除 ncurses 并重新设置,但有些东西(如菜单位置)不会保留。

我该如何正确地做到这一点?有没有更好的方法来调用一些外部程序并优雅地返回这里?

I'm making a program that displays some info in ncurses, and then opens vim (using system) to allow the user to edit a file. After vim is exited, though, the ncurses screen won't redraw. refresh and wrefresh don't do anything, resulting in the complete trashing of my beautiful menu.

So, I get sent back to the command line. The menu items redraw when I move to them. Moving around a bit results in something that looks like this:

Tragedy

As you can see, I no longer am in my pretty ncurses environment,.

I could tear down ncurses completely and set things up again, but then some stuff (like menu position) is not preserved.

How do I do this correctly? Is there a better way to call some external program and return here gracefully?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

强辩 2024-09-16 16:24:52

我从来没有必要完全重新启动诅咒。

如果您执行类似

def_prog_mode() 的操作,该怎么办
endwin()

执行系统调用

,refresh() 应该恢复它

I've never had to restart curses entirely.

what if you do something like

def_prog_mode() then
endwin()

execute system call

and refresh() should restore it

荆棘i 2024-09-16 16:24:52

将程序状态与诅咒状态分开。

我所知道的唯一干净的方法是完全停止并重新启动诅咒。如果您的程序对其内部状态有一个清晰的概念(它应该如此),那么应该很容易返回到相同的位置。

祝你好运!

Separate your program state from the curses state.

The only clean way I know of is to stop and restart curses entirely. If your program has a clean notion of its internal state (as it should), then it should be easy to go back to the same position.

Good luck!

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