我正在尝试处理调整大小信号(SIGWINCH)
void Server::resizeSignalHandler(int a)
{
signal(SIGWINCH, SIG_IGN);
endwin();
initscr();
refresh();
clear();
int x,y;
getmaxyx(stdscr, y, x);
wmove(upScreen, 0, 0);
wmove(downScreen, y/2, 0);
wresize(upScreen, y/2, x);
wresize(downScreen, y/2, x);
wclear(upScreen);
wclear(downScreen);
waddstr(upScreen, "test1");
waddstr(downScreen, "test2");
wrefresh(upScreen);
wrefresh(downScreen);
refresh();
signal(SIGWINCH, Server::resizeSignalHandler);
}
Server::Server()
{
//ncurses screen initialization
initscr();
if (!upScreen) {
upScreen = newwin(0, 0, 1, 1);
}
if (!downScreen) {
downScreen = newwin(0, 0, 1, 1);
}
//adjusting screen when user resize terminal
signal(SIGWINCH, Server::resizeSignalHandler);
//configuring screens
Server::resizeSignalHandler(0);
waddstr(Server::upScreen, "lalfasdfsafd as");
waddstr(downScreen, "supreme!");
wrefresh(Server::upScreen);
wrefresh(downScreen);
}
当我调试这段代码时,在 resizeSignalHandler var x,y 中总是相同的(大小没有改变)。我还尝试使用 ioctl 确定大小,但没有任何改变。
我发现在我之前很多人都有这个问题 http://www.mail-archive.com/arch@archlinux.org/msg11253.html 有时,他们解决了这个问题(更改 /etc/profile ;O(原文如此!)) ,但有时不是。是否有任何替代 mac os x 终端,也许 ncurses 专用于 xterm 和类似的。