我一直在尝试制作一个ncurses程序,它将在某个时刻结束ncurses模式,并恢复到正常的终端模式,但仍然保持程序运行。可能吗?endwin();结束了程序。下面是我的代码(不用担心函数,我之前做过):
clear();
refresh();
endwin();
boxmessage("STEP 1");
consolewrite("Removing Popularity Contest...");
std::vector<std::string> removepak;
removepak.push_back("popularity-contest");
removepackages(removepak);发布于 2011-12-05 08:56:19
endwin()没有终止您的程序;一定是其他原因在终止您的程序。
此程序在我的系统(Ubuntu11.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";
}它清除屏幕,在预期位置打印"Hello,world“,休眠4秒,然后恢复屏幕并打印”完成“。
正如评论中提到的,如果boxmessage()使用ncurses,那么在您调用endwin()之后,它将无法工作。
尝试在endwin()之后添加一些创建和写入文件的代码,只是为了验证您的程序不会立即死掉。
更新(近16个月后),引用了OP的最新评论:
好的,我找到bug了。这只是因为我做了一系列的按钮,然后我做了'case: x‘部分,我只是没有写出正确调用函数的整数。感谢您的帮助!
https://stackoverflow.com/questions/8379529
复制相似问题