Mercurial > hg > nnchat
changeset 46:65b1ac6a1e2e
Support for resizing the terminal on fly. Not perfect, but works.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 29 Oct 2008 01:34:27 +0200 |
parents | ceec75116aa7 |
children | e47955d42b55 |
files | nnchat.c |
diffstat | 1 files changed, 30 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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':