Mercurial > hg
comparison mcabber/src/screen.c @ 419:2f9852610cf4
Small code review
Some clean up and security checks
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 02 Sep 2005 20:34:17 +0200 |
parents | 9c640ee3bae3 |
children | b44be19d6229 |
comparison
equal
deleted
inserted
replaced
418:05bcc91b8699 | 419:2f9852610cf4 |
---|---|
299 lines = CHAT_WIN_HEIGHT; | 299 lines = CHAT_WIN_HEIGHT; |
300 cols = maxX - ROSTER_WIDTH; | 300 cols = maxX - ROSTER_WIDTH; |
301 | 301 |
302 tmp->win = newwin(lines, cols, y, x); | 302 tmp->win = newwin(lines, cols, y, x); |
303 while (!tmp->win) { | 303 while (!tmp->win) { |
304 usleep(250); | 304 safe_usleep(250); |
305 tmp->win = newwin(lines, cols, y, x); | 305 tmp->win = newwin(lines, cols, y, x); |
306 } | 306 } |
307 wbkgd(tmp->win, COLOR_PAIR(COLOR_GENERAL)); | 307 wbkgd(tmp->win, COLOR_PAIR(COLOR_GENERAL)); |
308 tmp->panel = new_panel(tmp->win); | 308 tmp->panel = new_panel(tmp->win); |
309 tmp->name = (char *) calloc(1, 96); | 309 tmp->name = (char *) calloc(1, 96); |
391 line = *(lines+n); | 391 line = *(lines+n); |
392 // NOTE: update PREFIX_WIDTH if you change the date format!! | 392 // NOTE: update PREFIX_WIDTH if you change the date format!! |
393 // You need to set it to the whole prefix length + 1 | 393 // You need to set it to the whole prefix length + 1 |
394 if (line) { | 394 if (line) { |
395 if (line->timestamp) { | 395 if (line->timestamp) { |
396 strftime(date, 35, "%m-%d %H:%M", localtime(&line->timestamp)); | 396 strftime(date, 30, "%m-%d %H:%M", localtime(&line->timestamp)); |
397 } else | 397 } else |
398 strcpy(date, " "); | 398 strcpy(date, " "); |
399 if (line->flags & HBB_PREFIX_INFO) { | 399 if (line->flags & HBB_PREFIX_INFO) { |
400 char dir = '*'; | 400 char dir = '*'; |
401 if (line->flags & HBB_PREFIX_IN) | 401 if (line->flags & HBB_PREFIX_IN) |
1157 num++; | 1157 num++; |
1158 } else { | 1158 } else { |
1159 // First message line (we skip leading empty lines) | 1159 // First message line (we skip leading empty lines) |
1160 num = 0; | 1160 num = 0; |
1161 if (line[0]) { | 1161 if (line[0]) { |
1162 multiline = g_new(char, strlen(line)+1); | 1162 multiline = g_strdup(line); |
1163 strcpy(multiline, line); | |
1164 num++; | 1163 num++; |
1165 } else | 1164 } else |
1166 return; | 1165 return; |
1167 } | 1166 } |
1168 scr_LogPrint(LPRINT_NORMAL, "Multi-line mode: line #%d added [%.25s...", | 1167 scr_LogPrint(LPRINT_NORMAL, "Multi-line mode: line #%d added [%.25s...", |
1325 scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); | 1324 scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
1326 return; | 1325 return; |
1327 } | 1326 } |
1328 | 1327 |
1329 strcpy(tmpLine, ptr_inputline); | 1328 strcpy(tmpLine, ptr_inputline); |
1330 strcpy(ptr_inputline, text); ptr_inputline += len; | 1329 strcpy(ptr_inputline, text); |
1330 ptr_inputline += len; | |
1331 strcpy(ptr_inputline, tmpLine); | 1331 strcpy(ptr_inputline, tmpLine); |
1332 } | 1332 } |
1333 | 1333 |
1334 // scr_handle_tab() | 1334 // scr_handle_tab() |
1335 // Function called when tab is pressed. | 1335 // Function called when tab is pressed. |
1533 // Reset history line pointer | 1533 // Reset history line pointer |
1534 cmdhisto_cur = NULL; | 1534 cmdhisto_cur = NULL; |
1535 } else { // down-history | 1535 } else { // down-history |
1536 // Use next history line instead of a blank line | 1536 // Use next history line instead of a blank line |
1537 const char *l = scr_cmdhisto_next("", 0); | 1537 const char *l = scr_cmdhisto_next("", 0); |
1538 if (l) | 1538 if (l) strcpy(inputLine, l); |
1539 strcpy(inputLine, l); | |
1540 // Reset backup history line | 1539 // Reset backup history line |
1541 cmdhisto_backup[0] = 0; | 1540 cmdhisto_backup[0] = 0; |
1542 } | 1541 } |
1543 break; | 1542 break; |
1544 case KEY_UP: | 1543 case KEY_UP: |
1545 { | 1544 { |
1546 const char *l = scr_cmdhisto_prev(inputLine, | 1545 const char *l = scr_cmdhisto_prev(inputLine, |
1547 ptr_inputline-inputLine); | 1546 ptr_inputline-inputLine); |
1548 if (l) { | 1547 if (l) strcpy(inputLine, l); |
1549 strcpy(inputLine, l); | |
1550 } | |
1551 } | 1548 } |
1552 break; | 1549 break; |
1553 case KEY_DOWN: | 1550 case KEY_DOWN: |
1554 { | 1551 { |
1555 const char *l = scr_cmdhisto_next(inputLine, | 1552 const char *l = scr_cmdhisto_next(inputLine, |
1556 ptr_inputline-inputLine); | 1553 ptr_inputline-inputLine); |
1557 if (l) { | 1554 if (l) strcpy(inputLine, l); |
1558 strcpy(inputLine, l); | |
1559 } | |
1560 } | 1555 } |
1561 break; | 1556 break; |
1562 case KEY_PPAGE: | 1557 case KEY_PPAGE: |
1563 scr_CheckAutoAway(TRUE); | 1558 scr_CheckAutoAway(TRUE); |
1564 scr_RosterUp(); | 1559 scr_RosterUp(); |