# HG changeset patch # User Matti Hamalainen # Date 1225236867 -7200 # Node ID 65b1ac6a1e2ed9bbf084a9c60e5c7a06d90a0235 # Parent ceec75116aa7d7c6da09ccde3fa670900ce18bb4 Support for resizing the terminal on fly. Not perfect, but works. diff -r ceec75116aa7 -r 65b1ac6a1e2e nnchat.c --- a/nnchat.c Tue Oct 28 00:33:10 2008 +0200 +++ b/nnchat.c Wed Oct 29 01:34:27 2008 +0200 @@ -1056,6 +1056,26 @@ } +BOOL initializeWindows(void) +{ + if (mainWin) delwin(mainWin); + if (statusWin) delwin(statusWin); + if (editWin) delwin(editWin); + + mainWin = newwin(LINES - 4, COLS, 0, 0); + statusWin = newwin(1, COLS, LINES - 4, 0); + editWin = newwin(3, COLS, LINES - 3, 0); + + if (mainWin == NULL || statusWin == NULL || editWin == NULL) { + THERR("Could not create ncurses windows!\n"); + return FALSE; + } + scrollok(mainWin, 1); + + return TRUE; +} + + int main(int argc, char *argv[]) { int tmpSocket, curVis, updateCount = 0; @@ -1075,7 +1095,7 @@ memset(histBuf, 0, sizeof(histBuf)); /* Initialize */ - th_init("NNChat", "Newbie Nudes chat client", "0.6.2", + th_init("NNChat", "Newbie Nudes chat client", "0.6.3", "Written and designed by Anonymous Finnish Guy (C) 2008", "This software is freeware, use and distribute as you wish."); th_verbosityLevel = 0; @@ -1176,21 +1196,14 @@ } - mainWin = newwin(LINES - 4, COLS, 0, 0); - statusWin = newwin(1, COLS, LINES - 4, 0); - editWin = newwin(3, COLS, LINES - 3, 0); + cursesInit = TRUE; - if (mainWin == NULL || statusWin == NULL || editWin == NULL) { - THERR("Could not create ncurses windows!\n"); + if (!initializeWindows()) goto err_exit; - } - scrollok(mainWin, 1); clearBuf(editBuf); printEditBuf("", editBuf); updateStatus(insertMode); - - cursesInit = TRUE; } @@ -1247,6 +1260,13 @@ do { c = getch(); switch (c) { + case KEY_RESIZE: + if (!initializeWindows()) { + THERR("Error resizing ncurses windows\n"); + isError = TRUE; + } + break; + case KEY_ENTER: case '\n': case '\r':