C - transition from ncurses ui to an external program and vice versa

I create a program that displays some information in ncurses and then opens vim (using system) to allow the user to edit the file. However, after vim exits, the ncurses screen will not be redrawn. refreshand wrefreshdo nothing, which leads to the complete destruction of my beautiful menu.

So, I am returning to the command line. Menu items are redrawn when I go to them. Moving a bit leads to what looks like this:

Tragedy

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

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

How to do it right? Is there a better way to invoke some external program and return here gracefully?

+5
source share
2 answers

I never had to completely restart curses.

what if you do something like

def_prog_mode () , then endwin ()

make a system call

and refresh () should restore it

+1
source

Separate your program state from curses state.

The only clean way that I know of is to completely stop and renew the curses. If your program has a clear idea of ​​its internal state (as it should be), then it should be easy to return to that position.

Good luck

0
source

All Articles