How can I end ncurses without ending a c ++ program?

I am trying to create an ncurses program that ends ncurses mode at a certain point and resumes in normal terminal mode, but the program will still work. Is it possible? endwin(); terminates the program. Here is my code (don't worry about the functions that I did before):

 clear(); refresh(); endwin(); boxmessage("STEP 1"); consolewrite("Removing Popularity Contest..."); std::vector<std::string> removepak; removepak.push_back("popularity-contest"); removepackages(removepak); 
+6
source share
1 answer

endwin() does not terminate your program; something else should do it.

This program works correctly on my system (Ubuntu 11.04, g ++ 4.5.2):

 #include <curses.h> #include <unistd.h> #include <iostream> int main() { initscr(); mvaddstr(10, 10, "Hello, world"); refresh(); sleep(4); endwin(); std::cout << "DONE\n"; } 

It clears the screen, prints โ€œHello, worldโ€ at the expected position, sleeps for 4 seconds, then restores the screen and prints โ€œDONEโ€.

As mentioned in the comments, if boxmessage() uses ncurses, it will not work after endwin() called.

Try adding the code after endwin() , which creates and writes to the file, just to make sure your program doesn't die right there.

Update (almost 16 months later), citing OP's latest comment:

Ok, I found a mistake. Just because I made a series of buttons, I made the case: x part, and I just did not write an integer that calls the function correctly. Thanks for the help!

+4
source

Source: https://habr.com/ru/post/903065/


All Articles