comparison nnchat.c @ 119:4bc63a535acb

Fix some PDCurses incompatibilities and remove some Win32/PDCurses specific hacks.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 28 Oct 2010 23:22:31 +0300
parents 9e7f52878725
children 804c7db454b4
comparison
equal deleted inserted replaced
118:9e7f52878725 119:4bc63a535acb
16 16
17 17
18 #define SET_MAX_BACKBUF (1024) 18 #define SET_MAX_BACKBUF (1024)
19 #define SET_MAX_HISTORY (16) 19 #define SET_MAX_HISTORY (16)
20 #define SET_DELAY (15) 20 #define SET_DELAY (15)
21 #define SET_DELAY_USEC (SET_DELAY * 250) 21 #define SET_DELAY_USEC (SET_DELAY * 150)
22 #define SET_KEEPALIVE (15*60) /* Ping/keepalive period in seconds */ 22 #define SET_KEEPALIVE (15*60) /* Ping/keepalive period in seconds */
23 23
24 char *ignoreList[] = { 24 char *ignoreList[] = {
25 "purr_rr", 25 "purr_rr",
26 "moisha", 26 "moisha",
174 timeStamp = time(NULL); 174 timeStamp = time(NULL);
175 if ((tmpTime = localtime(&timeStamp)) != NULL) { 175 if ((tmpTime = localtime(&timeStamp)) != NULL) {
176 strftime(tmpStr, sizeof(tmpStr), "%H:%M:%S", tmpTime); 176 strftime(tmpStr, sizeof(tmpStr), "%H:%M:%S", tmpTime);
177 } 177 }
178 178
179 #ifdef __WIN32 179 wbkgdset(statusWin, COLOR_PAIR(10));
180 /* PDCurses does not like the hack used for ncurses to get a specific
181 * colour background .. so we just use something else, but uglier. :|
182 */
183 wbkgdset(statusWin, A_REVERSE | COLOR_PAIR(13));
184 #else
185 wbkgdset(statusWin, 0x0d00);
186 #endif
187 werase(statusWin); 180 werase(statusWin);
188 181
189 wattrset(statusWin, A_BOLD); 182 wattrset(statusWin, A_BOLD | COLOR_PAIR(11));
190 mvwaddstr(statusWin, 0, 1, tmpStr); 183 mvwaddstr(statusWin, 0, 1, tmpStr);
191 184
185 wattrset(statusWin, A_BOLD | COLOR_PAIR(13));
192 waddstr(statusWin, " | "); 186 waddstr(statusWin, " | ");
193 wattrset(statusWin, A_BOLD | COLOR_PAIR(16)); 187 wattrset(statusWin, A_BOLD | COLOR_PAIR(16));
194 waddstr(statusWin, optUserName); 188 waddstr(statusWin, optUserName);
195 wattrset(statusWin, A_BOLD | COLOR_PAIR(13)); 189 wattrset(statusWin, A_BOLD | COLOR_PAIR(13));
196 190
953 BOOL update = FALSE; 947 BOOL update = FALSE;
954 948
955 /* Handle several buffered keypresses at once */ 949 /* Handle several buffered keypresses at once */
956 do { 950 do {
957 c = wgetch(stdscr); 951 c = wgetch(stdscr);
958
959 if (c == 0x1b) { 952 if (c == 0x1b) {
960 c = wgetch(stdscr); 953 c = wgetch(stdscr);
961 if (c == 'O') { 954 if (c == 'O') {
962 c = wgetch(stdscr); 955 c = wgetch(stdscr);
963 switch (c) { 956 switch (c) {
971 printMsg("Unhandled ESC key sequence 0x%02x\n", c); 964 printMsg("Unhandled ESC key sequence 0x%02x\n", c);
972 continue; 965 continue;
973 } 966 }
974 } 967 }
975 968
969
976 switch (c) { 970 switch (c) {
977 #ifdef KEY_RESIZE 971 #ifdef KEY_RESIZE
978 case KEY_RESIZE: 972 case KEY_RESIZE:
973 #ifdef PDCURSES
974 resize_term(0, 0);
975 erase();
976 timeout(SET_DELAY);
977 #endif
978
979 if (!initializeWindows()) { 979 if (!initializeWindows()) {
980 errorMsg("Error resizing ncurses windows\n"); 980 errorMsg("Error resizing curses windows\n");
981 isError = TRUE; 981 isError = TRUE;
982 } 982 }
983 update = TRUE;
983 break; 984 break;
984 #endif 985 #endif
985 986
986 case KEY_ENTER: 987 case KEY_ENTER:
987 case '\n': 988 case '\n':